//充值 public ActionResult Cash() { string userName = Request["username"]; UserInfoService userInfoService = new UserInfoService(); UserInfo user = userInfoService.LoadEntities(s => s.Name == userName).FirstOrDefault(); if (user == null) { throw new Exception("充值失败,充值用户不存!"); } string money = Request["Money"]; if (!string.IsNullOrEmpty(money)) { decimal cashMoney = decimal.Parse(money); if (cashMoney > 0) { //更新用户账户信息 Account account = accountService.LoadEntities(s => s.UserId == user.id).FirstOrDefault(); if (account.Balance < cashMoney) { return(Content("余额不足,提现失败")); } if (account != null) { account.Balance = account.Balance - cashMoney; accountService.UpdateEntity(account); } else { return(Content("提现失败,当前用户账户信息有误!")); } //增加一条充值记录 CashRecord cashRecord = new CashRecord(); cashRecord.UserId = user.id; cashRecord.CashBy = userName; cashRecord.CashDate = DateTime.Now; cashRecord.CashMoney = cashMoney; CashRecordService crs = new CashRecordService(); crs.AddEntity(cashRecord); return(Content("ok")); } else { return(Content("充值失败,充值金额有误!")); } } else { return(Content("充值失败,充值金额为空!")); } }
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; CashRecord order = (CashRecord)row.DataBoundItem; if (shopIDDataGridViewTextBoxColumn.Index == e.ColumnIndex) { e.Value = CommonGlobalCache.GetShopName(order.ShopID); } else if (createTimeDataGridViewTextBoxColumn.Index == e.ColumnIndex) { createTimeDataGridViewTextBoxColumn.DefaultCellStyle.Format = DateTimeUtil.DEFAULT_DATETIME_FORMAT; } else if (operatorUserIDDataGridViewTextBoxColumn.Index == e.ColumnIndex) { e.Value = CommonGlobalCache.GetUserName(order.OperatorUserID); } else if (feeTypeDataGridViewTextBoxColumn.Index == e.ColumnIndex) { e.Value = CommonGlobalUtil.GetFeeTypeName(order.FeeType); } }
private void btn_Save_Click(object sender, EventArgs e) { try { if (GlobalUtil.EngineUnconnectioned(this)) { return; } decimal moneyCash = decimal.Parse(this.skinTextBox_MoneyCash.SkinTxt.Text); if (moneyCash <= 0) { GlobalMessageBox.Show("输入的金额必须大于0!"); return; } else { if (moneyCash > Convert.ToDecimal(99999999.99)) { GlobalMessageBox.Show("输入的金额不能大于99999999.99!"); return; } } //if (this.guideComboBox1.SelectedIndex == 0) //{ // GlobalMessageBox.Show("操作人不能为空"); // return; //} CashRecordFeeType feeType = (CashRecordFeeType)(this.skinComboBox_FeeType.SelectedValue); if (feeType != CashRecordFeeType.Income) { moneyCash = moneyCash * -1; } CashRecord cashRecord = new CashRecord() { ShopID = GlobalCache.CurrentShopID, FeeType = (byte)feeType, FeeDetailType = this.skinComboBox_FeeDetailType.SelectedValue.ToString(), MoneyCash = moneyCash, Remarks = this.skinTextBox_Remarks.SkinTxt.Text.Trim(), CreateTime = DateTime.Now, OperatorUserID = CommonGlobalCache.CurrentUserID //(string)this.guideComboBox1.SelectedValue, }; InsertResult result = GlobalCache.ServerProxy.InsertCashRecord(cashRecord); switch (result) { case InsertResult.Success: GlobalMessageBox.Show("新增成功!"); TabPageClose(this.CurrentTabPage, this.SourceCtrlType); break; case InsertResult.Error: GlobalMessageBox.Show("内部错误!"); break; default: break; } } catch (Exception ee) { GlobalUtil.WriteLog(ee); GlobalMessageBox.Show("新增失败!"); } finally { GlobalUtil.UnLockPage(this); } }