📄 tianjiashanchuyonghu.h
字号:
// button1
//
this->button1->Font = new System::Drawing::Font(S"宋体", 9, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, (System::Byte)134);
this->button1->Location = System::Drawing::Point(264, 13);
this->button1->Name = S"button1";
this->button1->Size = System::Drawing::Size(72, 32);
this->button1->TabIndex = 41;
this->button1->Text = S"查询";
this->button1->Click += new System::EventHandler(this, button1_Click);
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(96, 21);
this->textBox1->Name = S"textBox1";
this->textBox1->Size = System::Drawing::Size(144, 21);
this->textBox1->TabIndex = 40;
this->textBox1->Text = S"";
//
// label1
//
this->label1->Font = new System::Drawing::Font(S"宋体", 10.5F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, (System::Byte)134);
this->label1->Location = System::Drawing::Point(56, 21);
this->label1->Name = S"label1";
this->label1->Size = System::Drawing::Size(40, 23);
this->label1->TabIndex = 39;
this->label1->Text = S"ID:";
this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
//
// comboBox2
//
System::Object* __mcTemp__4[] = new System::Object*[2];
__mcTemp__4[0] = S"男";
__mcTemp__4[1] = S"女";
this->comboBox2->Items->AddRange(__mcTemp__4);
this->comboBox2->Location = System::Drawing::Point(96, 88);
this->comboBox2->Name = S"comboBox2";
this->comboBox2->Size = System::Drawing::Size(136, 20);
this->comboBox2->TabIndex = 57;
//
// comboBox3
//
System::Object* __mcTemp__5[] = new System::Object*[99];
__mcTemp__5[0] = S"1";
__mcTemp__5[1] = S"2";
__mcTemp__5[2] = S"3";
__mcTemp__5[3] = S"4";
__mcTemp__5[4] = S"5";
__mcTemp__5[5] = S"6";
__mcTemp__5[6] = S"7";
__mcTemp__5[7] = S"8";
__mcTemp__5[8] = S"9";
__mcTemp__5[9] = S"10";
__mcTemp__5[10] = S"11";
__mcTemp__5[11] = S"12";
__mcTemp__5[12] = S"13";
__mcTemp__5[13] = S"14";
__mcTemp__5[14] = S"15";
__mcTemp__5[15] = S"16";
__mcTemp__5[16] = S"17";
__mcTemp__5[17] = S"18";
__mcTemp__5[18] = S"19";
__mcTemp__5[19] = S"20";
__mcTemp__5[20] = S"21";
__mcTemp__5[21] = S"22";
__mcTemp__5[22] = S"23";
__mcTemp__5[23] = S"24";
__mcTemp__5[24] = S"25";
__mcTemp__5[25] = S"26";
__mcTemp__5[26] = S"27";
__mcTemp__5[27] = S"28";
__mcTemp__5[28] = S"29";
__mcTemp__5[29] = S"30";
__mcTemp__5[30] = S"31";
__mcTemp__5[31] = S"32";
__mcTemp__5[32] = S"33";
__mcTemp__5[33] = S"34";
__mcTemp__5[34] = S"35";
__mcTemp__5[35] = S"36";
__mcTemp__5[36] = S"37";
__mcTemp__5[37] = S"38";
__mcTemp__5[38] = S"39";
__mcTemp__5[39] = S"40";
__mcTemp__5[40] = S"41";
__mcTemp__5[41] = S"42";
__mcTemp__5[42] = S"43";
__mcTemp__5[43] = S"44";
__mcTemp__5[44] = S"45";
__mcTemp__5[45] = S"46";
__mcTemp__5[46] = S"47";
__mcTemp__5[47] = S"48";
__mcTemp__5[48] = S"49";
__mcTemp__5[49] = S"50";
__mcTemp__5[50] = S"51";
__mcTemp__5[51] = S"52";
__mcTemp__5[52] = S"53";
__mcTemp__5[53] = S"54";
__mcTemp__5[54] = S"55";
__mcTemp__5[55] = S"56";
__mcTemp__5[56] = S"57";
__mcTemp__5[57] = S"58";
__mcTemp__5[58] = S"59";
__mcTemp__5[59] = S"60";
__mcTemp__5[60] = S"61";
__mcTemp__5[61] = S"62";
__mcTemp__5[62] = S"63";
__mcTemp__5[63] = S"64";
__mcTemp__5[64] = S"65";
__mcTemp__5[65] = S"66";
__mcTemp__5[66] = S"67";
__mcTemp__5[67] = S"68";
__mcTemp__5[68] = S"69";
__mcTemp__5[69] = S"70";
__mcTemp__5[70] = S"71";
__mcTemp__5[71] = S"72";
__mcTemp__5[72] = S"73";
__mcTemp__5[73] = S"74";
__mcTemp__5[74] = S"75";
__mcTemp__5[75] = S"76";
__mcTemp__5[76] = S"77";
__mcTemp__5[77] = S"78";
__mcTemp__5[78] = S"79";
__mcTemp__5[79] = S"80";
__mcTemp__5[80] = S"81";
__mcTemp__5[81] = S"82";
__mcTemp__5[82] = S"83";
__mcTemp__5[83] = S"84";
__mcTemp__5[84] = S"85";
__mcTemp__5[85] = S"86";
__mcTemp__5[86] = S"87";
__mcTemp__5[87] = S"88";
__mcTemp__5[88] = S"89";
__mcTemp__5[89] = S"90";
__mcTemp__5[90] = S"91";
__mcTemp__5[91] = S"92";
__mcTemp__5[92] = S"93";
__mcTemp__5[93] = S"94";
__mcTemp__5[94] = S"95";
__mcTemp__5[95] = S"96";
__mcTemp__5[96] = S"97";
__mcTemp__5[97] = S"98";
__mcTemp__5[98] = S"99";
this->comboBox3->Items->AddRange(__mcTemp__5);
this->comboBox3->Location = System::Drawing::Point(344, 48);
this->comboBox3->Name = S"comboBox3";
this->comboBox3->Size = System::Drawing::Size(144, 20);
this->comboBox3->TabIndex = 58;
//
// dataGrid2
//
this->dataGrid2->DataMember = S"";
this->dataGrid2->HeaderForeColor = System::Drawing::SystemColors::ControlText;
this->dataGrid2->Location = System::Drawing::Point(272, 280);
this->dataGrid2->Name = S"dataGrid2";
this->dataGrid2->TabIndex = 59;
//
// tianjiashanchuyonghu
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(600, 430);
this->Controls->Add(this->comboBox3);
this->Controls->Add(this->comboBox2);
this->Controls->Add(this->dataGrid1);
this->Controls->Add(this->comboBox1);
this->Controls->Add(this->textBox6);
this->Controls->Add(this->label7);
this->Controls->Add(this->textBox5);
this->Controls->Add(this->label6);
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->label2);
this->Controls->Add(this->button1);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->label1);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->dataGrid2);
this->Name = S"tianjiashanchuyonghu";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = S"添加/删除用户";
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dataGrid1))->EndInit();
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dataGrid2))->EndInit();
this->ResumeLayout(false);
}
private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
{String *NID=this->textBox1->Text->Trim();
oleDbSelectCommand1->CommandText=String::Concat(S"select NID as 用户ID,NAME as 姓名,AGE as 年龄,SEX as 性别,COMPANY as 部门,STATUS as 身份,ADDS as 地址 from 用户表 where ",S"NID='",NID,S"'" );
oleDbConnection1->Open();
oleDbSelectCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table1=new DataTable();
oleDbDataAdapter1->Fill(table1);
this->dataGrid1->DataSource=table1;
}
private: System::Void button2_Click(System::Object * sender, System::EventArgs * e)
{ String *NID=this->textBox1->Text->Trim();
if(this->textBox1->Text->CompareTo("")==0) MessageBox::Show("用户ID不能为空");
else{ oleDbSelectCommand1->CommandText=String::Concat(S"select NID as 用户ID,NAME as 姓名,AGE as 年龄,SEX as 性别,COMPANY as 部门,STATUS as 身份,ADDS as 地址 from 用户表 where ",S"NID='",NID,S"'" );
oleDbConnection1->Open();
oleDbSelectCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table2=new DataTable();
oleDbDataAdapter1->Fill(table2);
this->dataGrid1->DataSource=table2;
int nindex=dataGrid1->CurrentRowIndex;
DataTable *table3=__try_cast<DataTable*>(dataGrid1->DataSource);
if(nindex==0) MessageBox::Show("用户ID已注册过");
else{ int i=0;
if(this->textBox2->Text->CompareTo("")==0) {MessageBox::Show("姓名不能为空");
i++; }
if(this->textBox2->Text->Length>20) {MessageBox::Show("姓名太长");
i++;}
if(this->comboBox3->Text->CompareTo("")==0) {MessageBox::Show("年龄不能为空");
i++;}
if(this->comboBox3->Text->Length>4) {MessageBox::Show("年龄太长");
i++; }
if(this->comboBox2->Text->CompareTo("")==0) {MessageBox::Show("性别不能为空");
i++;}
if(this->comboBox2->Text->Length>4){ MessageBox::Show("性别太长");
i++;}
if(this->comboBox1->Text->CompareTo("")==0) {MessageBox::Show("部门不能为空");
i++;}
if(this->comboBox1->Text->Length>20){ MessageBox::Show("部门太长");
i++;}
if(this->textBox5->Text->CompareTo("")==0) {MessageBox::Show("身份证不能为空");
i++;}
if(this->textBox5->Text->Length>20) {MessageBox::Show("身份证太长");
i++;}
if(this->textBox6->Text->CompareTo("")==0) {MessageBox::Show("地址不能为空");
i++;}
if(this->textBox6->Text->Length>50){ MessageBox::Show("地址太长");
i++;}
if(i==0){
String *NAME=this->textBox2->Text->Trim();
String *AGE=this->comboBox3->Text->Trim();
String *SEX=this->comboBox2->Text->Trim();
String *COMPANY=this->comboBox1->Text->Trim();
String *PASSWORD=0;
String *STATUS=this->textBox5->Text->Trim();
String *ADDS=this->textBox6->Text->Trim();
oleDbInsertCommand1->CommandText=String::Concat(S"insert into 用户表 (", S"NID,NAME,AGE,SEX,COMPANY,PASSWORD,STATUS,ADDS) values ('", NID, S"','",NAME,S"','",AGE,S"','",SEX,S"','",COMPANY,S"','",PASSWORD,S"','",STATUS,S"','",ADDS,S"')" );
oleDbSelectCommand1->CommandText=String::Concat(S"select NID as 用户ID,NAME as 姓名,AGE as 年龄,SEX as 性别,COMPANY as 部门,STATUS as 身份,ADDS as 地址 from 用户表 where ",S"NID='",NID,S"'" );
oleDbConnection1->Open();
oleDbInsertCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table1=new DataTable();
oleDbDataAdapter1->Fill(table1);
this->dataGrid1->DataSource=table1;
}
}
}
}
private: System::Void button3_Click(System::Object * sender, System::EventArgs * e)
{ String *NID=this->textBox1->Text->Trim();
oleDbDeleteCommand1->CommandText=String::Concat(S"delete from 用户表 where ",S"NID='",NID,S"'");
oleDbConnection1->Open();
oleDbDeleteCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table1=new DataTable();
oleDbDataAdapter1->Fill(table1);
this->dataGrid1->DataSource=table1;
}
private: System::Void dataGrid1_CurrentCellChanged(System::Object * sender, System::EventArgs * e)
{int nindex=dataGrid1->CurrentRowIndex;
if(nindex<0)
{this->textBox1->Text=S"";
this->textBox2->Text=S"";
this->comboBox3->Text=S"";
this->comboBox2->Text=S"";
this->comboBox1->Text=S"";
this->textBox5->Text=S"";
this->textBox6->Text=S"";
return;
}
DataTable *table2=__try_cast<DataTable*>(dataGrid1->DataSource);
DataRow * row=table2->Rows->Item[nindex];
this->textBox1->Text=row->Item[0]->ToString();
this->textBox2->Text=row->Item[1]->ToString();
this->comboBox3->Text=row->Item[2]->ToString();
this->comboBox2->Text=row->Item[3]->ToString();
this->comboBox1->Text=row->Item[4]->ToString();
this->textBox5->Text=row->Item[5]->ToString();
this->textBox6->Text=row->Item[6]->ToString();
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -