private void btnReChargeOK_Click(object sender, System.EventArgs e) { int num = 0; if (this.txtReCharge.Text.Trim().IndexOf(".") > 0) { num = this.txtReCharge.Text.Trim().Substring(this.txtReCharge.Text.Trim().IndexOf(".") + 1).Length; } decimal num2; if (!decimal.TryParse(this.txtReCharge.Text.Trim(), out num2) || num > 2) { this.ShowMsg("本次充值要给当前客户加款的金额只能是数值,且不能超过2位小数", false); return; } if (num2 < -10000000m || num2 > 10000000m) { this.ShowMsg("金额大小必须在正负1000万之间", false); return; } Hidistro.Membership.Context.Distributor distributor = Hidistro.Membership.Context.Users.GetUser(this.userId, false) as Hidistro.Membership.Context.Distributor; if (distributor == null) { this.ShowMsg("此分销商已经不存在", false); return; } decimal num3 = num2 + distributor.Balance; BalanceDetailInfo balanceDetailInfo = new BalanceDetailInfo(); balanceDetailInfo.UserId = this.userId; balanceDetailInfo.UserName = distributor.Username; balanceDetailInfo.TradeDate = System.DateTime.Now; balanceDetailInfo.TradeType = TradeTypes.BackgroundAddmoney; balanceDetailInfo.Income = new decimal?(num2); balanceDetailInfo.Balance = num3; balanceDetailInfo.Remark = Globals.HtmlEncode(this.txtRemarks.Text.Trim()); ValidationResults validationResults = Validation.Validate <BalanceDetailInfo>(balanceDetailInfo, new string[] { "ValBalanceDetail" }); string text = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { text += Formatter.FormatErrorMessage(current.Message); } this.ShowMsg(text, false); return; } if (DistributorHelper.AddBalance(balanceDetailInfo, num2)) { this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "success", string.Format("<script>alert(\"本次充值已成功,充值金额:{0}\");window.location.href=\"DistributorReCharge.aspx?userId={1}\"</script>", num2, this.userId)); } this.txtReCharge.Text = string.Empty; this.txtRemarks.Text = string.Empty; this.lblUseableBalance.Money = num3; }
private void btnReChargeOK_Click(object sender, EventArgs e) { decimal num; int length = 0; if (txtReCharge.Text.Trim().IndexOf(".") > 0) { length = txtReCharge.Text.Trim().Substring(txtReCharge.Text.Trim().IndexOf(".") + 1).Length; } if (!(decimal.TryParse(txtReCharge.Text.Trim(), out num) && (length <= 2))) { ShowMsg("本次充值要给当前客户加款的金额只能是数值,且不能超过2位小数", false); } else if ((num < -10000000M) || (num > 10000000M)) { ShowMsg("金额大小必须在正负1000万之间", false); } else { Distributor user = Users.GetUser(userId, false) as Distributor; if (user == null) { ShowMsg("此分销商已经不存在", false); } else { decimal num3 = num + user.Balance; BalanceDetailInfo info2 = new BalanceDetailInfo(); info2.UserId = userId; info2.UserName = user.Username; info2.TradeDate = DateTime.Now; info2.TradeType = TradeTypes.BackgroundAddmoney; info2.Income = new decimal?(num); info2.Balance = num3; info2.Remark = Globals.HtmlEncode(txtRemarks.Text.Trim()); BalanceDetailInfo target = info2; ValidationResults results = Hishop.Components.Validation.Validation.Validate <BalanceDetailInfo>(target, new string[] { "ValBalanceDetail" }); string msg = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } ShowMsg(msg, false); } else { if (DistributorHelper.AddBalance(target)) { ShowMsg(string.Format("本次充值已成功,充值金额:{0}", num), true); } txtReCharge.Text = string.Empty; txtRemarks.Text = string.Empty; lblUseableBalance.Money = num3; } } } }
private void btnReChargeOK_Click(object sender, EventArgs e) { decimal num; int length = 0; if (this.txtReCharge.Text.Trim().IndexOf(".") > 0) { length = this.txtReCharge.Text.Trim().Substring(this.txtReCharge.Text.Trim().IndexOf(".") + 1).Length; } if (!decimal.TryParse(this.txtReCharge.Text.Trim(), out num) || (length > 2)) { this.ShowMsg("本次充值要给当前客户加款的金额只能是数值,且不能超过2位小数", false); } else if ((num < -10000000M) || (num > 10000000M)) { this.ShowMsg("金额大小必须在正负1000万之间", false); } else { Distributor user = Users.GetUser(this.userId, false) as Distributor; if (user == null) { this.ShowMsg("此分销商已经不存在", false); } else { decimal num3 = num + user.Balance; BalanceDetailInfo target = new BalanceDetailInfo(); target.UserId = this.userId; target.UserName = user.Username; target.TradeDate = DateTime.Now; target.TradeType = TradeTypes.BackgroundAddmoney; target.Income = new decimal?(num); target.Balance = num3; target.Remark = Globals.HtmlEncode(this.txtRemarks.Text.Trim()); ValidationResults results = Hishop.Components.Validation.Validation.Validate <BalanceDetailInfo>(target, new string[] { "ValBalanceDetail" }); string msg = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } this.ShowMsg(msg, false); } else { if (DistributorHelper.AddBalance(target, num)) { this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "success", string.Format("<script>alert(\"本次充值已成功,充值金额:{0}\");window.location.href=\"DistributorReCharge.aspx?userId={1}\"</script>", num, this.userId)); } this.txtReCharge.Text = string.Empty; this.txtRemarks.Text = string.Empty; this.lblUseableBalance.Money = num3; } } } }
private void btnAddBalance_Click(object sender, EventArgs e) { if (!RoleHelper.GetUserPrivileges(HiContext.Current.User.Username).Contains(0x232d) && (HiContext.Current.User.UserRole != UserRole.SiteManager)) { this.ShowMsg("权限不够", false); } else { decimal num; int length = 0; if (this.txtReCharge.Text.Trim().IndexOf(".") > 0) { length = this.txtReCharge.Text.Trim().Substring(this.txtReCharge.Text.Trim().IndexOf(".") + 1).Length; } if (!decimal.TryParse(this.txtReCharge.Text.Trim(), out num) || (length > 2)) { this.ShowMsg("本次充值要给当前客户加款的金额只能是数值,且不能超过2位小数", false); } else if ((num < -10000000M) || (num > 10000000M)) { this.ShowMsg("金额大小必须在正负1000万之间", false); } else { int userId = 0; if (!string.IsNullOrEmpty(this.currentUserId.Value)) { userId = Convert.ToInt32(this.currentUserId.Value); } Distributor user = Users.GetUser(userId, false) as Distributor; if (user == null) { this.ShowMsg("此分销商已经不存在", false); } else { decimal num4 = num + user.Balance; BalanceDetailInfo target = new BalanceDetailInfo(); target.UserId = userId; target.UserName = user.Username; target.TradeDate = DateTime.Now; target.TradeType = TradeTypes.BackgroundAddmoney; target.Income = new decimal?(num); target.Balance = num4; target.Remark = Globals.HtmlEncode(this.txtRemark.Text.Trim()); ValidationResults results = Hishop.Components.Validation.Validation.Validate <BalanceDetailInfo>(target, new string[] { "ValBalanceDetail" }); string msg = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } this.ShowMsg(msg, false); } else if (DistributorHelper.AddBalance(target, num)) { this.ShowMsg("加款成功", true); this.ReBind(false); } } } } }
private void btnAddBalance_Click(object sender, System.EventArgs e) { System.Collections.Generic.IList <int> userPrivileges = Hidistro.Membership.Core.RoleHelper.GetUserPrivileges(Hidistro.Membership.Context.HiContext.Current.User.Username); if (!userPrivileges.Contains(9005) && Hidistro.Membership.Context.HiContext.Current.User.UserRole != Hidistro.Membership.Core.Enums.UserRole.SiteManager) { this.ShowMsg("权限不够", false); return; } int num = 0; if (this.txtReCharge.Text.Trim().IndexOf(".") > 0) { num = this.txtReCharge.Text.Trim().Substring(this.txtReCharge.Text.Trim().IndexOf(".") + 1).Length; } decimal num2; if (!decimal.TryParse(this.txtReCharge.Text.Trim(), out num2) || num > 2) { this.ShowMsg("本次充值要给当前客户加款的金额只能是数值,且不能超过2位小数", false); return; } if (num2 < -10000000m || num2 > 10000000m) { this.ShowMsg("金额大小必须在正负1000万之间", false); return; } int userId = 0; if (!string.IsNullOrEmpty(this.currentUserId.Value)) { userId = System.Convert.ToInt32(this.currentUserId.Value); } Hidistro.Membership.Context.Distributor distributor = Hidistro.Membership.Context.Users.GetUser(userId, false) as Hidistro.Membership.Context.Distributor; if (distributor == null) { this.ShowMsg("此分销商已经不存在", false); return; } decimal balance = num2 + distributor.Balance; BalanceDetailInfo balanceDetailInfo = new BalanceDetailInfo(); balanceDetailInfo.UserId = userId; balanceDetailInfo.UserName = distributor.Username; balanceDetailInfo.TradeDate = System.DateTime.Now; balanceDetailInfo.TradeType = TradeTypes.BackgroundAddmoney; balanceDetailInfo.Income = new decimal?(num2); balanceDetailInfo.Balance = balance; balanceDetailInfo.Remark = Globals.HtmlEncode(this.txtRemark.Text.Trim()); ValidationResults validationResults = Validation.Validate <BalanceDetailInfo>(balanceDetailInfo, new string[] { "ValBalanceDetail" }); string text = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { text += Formatter.FormatErrorMessage(current.Message); } this.ShowMsg(text, false); return; } if (DistributorHelper.AddBalance(balanceDetailInfo, num2)) { this.ShowMsg("加款成功", true); this.ReBind(false); } }
private void BtnRefund_Click(object sender, EventArgs e) { PurchaseOrderInfo purchaseOrder = SalesHelper.GetPurchaseOrder(purchaseOrderId); if (!purchaseOrder.CheckAction(PurchaseOrderActions.MASTER_REJECT_REFUND)) { ShowMsg("未付款或不在进行中的订单没有退款操作", false); } else { int length = 0; decimal result = 0M; if (purchaseOrder.PurchaseStatus == OrderStatus.SellerAlreadySent) { if (txtRefundTotal.Text.Trim().IndexOf(".") > 0) { length = txtRefundTotal.Text.Trim().Substring(txtRefundTotal.Text.Trim().IndexOf(".") + 1).Length; } if (!(decimal.TryParse(txtRefundTotal.Text.Trim(), out result) && (length <= 2))) { ShowMsg("退款金额只能是数值,且不能超过2位小数", false); return; } if ((result <= 0M) || (result > purchaseOrder.GetPurchaseTotal())) { ShowMsg("退款金额必须大于0,小于等于实收款", false); return; } } if (txtRefundRemark.Text.Length > 200) { ShowMsg("退款说明限制在200个字符以内", false); } else { decimal num3; Distributor user = Users.GetUser(purchaseOrder.DistributorId) as Distributor; if (purchaseOrder.PurchaseStatus == OrderStatus.SellerAlreadySent) { num3 = result; } else { num3 = decimal.Parse(lblRefundTotal.Money.ToString()); } BalanceDetailInfo balanceDetails = new BalanceDetailInfo(); balanceDetails.UserId = purchaseOrder.DistributorId; balanceDetails.UserName = purchaseOrder.Distributorname; balanceDetails.TradeDate = DateTime.Now; balanceDetails.TradeType = TradeTypes.RefundOrder; balanceDetails.Income = new decimal?(num3); balanceDetails.Balance = user.Balance + num3; balanceDetails.Remark = "采购单退款到预付款"; if (DistributorHelper.AddBalance(balanceDetails)) { purchaseOrder.RefundAmount = num3; purchaseOrder.RefundRemark = Globals.HtmlEncode(txtRefundRemark.Text.Trim()); purchaseOrder.FinishDate = DateTime.Now; if (purchaseOrder.PurchaseStatus == OrderStatus.BuyerAlreadyPaid) { purchaseOrder.PurchaseStatus = OrderStatus.Closed; } if (purchaseOrder.PurchaseStatus == OrderStatus.SellerAlreadySent) { purchaseOrder.PurchaseStatus = OrderStatus.Finished; } if (SalesHelper.RefundPurchaseOrder(purchaseOrder)) { Page.Response.Redirect(Globals.ApplicationPath + string.Format("/Admin/purchaseOrder/RefundPurchaseOrderDetails.aspx?PurchaseOrderId={0}", purchaseOrder.PurchaseOrderId)); } else { ShowMsg("退款失败", false); } } } } }