private void Button_Add_Click(object sender, EventArgs e) { if (this.textBox_GiftCode.Text == "" || this.textBox_GiftName.Text == "" || this.TextBox_Number.Text == "" || this.TextBox_Point.Text == "") { MessageBox.Show("请输入完整信息!"); return; } VipSoft.Model.Gift model = new Model.Gift(); model.GiftCode = this.textBox_GiftCode.Text; model.Name = this.textBox_GiftName.Text; model.Photo = this.textBox_Photo.Text; model.Point = int.Parse(this.TextBox_Point.Text.Trim()); model.Number = int.Parse(this.TextBox_Number.Text.Trim()); model.ExchangeNumber = 0; if (this.label_GiftID.Text == "") { if (eg.Exists(this.textBox_GiftCode.Text.Trim())) { MessageBox.Show("礼品编号重复,请重新输入!"); return; } if (eg.Add(model)>0) { // 记录日志 new VipSoft.BLL.SysLog().Add(new VipSoft.Model.SysLog(PublicState.Master, "礼品兑换", "新增礼品成功,礼品名称:" + this.textBox_GiftName.Text, DateTime.Now)); // 提醒 MessageBox.Show("礼品增加成功!"); this.textBox_GiftCode.Text = ""; this.textBox_GiftName.Text = ""; this.TextBox_Number.Text = ""; this.textBox_Photo.Text = ""; this.TextBox_Point.Text = ""; BindList(); this.myTabControl1.SelectedIndex = 0; } else { MessageBox.Show("新增失败,请重试!"); } } else { model.ID = int.Parse(this.label_GiftID.Text); if (eg.Update(model)) { // 记录日志 new VipSoft.BLL.SysLog().Add(new VipSoft.Model.SysLog(PublicState.Master, "礼品兑换", "修改礼品成功,礼品名称:" + this.textBox_GiftName.Text, DateTime.Now)); // 提醒 MessageBox.Show("礼品修改成功!"); this.textBox_GiftCode.Text = ""; this.textBox_GiftName.Text = ""; this.TextBox_Number.Text = ""; this.textBox_Photo.Text = ""; this.TextBox_Point.Text = ""; this.label_GiftID.Text = ""; BindList(); this.myTabControl1.SelectedIndex = 0; } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(VipSoft.Model.Gift model) { return(dal.Update(model)); }
private void Button_Save_Click(object sender, EventArgs e) { totalPoint = 0; if (memInfo == null) { MessageBox.Show("您必须先选择会员!"); return; } exchangList = new List<VipSoft.Model.ExchangeLog>(); foreach (DataGridViewRow row in this.dataGridView_List.Rows) { Model.ExchangeLog info; Model.Gift gift; if (row.Cells[0].Value != null && bool.Parse(row.Cells[0].Value.ToString())) { int id = int.Parse(row.Cells["Column_ID"].Value.ToString()); string code = row.Cells["Column_Code"].Value.ToString(); string name = row.Cells["Column_Name"].Value.ToString(); int point = int.Parse(row.Cells["Column_Point"].Value.ToString()); int number = 1; try { number = int.Parse(row.Cells["Column_ENum"].Value.ToString()); } catch { MessageBox.Show("请输入正确的兑换数量!"); return; } if (number > int.Parse(row.Cells["Column_Number"].Value.ToString())) { MessageBox.Show("兑换数量超出礼品剩余数量!"); return; } gift = new Model.Gift(); gift.GiftCode=code; gift.Name=name; gift.Photo=""; gift.Point=point; gift.Number=number; gift.ID = id; info = new Model.ExchangeLog(); info.MemID=memInfo.ID; info.CardID=memInfo.CardID; info.Name=memInfo.Name; info.Number=number; info.Point = point * number; info.GiftID=id; info.GiftName=name; info.GiftCode=code; info.MasterID=PublicState.Master.ID; info.MasterName=PublicState.Master.Name; info.ShopID=PublicState.Master.ShopID; info.ShopName=PublicState.Master.ShopName; exchangList.Add(info); } } if (exchangList.Count == 0) { MessageBox.Show("请先选择需要兑换的礼品!"); return; } if (totalPoint > memInfo.Point) { MessageBox.Show("对不起,此会员账户积分不足!"); return; } if (new VipSoft.BLL.ExchangeLog().Add(exchangList)) { // 日志记录 VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog(); log.Add(new Model.SysLog(PublicState.Master, "积分兑换", "积分兑换产品成功,会员卡号:" + memInfo.CardID + "姓名:" + memInfo.Name, DateTime.Now)); // 发送系统短信 memInfo = new BLL.MemCard().GetModel(memInfo.ID); Function.UpdateMemberLevel(2, memInfo);//兑换登记时候自动重新计算 // 提示 MessageBox.Show("兑换成功。"); // 界面 memInfo = null; this.label_M_Money.Text = ""; this.label_M_Name.Text = ""; this.label_M_Point.Text = ""; this.label_M_TotalMoney.Text = ""; this.searchMember1.CardID = ""; BindList(); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(VipSoft.Model.Gift model) { return(dal.Add(model)); }