//确定按钮,新增和修改 private void btnOk_Click(object sender, EventArgs e) { MemmberInfo mem = new MemmberInfo(); if (IsCheck()) { mem.MemAddress = txtAddress.Text; mem.MemBirthdaty = Convert.ToDateTime(txtBirs.Text); mem.MemDiscount = Convert.ToDecimal(txtMemDiscount.Text); mem.MemEndServerTime = dtEndServerTime.Value; mem.MemGender = CheckGender(); mem.MemIntegral = Convert.ToInt32(txtMemIntegral.Text); mem.MemMobilePhone = txtMemPhone.Text; mem.MemMoney = Convert.ToDecimal(txtmemMoney.Text); mem.MemName = txtMemName.Text; mem.MemNum = txtMemNum.Text; mem.MemType = Convert.ToInt32(cmbMemType.SelectedIndex); } MemmberInfoBLL bll = new MemmberInfoBLL(); //新增还是修改 if (this.Tp == 1)//新增 { mem.DelFlag = 0; mem.SubTime = System.DateTime.Now; //if (bll.SaveMemmber(mem,this.Tp)) //{ // MessageBox.Show("新增成功"); // this.Close(); //} //else //{ // MessageBox.Show("新增失败"); //} } else if (this.Tp == 2) //修改 { mem.MemmberId = Convert.ToInt32(labId.Text); //if (bll.SaveMemmber(mem, this.Tp)) //{ // MessageBox.Show("修改成功"); // this.Close(); //} //else //{ // MessageBox.Show("修改失败"); //} } string st = bll.SaveMemmber(mem, this.Tp) ? "操作成功" : "操作失败"; MessageBox.Show(st); this.Close(); }
private void btnOk_Click(object sender, EventArgs e) { //获取会员信息 //不为空 MemmberInfo mem = new MemmberInfo(); if (IsCheck()) { mem.MemAddress = txtAddress.Text; mem.MemBirthdaty = Convert.ToDateTime(txtBirs.Text); //生日最好用控件 mem.MemDiscount = Convert.ToDecimal(txtMemDiscount.Text); //折扣 mem.MemEndServerTime = dtEndServerTime.Value; mem.MemGender = IsGender(); mem.MemIntegral = Convert.ToInt32(txtMemIntegral.Text); mem.MemMobilePhone = txtMemPhone.Text; mem.MemMoney = Convert.ToDecimal(txtmemMoney.Text); mem.MemName = txtMemName.Text; mem.MemNum = txtMemNum.Text; mem.MemType = Convert.ToInt32(cmbMemType.SelectedValue); } else { //MessageBox.Show("不能为空"); return; //没的话,直接确定会生成空值,报错 } MemmberInfoBLL bll = new MemmberInfoBLL(); //新增还是修改 if (this.Tp == 1) { mem.DelFlag = 0; mem.SubTime = System.DateTime.Now; } else if (this.Tp == 2) { mem.MemmberId = Convert.ToInt32(labId.Text); } string st = bll.SaveMemmber(mem, this.Tp) ? "操作成功" : "操作失败"; MessageBox.Show(st); this.Close(); }