📄 frmregister.cs
字号:
// comboItem3
//
this.comboItem3.Text = "小新";
//
// comboItem4
//
this.comboItem4.Text = "地球";
//
// comboItem5
//
this.comboItem5.Text = "阿杰";
//
// comboItem6
//
this.comboItem6.Text = "阿比";
//
// comboItem7
//
this.comboItem7.Text = "100";
//
// comboItem8
//
this.comboItem8.Text = "120";
//
// comboItem9
//
this.comboItem9.Text = "150";
//
// comboItem10
//
this.comboItem10.Text = "200";
//
// comboItem11
//
this.comboItem11.Text = "300";
//
// comboItem12
//
this.comboItem12.Text = "500";
//
// comboItem13
//
this.comboItem13.Text = "1";
//
// comboItem14
//
this.comboItem14.Text = "2";
//
// comboItem15
//
this.comboItem15.Text = "3";
//
// comboItem16
//
this.comboItem16.Text = "4";
//
// comboItem17
//
this.comboItem17.Text = "5";
//
// comboItem22
//
this.comboItem22.Text = "一室一厅";
//
// comboItem23
//
this.comboItem23.Text = "二室一厅";
//
// comboItem24
//
this.comboItem24.Text = "三室二厅";
//
// comboItem25
//
this.comboItem25.Text = "四室一厅";
//
// comboItem26
//
this.comboItem26.Text = "四室二厅";
//
// comboItem27
//
this.comboItem27.Text = "五室一厅";
//
// comboItem28
//
this.comboItem28.Text = "五室二厅";
//
// comboItem29
//
this.comboItem29.Text = "二室二厅";
//
// comboItem18
//
this.comboItem18.Text = "适中";
//
// comboItem19
//
this.comboItem19.Text = "较高";
//
// comboItem20
//
this.comboItem20.Text = "太高";
//
// comboItem21
//
this.comboItem21.Text = "分期";
//
// comboItem30
//
this.comboItem30.Text = "一次性";
//
// comboItem31
//
this.comboItem31.Text = "未售";
//
// comboItem32
//
this.comboItem32.Text = "预定";
//
// comboItem33
//
this.comboItem33.Text = "售出";
//
// comboItem34
//
this.comboItem34.Text = "电视";
//
// comboItem35
//
this.comboItem35.Text = "报纸";
//
// comboItem36
//
this.comboItem36.Text = "市区广告";
//
// comboItem37
//
this.comboItem37.Text = "熟人介绍";
//
// comboItem38
//
this.comboItem38.Text = "网络";
//
// comboItem39
//
this.comboItem39.Text = "宣传单";
//
// comboItem40
//
this.comboItem40.Text = "杂志";
//
// labelX3
//
this.labelX3.Location = new System.Drawing.Point(16, 152);
this.labelX3.Name = "labelX3";
this.labelX3.Size = new System.Drawing.Size(72, 24);
this.labelX3.TabIndex = 26;
this.labelX3.Text = "<b>客户地址:</b>";
//
// labelX4
//
this.labelX4.Location = new System.Drawing.Point(432, 72);
this.labelX4.Name = "labelX4";
this.labelX4.Size = new System.Drawing.Size(176, 23);
this.labelX4.TabIndex = 27;
this.labelX4.Text = "<b>备注: (可以不填写)</b>";
//
// txtRe
//
this.txtRe.AutoSize = false;
//
// txtRe.Border
//
this.txtRe.Border.Class = "TextBoxBorder";
this.txtRe.Location = new System.Drawing.Point(432, 104);
this.txtRe.Name = "txtRe";
this.txtRe.Size = new System.Drawing.Size(216, 72);
this.txtRe.TabIndex = 28;
//
// comboItem41
//
this.comboItem41.Text = "小庄";
//
// comboItem42
//
this.comboItem42.Text = "小山";
//
// frmRegister
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(672, 469);
this.Controls.Add(this.txtRe);
this.Controls.Add(this.labelX4);
this.Controls.Add(this.labelX3);
this.Controls.Add(this.cboEp);
this.Controls.Add(this.labelX6);
this.Controls.Add(this.txtEmail);
this.Controls.Add(this.labelX5);
this.Controls.Add(this.txtaddress);
this.Controls.Add(this.txtPhone);
this.Controls.Add(this.labelX2);
this.Controls.Add(this.txtClientname);
this.Controls.Add(this.labelX1);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.toolBar1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "frmRegister";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "来访客户登记";
this.Load += new System.EventHandler(this.frmRegister_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
switch(this.toolBar1.Buttons.IndexOf(e.Button))
{
case 0:this.txtClientname.Focus();this.txtaddress.Text="";
this.txtEmail.Text="";this.txtPhone.Text="";
this.txtClientname.Text="";this.toolBar1.Buttons[1].Enabled=true;
this.clientID=0;//让处于添加信息状态
break;
case 1:
//获取当前信息
string ClientName=this.txtClientname.Text;
string ClientPhone=this.txtPhone.Text;
string ClientMail=this.txtEmail.Text;
string emp=this.cboEp.Text;
string address=this.txtaddress.Text;
string re=this.txtRe.Text;
if(clientID==0)
{
//判断是否为空
if(ClientName.Length<1 || ClientPhone.Length<1 || ClientMail.Length<1 ||
emp.Length<1 || address.Length<1)
{
MessageBox.Show("请把信息填写完整!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
else
{
try
{
this.clientBE=new Client();
this.clientBS=new ClientBS();
this.clientBE.ClientName=ClientName;
this.clientBE.ClientTelphone=ClientPhone;
this.clientBE.ClientEmail=ClientMail;
this.clientBE.getEmp=emp;
this.clientBE.ClientAdress=address;
this.clientBE.Reamark=re;
this.clientBS.client=this.clientBE;
this.clientBS.insert();
MessageBox.Show("添加信息成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
//清空数据
this.txtaddress.Text="";
this.txtEmail.Text="";
this.txtPhone.Text="";
this.txtClientname.Text="";
this.toolBar1.Buttons[1].Enabled=false;
this.clientID=0;
//重新加载
frmRegister_Load(sender,e);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
}
}
else
{
try
{
this.clientBE=new Client();
this.clientBS=new ClientBS();
this.clientBE.ClientName=ClientName;
this.clientBE.ClientTelphone=ClientPhone;
this.clientBE.ClientEmail=ClientMail;
this.clientBE.getEmp=emp;
this.clientBE.ClientAdress=address;
this.clientBE.Reamark=re;
this.clientBE.ClientID=this.clientID;
this.clientBS.client=this.clientBE;
this.clientBS.update();
MessageBox.Show("修改信息成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
//清空数据
this.txtaddress.Text="";
this.txtEmail.Text="";
this.txtPhone.Text="";
this.txtClientname.Text="";
this.toolBar1.Buttons[1].Enabled=false;
//重新加载
frmRegister_Load(sender,e);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
}
break;//添加
case 2:
if(this.txtClientname.Text !="")
{
this.txtClientname.Focus();this.txtClientname.SelectAll();
this.toolBar1.Buttons[1].Enabled=true;
}
else
{
MessageBox.Show("请单击一条记录");
return;
}
break;
case 3:break;//打印
case 4:this.Close();break;
}
}
private void frmRegister_Load(object sender, System.EventArgs e)
{
this.toolBar1.Buttons[1].Enabled=false;
this.clientBS=new ClientBS();
ds=this.clientBS.select();
this.dataGrid1.DataSource=ds;
this.dataGrid1.DataMember="Client";
}
private void dataGrid1_Click(object sender, System.EventArgs e)
{
//单击一条记录
string name=Convert.ToString(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][0]);
string phone=Convert.ToString(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][1]);
string email=Convert.ToString(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][2]);
string empname=Convert.ToString(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][3]);
string address=Convert.ToString(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][4]);
string re=Convert.ToString(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][5]);
this.clientID=Convert.ToInt32(this.ds.Tables[0].Rows[this.dataGrid1.CurrentRowIndex][6]);
this.txtClientname.Text=name;
this.txtEmail.Text=email;
this.txtPhone.Text=phone;
this.txtaddress.Text=address;
this.txtRe.Text=re;
this.cboEp.Text=empname;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -