private void btnCommit_Click(object sender, EventArgs e) //提交添加或者修改 { //对数据进行校验 if (!ValidataInput()) { return; } //封装数据 Prize objPrize = new Prize() { PrizeID = int.Parse(txtPrizeID.Text.Trim()), PrizeLevel = txtPrizeLevel.Text.Trim(), PrizeNumber = int.Parse(txtPrizeNumber.Text.Trim()), PrizeName = txtPrizeName.Text.Trim(), }; //提交修改或者添加 switch (actionFlag) { case 1: //添加 objPrizeService.AddPrize(objPrize, Program.objListPrize); //刷新 LoadPrizeInfo(Program.objListPrize); //更新数量 lbTotalPrize.Text = (int.Parse(lbTotalPrize.Text) + objPrize.PrizeNumber).ToString(); EnbleButton(); //添加成功 MessageBox.Show("添加成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; case 2: //修改前数量 lbTotalPrize.Text = (int.Parse(lbTotalPrize.Text) - int.Parse(dgvPrize.CurrentRow.Cells[2].Value.ToString())).ToString(); objPrizeService.UpdatePrize(objPrize, Program.objListPrize); //刷新 LoadPrizeInfo(Program.objListPrize); //更新数量 lbTotalPrize.Text = objPrizeService.GetPrizeSum(Program.objListPrize); EnbleButton(); //添加成功 MessageBox.Show("修改成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; default: break; } }
/// <summary> /// 添加奖品 /// </summary> /// <param name="model"></param> /// <returns></returns> public TResult AddPrize(PrizeDto model) { return(_weiXinPrizeService.AddPrize(model)); }