?? hyyw.cs
字號:
//
// label5
//
this.label5.Location = new System.Drawing.Point(408, 40);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(64, 16);
this.label5.TabIndex = 4;
this.label5.Text = "會員性別";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(272, 32);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(112, 21);
this.textBox4.TabIndex = 3;
this.textBox4.Text = "";
this.textBox4.TextChanged += new System.EventHandler(this.textBox4_TextChanged);
this.textBox4.Leave += new System.EventHandler(this.textBox4_Leave);
//
// label4
//
this.label4.Location = new System.Drawing.Point(208, 40);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(56, 16);
this.label4.TabIndex = 2;
this.label4.Text = "會員姓名";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(80, 32);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(112, 21);
this.textBox3.TabIndex = 1;
this.textBox3.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(16, 40);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 16);
this.label3.TabIndex = 0;
this.label3.Text = "會員級別";
//
// groupBox4
//
this.groupBox4.Controls.Add(this.button6);
this.groupBox4.Controls.Add(this.button1);
this.groupBox4.Controls.Add(this.button2);
this.groupBox4.Controls.Add(this.button3);
this.groupBox4.Controls.Add(this.button4);
this.groupBox4.Location = new System.Drawing.Point(688, 344);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(80, 248);
this.groupBox4.TabIndex = 3;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "操作";
//
// button1
//
this.button1.Location = new System.Drawing.Point(8, 32);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(64, 24);
this.button1.TabIndex = 5;
this.button1.Text = "添加";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Enabled = false;
this.button2.Location = new System.Drawing.Point(8, 72);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(64, 24);
this.button2.TabIndex = 6;
this.button2.Text = "修改";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Enabled = false;
this.button3.Location = new System.Drawing.Point(8, 112);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(64, 24);
this.button3.TabIndex = 7;
this.button3.Text = "刪除";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(8, 192);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(64, 24);
this.button4.TabIndex = 8;
this.button4.Text = "關閉";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button6
//
this.button6.Enabled = false;
this.button6.Location = new System.Drawing.Point(8, 152);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(64, 24);
this.button6.TabIndex = 9;
this.button6.Text = "刷新";
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// hyyw
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(784, 597);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.MaximizeBox = false;
this.Name = "hyyw";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "會員管理";
this.TopMost = true;
this.Load += new System.EventHandler(this.hyyw_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void hyyw_Load(object sender, System.EventArgs e)
{
setlv();//顯示lv的值
}
private void setlv(){
this.listView1.Items.Clear();
cs.hysql hysq=new bggl.cs.hysql();
DataSet objset=hysq.selectexe();
foreach(DataRow dr in objset.Tables[0].Rows)
{
ListViewItem lst=new ListViewItem();
lst.SubItems.Clear();
lst.SubItems[0].Text=dr[0].ToString();
lst.SubItems.Add(dr[1].ToString());
lst.SubItems.Add(dr[2].ToString());
lst.SubItems.Add(dr[3].ToString());
lst.SubItems.Add(dr[4].ToString());
lst.SubItems.Add(dr[5].ToString());
lst.SubItems.Add(dr[6].ToString());
lst.SubItems.Add(dr[7].ToString());
lst.SubItems.Add(dr[8].ToString());
lst.SubItems.Add(dr[9].ToString());
this.listView1.Items.Add(lst);
}
}
private void button1_Click(object sender, System.EventArgs e)
{
if(this.textBox4.Text.Trim()!=""&&this.textBox7.Text.Trim()!=""&&this.textBox8.Text.Trim()!="")
{
cs.hysql hysq=new bggl.cs.hysql();
bool pd=hysq.insertexe(this.textBox3.Text,this.textBox4.Text,this.comboBox1.Text,this.textBox5.Text,this.textBox6.Text,this.textBox7.Text,this.textBox8.Text,this.dateTimePicker1.Text,this.textBox9.Text);
if(pd==true)
{
MessageBox.Show("添加成功");
qk();
setlv();
}
else
{
MessageBox.Show("添加失敗,請重新填寫");
}
}
else{
MessageBox.Show("資料不完整,請填寫完整!");
}
}
private void button5_Click(object sender, System.EventArgs e)
{
this.listView1.Items.Clear();
cs.hysql hysq=new bggl.cs.hysql();
DataSet objset=hysq.selectexe(this.textBox1.Text,this.textBox2.Text);
foreach(DataRow dr in objset.Tables[0].Rows)
{
ListViewItem lst=new ListViewItem();
lst.SubItems.Clear();
lst.SubItems[0].Text=dr[0].ToString();
lst.SubItems.Add(dr[1].ToString());
lst.SubItems.Add(dr[2].ToString());
lst.SubItems.Add(dr[3].ToString());
lst.SubItems.Add(dr[4].ToString());
lst.SubItems.Add(dr[5].ToString());
lst.SubItems.Add(dr[6].ToString());
lst.SubItems.Add(dr[7].ToString());
lst.SubItems.Add(dr[8].ToString());
lst.SubItems.Add(dr[9].ToString());
this.listView1.Items.Add(lst);
}
}
private void textBox4_Leave(object sender, System.EventArgs e)
{
cs.hysql hysq=new bggl.cs.hysql();
DataSet objset=hysq.selectexe();
int z=0;
foreach(DataRow dr in objset.Tables[0].Rows)
{
if(dr["hname"].ToString().Trim()==this.textBox4.Text.Trim())
{
z=z+1;
}
}
if(z!=0)
{
DialogResult panduan=new DialogResult();
panduan=MessageBox.Show("次姓名的會員已經有"+z+"個了,確定還是添加嗎?","確認",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if(panduan!=DialogResult.Yes)//
{
this.textBox4.Text="";
}
}
}
private void listView1_Click(object sender, System.EventArgs e)
{
zhi=this.listView1.SelectedItems[0].SubItems[0].Text;
if(zhi.Trim()!=""){
this.button2.Enabled=true;
this.button3.Enabled=true;
this.button1.Enabled=false;
cs.hysql hysq=new bggl.cs.hysql();
DataSet objset=hysq.selectexe();
foreach(DataRow dr in objset.Tables[0].Rows)
{
if(zhi.Trim()==dr["hid"].ToString().Trim()){
this.textBox3.Text=dr[1].ToString().Trim();
this.textBox4.Text=dr[2].ToString().Trim();
this.comboBox1.Text=dr[3].ToString().Trim();
this.textBox5.Text=dr[4].ToString().Trim();
this.textBox6.Text=dr[5].ToString().Trim();
this.textBox7.Text=dr[6].ToString().Trim();
this.textBox8.Text=dr[7].ToString().Trim();
this.dateTimePicker1.Text=dr[8].ToString().Trim();
this.textBox9.Text=dr[9].ToString().Trim();
}
}
}
}
private void qk(){
this.textBox1.Text="";
this.textBox2.Text="";
this.textBox3.Text="";
this.textBox4.Text="";
this.textBox5.Text="";
this.textBox6.Text="";
this.textBox7.Text="";
this.textBox8.Text="";
this.textBox9.Text="";
this.comboBox1.Text="";
}
private void button2_Click(object sender, System.EventArgs e)
{
if(zhi.ToString().Trim()!="")
{
if(this.textBox4.Text.Trim()!=""&&this.textBox7.Text.Trim()!=""&&this.textBox8.Text.Trim()!="")
{
this.button1.Enabled=true;
this.button2.Enabled=false;
this.button3.Enabled=false;
cs.hysql hysq=new bggl.cs.hysql();
bool pd=hysq.updateexe(zhi.Trim(),this.textBox3.Text,this.textBox4.Text,this.comboBox1.Text,this.textBox5.Text,this.textBox6.Text,this.textBox7.Text,this.textBox8.Text,this.dateTimePicker1.Text,this.textBox9.Text);
if(pd==true)
{
MessageBox.Show("修改成功");
zhi="";
qk();
setlv();
}
else
{
MessageBox.Show("修改失敗,請重新修改");
zhi="";
qk();
setlv();
}
}
}
}
private void button3_Click(object sender, System.EventArgs e)
{
if(zhi.ToString().Trim()!="")
{
DialogResult panduan=new DialogResult();
panduan=MessageBox.Show("您確定刪除當前記錄嗎?","確認",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if(panduan==DialogResult.Yes)
{
this.button1.Enabled=true;
this.button2.Enabled=false;
this.button3.Enabled=false;
cs.hysql hysq=new bggl.cs.hysql();
bool pd=hysq.delexe(zhi.ToString().Trim());
if(pd==true)
{
MessageBox.Show("刪除成功");
zhi="";
qk();
setlv();
}
else
{
MessageBox.Show("刪除失敗,請重新操作!");
zhi="";
qk();
setlv();
}
}
}
else
{
MessageBox.Show("您沒有選擇你要刪除的記錄!");
}
}
private void textBox7_TextChanged(object sender, System.EventArgs e)
{
gong.zhipd zhi=new bggl.gong.zhipd();
if(zhi.intjc(this.textBox7.Text.Trim())!=true)
{
MessageBox.Show("只能輸入數字!");
this.textBox7.Text="";
}
}
private void textBox8_TextChanged(object sender, System.EventArgs e)
{
}
private void textBox5_TextChanged(object sender, System.EventArgs e)
{
gong.zhipd zhi=new bggl.gong.zhipd();
if(zhi.zhi(this.textBox5.Text.Trim())!=true)
{
MessageBox.Show("價格只能輸入數字!");
this.textBox5.Text="";
}
}
private void textBox2_TextChanged(object sender, System.EventArgs e)
{
gong.zhipd zhi=new bggl.gong.zhipd();
if(zhi.zhi(this.textBox2.Text.Trim())!=true)
{
MessageBox.Show("價格只能輸入數字!");
this.textBox2.Text="";
}
}
private void textBox6_TextChanged(object sender, System.EventArgs e)
{
gong.zhipd zhi=new bggl.gong.zhipd();
if(zhi.intjc(this.textBox6.Text.Trim())!=true)
{
MessageBox.Show("只能輸入數字!");
this.textBox6.Text="";
}
}
private void button4_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void button6_Click(object sender, System.EventArgs e)
{
this.button1.Enabled=true;
this.button2.Enabled=false;
this.button3.Enabled=false;
zhi="";
qk();
setlv();
}
private void textBox8_Leave(object sender, System.EventArgs e)
{
gong.zhipd zhi=new bggl.gong.zhipd();
if(zhi.zhi(this.textBox8.Text.Trim())!=true)
{
MessageBox.Show("價格只能輸入數字!");
this.textBox8.Text="";
}
}
private void textBox4_TextChanged(object sender, System.EventArgs e)
{
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -