00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <stdio.h>
00020 #include <stdlib.h>
00021 #include <mysql/mysql.h>
00022 #include <libsql++.h>
00023 #include <string>
00024 using std::string;
00025 #include <libcgi++.h>
00026 #include <libwolfshade.h>
00027
00028 #include "BaseForm.h"
00029 #include "WolfshadeWeb.h"
00030
00031
00032 #include "SkillForm.h"
00033
00034
00035 namespace cgi
00036 {
00037
00038
00039 SkillForm::SkillForm(Web *web)
00040 :BaseForm(web, "skillform")
00041 ,m_edit(0)
00042 ,m_error(false)
00043 {
00044 }
00045
00046
00047 SkillForm::~SkillForm()
00048 {
00049 }
00050
00051
00052 void SkillForm::Process()
00053 {
00054 char action[200];
00055
00056 if (GetForm() -> getvalue("skillform",action,200))
00057 {
00058 if (!strcmp(action,"edit"))
00059 {
00060 char slask[100];
00061 GetForm() -> getvalue("edit",slask,100);
00062 m_edit = atol(slask);
00063 }
00064 else
00065 if (!strcmp(action," Save "))
00066 {
00067 char slask[100];
00068 GetForm() -> getvalue("num",slask,100);
00069 long num = atol(slask);
00070 GetForm() -> getvalue("onum",slask,100);
00071 long onum = atol(slask);
00072 db::Skill skill(GetDatabase(),num);
00073
00074 if (num != onum && skill.num)
00075 {
00076 m_error = true;
00077 }
00078 else
00079 {
00080
00081 GetForm() -> EnableRaw( true );
00082 skill.num = num;
00083 GetForm() -> getvalue("name",skill.name,255);
00084
00085 skill.save();
00086
00087 }
00088 }
00089 }
00090 }
00091
00092
00093 void SkillForm::Select(const string &)
00094 {
00095 }
00096
00097
00098 void SkillForm::List()
00099 {
00100 }
00101
00102
00103 void SkillForm::Display(long)
00104 {
00105 WolfshadeWeb *web = static_cast<WolfshadeWeb *>(GetWeb());
00106 Database *db = GetDatabase();
00107 Query q(db);
00108 long zonesize = 0;
00109 char sql[200];
00110
00111 zonesize = EditingZone();
00112
00113 if (!m_edit)
00114 web -> DisplayStartAntalForm();
00115
00116 if (m_error)
00117 {
00118 printf("<h3>New Skill# is already taken</h3>");
00119 }
00120
00121 {
00122 if (m_edit)
00123 sprintf(sql,"select * from skill where num=%ld",m_edit);
00124 else
00125 {
00126 sprintf(sql,"select * from skill where num>=%ld order by num limit %ld",GetStart(),GetAntal());
00127 }
00128 q.get_result(sql);
00129 char header[100];
00130
00131 if (m_edit)
00132 sprintf(header," Editing Skill#%ld",m_edit);
00133 else
00134 sprintf(header," Skills (%ld skills displayed)",q.num_rows());
00135 Table tbl("#000000", 3, header);
00136 printf("<tr bgcolor=#ffffff>");
00137 printf("<th align=left> Skill | Vnum</th>");
00138 printf("</tr>");
00139
00140 while (q.fetch_row())
00141 {
00142 db::Skill skill(db,&q);
00143
00144 printf("<tr bgcolor=#808080>");
00145 ShowSkill(skill,true,true);
00146 printf("</tr>");
00147 }
00148 q.free_result();
00149 }
00150 printf("<br>");
00151
00152 if (m_edit)
00153 {
00154 db::Skill skill(db,m_edit);
00155
00156
00157 {
00158 }
00159
00160
00161 {
00162 Table tbl("#000000", 3);
00163
00164 printf("<form action=%s method=post>",GetCgiName().c_str());
00165 printf("<input type=hidden name=onum value=%ld>",skill.num);
00166
00167 inputnum("Vnum", "num", skill.num);
00168 inputstr("SkillName","name",60,skill.name,true);
00169 inputsubmit(" Save ");
00170
00171 printf("</form>");
00172 }
00173 printf("<br>");
00174 }
00175 }
00176
00177
00178 }
00179
00180
00181