/// <summary> /// 执行充值 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { try { //询问用户 if (MessageBoxForm.Show("您确定要进行充值?", MessageBoxButtons.OKCancel) == DialogResult.OK) { decimal addValue = 0; try { //获取值 addValue = Convert.ToDecimal(txtValue.Text); //if (addValue <= 0) //{ // MessageBoxForm.Show("输入的金额必须要大于0元!", "系统提示"); // return; //} //else if ((_cardInfo.money + addValue) >= _cardInfo.MaxCount) { MessageBoxForm.Show("剩余金额必须小于上限金额!", MessageBoxButtons.OK); return; } if ((_cardInfo.money + addValue) >= 10000) { MessageBoxForm.Show("剩余金额必须小于10000元!", MessageBoxButtons.OK); return; } if ((_cardInfo.money + addValue) <= 0) { MessageBoxForm.Show("剩余金额必须大于0元!", MessageBoxButtons.OK); return; } //执行数据更改 _cardInfo.money = _cardInfo.money + Convert.ToDecimal((addValue).ToString("0.000").Substring(0, Convert.ToDecimal(addValue).ToString("0.000").Length - 2)); } catch (Exception ex2) { MessageBoxForm.Show("输入的数值不对,请重新输入!", MessageBoxButtons.OK); Bouwa.Helper.Class.Log.WriterLine(Bouwa.Helper.Class.ELevel.error, this.Text + "时进行值转换时出现异常!", ex2.Message); return; } Bouwa.ITSP2V31.BLL.CardInfoBLL _cardInfoBll = new Bouwa.ITSP2V31.BLL.CardInfoBLL(); int resout = _cardInfoBll.Update(_cardInfo, CurrentUser.Current.PassWordKey, addValue.ToString("0.00"), true); if (resout == 0) { MemoryCard_Load(sender, e);//刷新窗口 MessageBoxForm.Show("恭喜您充值成功!请确认卡上余额!", MessageBoxButtons.OK); //关闭窗口 this.Close(); return; } //执行数据还原 _cardInfo.money = _cardInfo.money - Convert.ToDecimal((addValue).ToString("0.000").Substring(0, Convert.ToDecimal(addValue).ToString("0.000").Length - 2)); //执行还原操作 _cardInfoBll.Update(_cardInfo, CurrentUser.Current.PassWordKey, addValue.ToString("0.00"), false); if (resout == 1) { MessageBoxForm.Show("网络连接不正常,请重新进行充值!", MessageBoxButtons.OK); } else { MessageBoxForm.Show(_cardInfoBll.ConvertMeassByStatus(resout), MessageBoxButtons.OK); } } } catch (Exception ex) { MessageBoxForm.Show("充值失败!", MessageBoxButtons.OK); Bouwa.Helper.Class.Log.WriterLine(Bouwa.Helper.Class.ELevel.error, this.Text + "时进行充值时出现异常!", ex.Message); } }
/// <summary> /// 执行充值 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { try { //询问用户 if (MessageBoxForm.Show("您确定要进行充值?", MessageBoxButtons.OKCancel) == DialogResult.OK) { int addValue = 0; try { //获取值 addValue = Convert.ToInt32(txtValue.Text); //if (addValue <= 0) //{ // MessageBoxForm.Show("输入的剩余次数必须要大于0次!", MessageBoxButtons.OK); // return; //} //else if ((_cardInfo.times + addValue) >= _cardInfo.MaxCount) { MessageBoxForm.Show("剩余次数必须小于上限次数!", MessageBoxButtons.OK); return; } if ((_cardInfo.times + addValue) >= 99999) { MessageBoxForm.Show("剩余次数必须小于99999次!", MessageBoxButtons.OK); return; } if ((_cardInfo.times + addValue) <= 0) { MessageBoxForm.Show("剩余次数必须大于0次!", MessageBoxButtons.OK); return; } //执行数据更改 _cardInfo.times = _cardInfo.times + addValue; } catch (Exception ex2) { MessageBoxForm.Show("输入的数值不对,请重新输入!", MessageBoxButtons.OK); Bouwa.Helper.Class.Log.WriterLine(Bouwa.Helper.Class.ELevel.error, this.Text + "时进行值转换时出现异常!", ex2.Message); return; } Bouwa.ITSP2V31.BLL.CardInfoBLL _cardInfoBll = new Bouwa.ITSP2V31.BLL.CardInfoBLL(); int resout = _cardInfoBll.Update(_cardInfo, CurrentUser.Current.PassWordKey, addValue.ToString(), true); if (resout == 0) { LimitOfTimeCard_Load(sender, e);//刷新窗口 MessageBoxForm.Show("恭喜您充值成功!请确认卡上剩余次数!", MessageBoxButtons.OK); //关闭窗口 this.Close(); return; } //执行数据还原 _cardInfo.times = _cardInfo.times - addValue; //执行还原操作 _cardInfoBll.Update(_cardInfo, CurrentUser.Current.PassWordKey, addValue.ToString(), false); if (resout == 1) { MessageBoxForm.Show("网络连接不正常,请重新进行充值!", MessageBoxButtons.OK); } else { MessageBoxForm.Show(_cardInfoBll.ConvertMeassByStatus(resout), MessageBoxButtons.OK); } } } catch (Exception ex) { MessageBoxForm.Show("充值失败!", MessageBoxButtons.OK); Bouwa.Helper.Class.Log.WriterLine(Bouwa.Helper.Class.ELevel.error, this.Text + "时进行充值时出现异常!", ex.Message); } }
/// <summary> /// 执行充值 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { try { DateTime oldTime = _cardInfo.end_date;//保留一份原始数据 //询问用户 if (MessageBoxForm.Show("您确定要进行时间更改?", MessageBoxButtons.OKCancel) == DialogResult.OK) { DateTime addValue = DateTime.Now.AddDays(-1); //默认是昨天 try { //获取值 addValue = DateTime.Parse(txtValue.Text); if (DateTime.Compare(DateTime.Now, addValue) >= 0) { MessageBoxForm.Show("到期日期必须要大于当天!", MessageBoxButtons.OK); return; } if (addValue.Year >= 2100 || addValue.Year <= 2000) { MessageBoxForm.Show("只能在21世纪以内,请重新选择日期!", MessageBoxButtons.OK); return; } //执行数据更改 _cardInfo.end_date = addValue; } catch (Exception ex2) { MessageBoxForm.Show("选择的日期不正确,请重新输入!", MessageBoxButtons.OK); Bouwa.Helper.Class.Log.WriterLine(Bouwa.Helper.Class.ELevel.error, this.Text + "时进行值转换时出现异常!", ex2.Message); return; } Bouwa.ITSP2V31.BLL.CardInfoBLL _cardInfoBll = new Bouwa.ITSP2V31.BLL.CardInfoBLL(); int resout = _cardInfoBll.Update(_cardInfo, CurrentUser.Current.PassWordKey, addValue.ToString(), true); if (resout == 0) { DeadlineCard_Load(sender, e);//刷新窗口 MessageBoxForm.Show("恭喜您更新时间成功!请确认卡上到期时间!", MessageBoxButtons.OK); //关闭窗口 this.Close(); return; } //执行数据还原 _cardInfo.end_date = oldTime; //执行还原操作 _cardInfoBll.Update(_cardInfo, CurrentUser.Current.PassWordKey, addValue.ToString(), false); if (resout == 1) { MessageBoxForm.Show("网络连接不正常,请重新进行充值!", MessageBoxButtons.OK); } else { MessageBoxForm.Show(_cardInfoBll.ConvertMeassByStatus(resout), MessageBoxButtons.OK); } } } catch (Exception ex) { MessageBoxForm.Show("更新时间失败!", MessageBoxButtons.OK); Bouwa.Helper.Class.Log.WriterLine(Bouwa.Helper.Class.ELevel.error, this.Text + "时进行充值时出现异常!", ex.Message); } }