📄 customersmanage.cs
字号:
//
this.txtRelation.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtRelation.Location = new System.Drawing.Point(472, 96);
this.txtRelation.Name = "txtRelation";
this.txtRelation.Size = new System.Drawing.Size(232, 21);
this.txtRelation.TabIndex = 29;
this.txtRelation.Text = "";
//
// txtFax
//
this.txtFax.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtFax.Location = new System.Drawing.Point(112, 72);
this.txtFax.Name = "txtFax";
this.txtFax.Size = new System.Drawing.Size(232, 21);
this.txtFax.TabIndex = 25;
this.txtFax.Text = "";
//
// txtname
//
this.txtname.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtname.Location = new System.Drawing.Point(112, 24);
this.txtname.Name = "txtname";
this.txtname.Size = new System.Drawing.Size(232, 21);
this.txtname.TabIndex = 26;
this.txtname.Text = "";
//
// cbSex
//
this.cbSex.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbSex.Items.AddRange(new object[] {
"男",
"女"});
this.cbSex.Location = new System.Drawing.Point(472, 24);
this.cbSex.Name = "cbSex";
this.cbSex.Size = new System.Drawing.Size(232, 20);
this.cbSex.TabIndex = 38;
//
// btReset
//
this.btReset.BackColor = System.Drawing.SystemColors.Menu;
this.btReset.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btReset.Font = new System.Drawing.Font("宋体", 9F);
this.btReset.Location = new System.Drawing.Point(736, 120);
this.btReset.Name = "btReset";
this.btReset.Size = new System.Drawing.Size(75, 24);
this.btReset.TabIndex = 35;
this.btReset.Text = "清空";
this.btReset.Click +=new EventHandler(btReset_Click);
//
// txtCtelnumber
//
this.txtCtelnumber.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtCtelnumber.Location = new System.Drawing.Point(112, 48);
this.txtCtelnumber.Name = "txtCtelnumber";
this.txtCtelnumber.Size = new System.Drawing.Size(232, 21);
this.txtCtelnumber.TabIndex = 33;
this.txtCtelnumber.Text = "";
//
// label4
//
this.label4.BackColor = System.Drawing.SystemColors.Menu;
this.label4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label4.Location = new System.Drawing.Point(392, 48);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(72, 23);
this.label4.TabIndex = 22;
this.label4.Text = "客户类别";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label2
//
this.label2.BackColor = System.Drawing.SystemColors.Menu;
this.label2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.Location = new System.Drawing.Point(32, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 23);
this.label2.TabIndex = 19;
this.label2.Text = "客户姓名";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// btAdd
//
this.btAdd.BackColor = System.Drawing.SystemColors.Menu;
this.btAdd.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btAdd.Font = new System.Drawing.Font("宋体", 9F);
this.btAdd.Location = new System.Drawing.Point(736, 24);
this.btAdd.Name = "btAdd";
this.btAdd.Size = new System.Drawing.Size(75, 24);
this.btAdd.TabIndex = 28;
this.btAdd.Text = "添加";
this.btAdd.Click +=new EventHandler(btAdd_Click);
//
// label6
//
this.label6.BackColor = System.Drawing.SystemColors.Menu;
this.label6.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label6.Location = new System.Drawing.Point(32, 72);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(72, 23);
this.label6.TabIndex = 24;
this.label6.Text = "传真号码";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label5
//
this.label5.BackColor = System.Drawing.SystemColors.Menu;
this.label5.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label5.Location = new System.Drawing.Point(392, 72);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(72, 23);
this.label5.TabIndex = 23;
this.label5.Text = "E-mail";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// btSave
//
this.btSave.BackColor = System.Drawing.SystemColors.Menu;
this.btSave.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btSave.Font = new System.Drawing.Font("宋体", 9F);
this.btSave.Location = new System.Drawing.Point(736, 56);
this.btSave.Name = "btSave";
this.btSave.Size = new System.Drawing.Size(75, 24);
this.btSave.TabIndex = 31;
this.btSave.Tag = "修改";
this.btSave.Text = "修改";
this.btSave.Click +=new EventHandler(btSave_Click);
//
// tabControl1
//
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(0, 0);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(860, 176);
this.tabControl1.TabIndex = 39;
//
// CustomersManage
//
this.AutoScroll = true;
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Name = "CustomersManage";
this.Size = new System.Drawing.Size(860, 493);
this.Load += new System.EventHandler(this.CustomersManage_Load);
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgCustomer)).EndInit();
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void btAdd_Click(object sender, System.EventArgs e)
{
try
{
insertData();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void insertData()
{
if(!this.validate())
{
return;
}
CustomerInfo cinfo=new CustomerInfo();
cinfo=setData("增加");
CustomerBLL cbll=new CustomerBLL();
if(cbll.addCustomer(cinfo).ToString()!=null)
{
MessageBox.Show(this,"添加成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
getDataBind();
ClearData();
}
else
{
MessageBox.Show(this,"添加失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
private CustomerInfo setData(string tag)
{
CustomerInfo cinfo=new CustomerInfo();
if(tag=="修改")
{
cinfo.id=Convert.ToInt32(this.dgCustomer[this.dgCustomer.CurrentCell.RowNumber,1]);
}
cinfo.cname=this.txtname.Text;
cinfo.csex=this.cbSex.Text.ToString();
cinfo.ctelnumber=this.txtCtelnumber.Text.ToString();
cinfo.ccontact=this.txtRelation.Text;
cinfo.ctype=Convert.ToInt32(this.cbCType.SelectedValue);
cinfo.cfax=this.txtFax.Text;
cinfo.cemail=this.txtEmail.Text;
cinfo.caddress=this.txtAddr.Text;
cinfo.ccomment=this.txtMemo.Text;
return cinfo;
}
private void getDataBind()
{
this.checkBox1.Checked=false;
dscustomers=new DataSet();
CustomerBLL cbll=new CustomerBLL();
CustomerInfo cinfo=new CustomerInfo();
dscustomers=cbll.queryCustomer_DataSet(cinfo,"customers");
System.Type myDataType;
myDataType = System.Type.GetType("System.Boolean");
System.Data.DataColumn myColumn = new System.Data.DataColumn("check");
// Set various properties.
myColumn.AutoIncrement = false;
myColumn.ReadOnly = false;
myColumn.ColumnMapping = System.Data.MappingType.Attribute;
myColumn.Caption = "check";
myColumn.DefaultValue = "false";
myColumn.DataType = myDataType;
dscustomers.Tables["customers"].Columns.Add(myColumn);
DataView dv=new DataView();
dv=dscustomers.Tables["customers"].DefaultView;
dv.AllowNew=false;
this.dgCustomer.DataSource=dv;//dscustomers.Tables["customers"].DefaultView;
this.dgCustomer.TableStyles.Clear();
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = dscustomers.Tables["customers"].TableName;
DataGridColumnStyle gsc = new DataGridBoolColumn();
gsc.MappingName = "check";
gsc.HeaderText = "选择";
gsc.Width=40;
ts.GridColumnStyles.Add(gsc);
DataGridColumnStyle gs0 = new DataGridTextBoxColumn();
gs0.MappingName = "id";
gs0.HeaderText = "编号";
gs0.Width=0;
gs0.ReadOnly=true;
ts.GridColumnStyles.Add(gs0);
DataGridColumnStyle gs1 = new DataGridTextBoxColumn();
gs1.MappingName = "cname";
gs1.HeaderText = "姓名";
gs1.NullText = "";
gs1.Width=60;
gs1.ReadOnly=true;
gs1.Alignment = HorizontalAlignment.Left;
ts.GridColumnStyles.Add(gs1);
DataGridColumnStyle gs2 = new DataGridTextBoxColumn();
gs2.MappingName = "csex";
gs2.HeaderText = "性别";
gs2.NullText = "";
gs2.Width=40;
gs2.ReadOnly=true;
gs2.Alignment = HorizontalAlignment.Left;
ts.GridColumnStyles.Add(gs2);
DataGridColumnStyle gsc2 = new DataGridTextBoxColumn();
gsc2.MappingName = "telnumber";
gsc2.HeaderText = "客户来电";
gsc2.NullText = "";
gs2.Width=100;
gsc2.ReadOnly=true;
gsc2.Alignment = HorizontalAlignment.Right;
ts.GridColumnStyles.Add(gsc2);
DataGridColumnStyle gst2 = new DataGridTextBoxColumn();
gst2.MappingName = "ctype";
gst2.HeaderText = "类别";
gst2.NullText = "";
gst2.Width=40;
gst2.ReadOnly=true;
gst2.Alignment = HorizontalAlignment.Left;
ts.GridColumnStyles.Add(gst2);
DataGridColumnStyle gs3 = new DataGridTextBoxColumn();
gs3.MappingName = "cemail";
gs3.HeaderText = "email";
gs3.NullText = "";
gs3.Width=200;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -