protected void btnSave_Click(object sender, EventArgs e) { if (this.PaymentRequestID != 0) { XMPaymentApply payment = base.XMPaymentApplyService.GetXMPaymentApplyById(this.PaymentRequestID); if ((bool)payment.IsAudit || (bool)payment.FinancialStatus) { base.ShowMessage("申请单已审核,不能修改!"); return; } payment.ContractNumber = txtNumber.Text.Trim(); payment.RequestFundsReason = txtNote.Text.Trim(); payment.PayMode = int.Parse(ddlPayType.SelectedValue); payment.SupplierID = ddlSupplierList.SelectedValue != "" ? int.Parse(ddlSupplierList.SelectedValue) : 1; payment.BankAcount = txtBankAcount.Text.Trim(); payment.UpdateID = HozestERPContext.Current.User.CustomerID; payment.UpdateDate = DateTime.Now; base.XMPaymentApplyService.UpdateXMPaymentApply(payment); base.ShowMessage("操作成功!"); BindGrid(payment.Id); } else { XMPaymentApply xmPaymentApply = new XMPaymentApply(); decimal payAmounts = 0; decimal.TryParse(ltPayMoney.Text, out payAmounts); xmPaymentApply.PayAmounts = payAmounts; xmPaymentApply.PayMode = int.Parse(ddlPayType.SelectedValue);; xmPaymentApply.SupplierID = ddlSupplierList.SelectedValue != "" ? int.Parse(ddlSupplierList.SelectedValue) : 1; xmPaymentApply.RequstDate = DateTime.Now; xmPaymentApply.UserDate = DateTime.Now; xmPaymentApply.IsAudit = false; xmPaymentApply.FinancialStatus = false; xmPaymentApply.ApplicantID = HozestERPContext.Current.User.CustomerID; xmPaymentApply.UpdateDate = DateTime.Now; xmPaymentApply.UpdateID = HozestERPContext.Current.User.CustomerID; xmPaymentApply.IsEnable = false; xmPaymentApply.FinancialConfirm = false; XMPaymentApplyService.InsertXMPaymentApply(xmPaymentApply); base.ShowMessage("操作成功!"); BindGrid(xmPaymentApply.Id); } }
protected void btnSave_Click(object sender, Ext.Net.DirectEventArgs e) { var purchases = base.XMPurchaseService.GetXMPurchaseById(PayID); var XMPaymentApplyList = XMPaymentApplyService.GetXMPaymentApplyListByPurchaseID(PayID); decimal amount = XMPaymentApplyList.Sum(a => a.PayAmounts); decimal payamount = decimal.Parse(txtAmount.Text); if (amount + payamount > purchases.ProductsMoney) { Ext.Net.ExtNet.Msg.Alert("提示", "金额超出范围!").Show(); } else { XMPaymentApply paymentApply = new XMPaymentApply(); paymentApply.PurchaseID = purchases.Id; paymentApply.PayAmounts = decimal.Parse(txtAmount.Text); paymentApply.PayMode = purchases.PaymentType.Value; paymentApply.SupplierID = purchases.SupplierId; paymentApply.RequstDate = DateTime.Now; paymentApply.UserDate = purchases.PurchaseDate; paymentApply.ApplicantID = HozestERPContext.Current.User.CustomerID; paymentApply.UpdateDate = DateTime.Now; paymentApply.UpdateID = HozestERPContext.Current.User.CustomerID; paymentApply.IsAudit = false; paymentApply.FinancialStatus = false; paymentApply.FinancialConfirm = false; paymentApply.IsEnable = false; paymentApply.RequestFundsReason = txtReason.Text; base.XMPaymentApplyService.InsertXMPaymentApply(paymentApply); window1.Hide(); Ext.Net.ExtNet.Msg.Alert("提示", "操作成功!").Show(); } }
protected void grdvPurChase_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var info = e.Row.DataItem as XMPurchase; Label lblDealAddress = e.Row.FindControl("lblDealAddress") as Label; Label lblPurchaseStatus = e.Row.FindControl("lblPurchaseStatus") as Label; //采购订单状态 ImageButton imgBtnEdit = e.Row.FindControl("imgBtnEdit") as ImageButton; ImageButton imgProductDetails = e.Row.FindControl("imgProductDetails") as ImageButton; ImageButton imgBtnDelete = e.Row.FindControl("imgBtnDelete") as ImageButton; ImageButton imgRejected = e.Row.FindControl("imgRejected") as ImageButton; //生成入库单 ImageButton imgReturned = e.Row.FindControl("imgReturned") as ImageButton; //生成退货单 ImageButton imgPay = e.Row.FindControl("imgPay") as ImageButton; if (imgBtnEdit != null) { imgBtnEdit.OnClientClick = "return ShowWindowDetail('编辑采购订单','" + CommonHelper.GetStoreLocation() + "ManageInventory/PurchaseAdd.aspx?Type=1" + "&&Id=" + info.Id + "',1200,600, this,function(){document.getElementById('" + this.btnSearch.ClientID + "').click();});"; } if (imgProductDetails != null) { imgProductDetails.OnClientClick = "return ShowWindowDetail('查看采购订单','" + CommonHelper.GetStoreLocation() + "ManageInventory/PurchaseAdd.aspx?Type=2" + "&&Id=" + info.Id + "',1200,600, this,function(){document.getElementById('" + this.btnSearch.ClientID + "').click();});"; } if (imgRejected != null) { imgRejected.OnClientClick = "return ShowWindowDetail('新建采购入库单','" + CommonHelper.GetStoreLocation() + "ManageInventory/StorageAdd.aspx?Type=0" + "&&PurchaseID=" + info.Id + "',1200,600, this,function(){document.getElementById('" + this.btnSearch.ClientID + "').click();});"; } if (imgReturned != null) { imgReturned.OnClientClick = "return ShowWindowDetail('新建退货单','" + CommonHelper.GetStoreLocation() + "ManageInventory/RejectedAdd.aspx?Type=0" + "&&PurchaseID=" + info.Id + "',1200,600, this,function(){document.getElementById('" + this.btnSearch.ClientID + "').click();});"; } var purchase = base.XMPurchaseService.GetXMPurchaseById(info.Id); if (purchase != null && purchase.IsAudit != null) { //var payment = base.XMPaymentApplyService.GetXMPaymentApplyByPurchaseID(purchase.Id); var paymentList = XMPaymentApplyService.GetXMPaymentApplyListByPurchaseID(purchase.Id);//判断是否有付款数据 if (paymentList.Count > 0) { if (purchase.IsAudit.Value) { if (purchase.BillStatus == 2) //已全部入库 { imgReturned.Visible = false; imgRejected.Visible = false; imgProductDetails.Visible = true; imgBtnDelete.Visible = false; imgBtnEdit.Visible = false; imgPay.Visible = false; } else { bool Status = true; //decimal amount = paymentList.Sum(a => a.PayAmounts); //if (amount >=0) //{ // foreach (var item in paymentList) // { // bool isIsAudit = item.IsAudit.Value; // bool FinancialStatus = item.FinancialStatus.Value; // Status = isIsAudit && FinancialStatus; // } //} if (Status) { imgReturned.Visible = true; imgRejected.Visible = true; } else { imgReturned.Visible = false; imgRejected.Visible = false; } imgProductDetails.Visible = true; imgBtnDelete.Visible = false; imgBtnEdit.Visible = false; } } else { imgPay.Visible = false; imgBtnEdit.Visible = true; imgBtnDelete.Visible = true; imgRejected.Visible = false; imgReturned.Visible = false; imgProductDetails.Visible = true; } } else { if (purchase.IsAudit.Value) { imgBtnDelete.Visible = false; imgPay.Visible = true; imgRejected.Visible = true; } else { imgPay.Visible = false; imgBtnDelete.Visible = true; imgRejected.Visible = false; } imgReturned.Visible = false; imgProductDetails.Visible = true; //imgProductDetails.Visible = false; } } string dealAddress = info.DealAddress; if (!string.IsNullOrEmpty(dealAddress) && dealAddress.Length > 12) { dealAddress = dealAddress.Substring(0, 12) + "...."; } lblDealAddress.Text = dealAddress; lblDealAddress.ToolTip = info.DealAddress; //判断更新采购单状态 int purchaseId = info.Id; UpdatePurcahaseStatus(purchaseId, info.BillStatus); } }
protected void btnSave_Click(object sender, EventArgs e) { decimal value = 0; if (this.type == 0) //新增 { bool isEmpty = false; //判断厂家编码是否填写(厂家编码必填) bool isFlase = false; //判断入库数量值是否正确 string rf = AutoRejectedNumber(); //自动生成退货单号 var InventoryInfo = base.XMInventoryInfoService.GetXMInventoryInfoById(this.ID); int storageID = -1; if (InventoryInfo != null) { storageID = InventoryInfo.WfId; } int supplierId = ddlSuppliers.SelectedValue == "" ? -1 : int.Parse(ddlSuppliers.SelectedValue); int BizUserId = HozestERPContext.Current.User.CustomerID; // 退货人 DateTime BizDt = txtStorageDate.Value == "" ? DateTime.Parse(DateTime.Now.ToShortDateString()) : Convert.ToDateTime(txtStorageDate.Value); //退货时间 int paymentType = int.Parse(ddlPayment.SelectedValue); string note = txtNote.Text.Trim(); decimal totalRejectedMoney = 0; string hiddjsonContent = hdfJsonContent.Value; if (hiddjsonContent != "") { JArray ja_goods = (JArray)JsonConvert.DeserializeObject(hiddjsonContent); if (ja_goods.Count == 0) { isEmpty = true; } for (int i = 0; i < ja_goods.Count; i++) { int rejecedCount = ja_goods[i]["Count"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["Count"].ToString().Replace('\"', ' ').Trim()); //可退货数量 bool t = IsNumeric(ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? "0" : ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim()); if (!t) { base.ShowMessage("商品退货数量格式不正确!"); BindGrid(hiddjsonContent); return; } int productCount = ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim()); //退货数量 if (productCount == 0 || productCount > rejecedCount) { isFlase = true; } } } if (isFlase) { base.ShowMessage("商品退货数量不能为0 或 大于可退货数量!"); BindGrid(hiddjsonContent); return; } if (isEmpty) { base.ShowMessage("厂家编码不能为空,请输入厂家编码 或商品信息不存在!"); BindGrid(hiddjsonContent); return; } XMPurchaseRejected rejected = new XMPurchaseRejected(); rejected.Ref = rf; rejected.SupplierId = supplierId; rejected.BizUserId = BizUserId; rejected.BizDt = BizDt; rejected.BillStatus = 0; //待退货 rejected.RejectionMoney = totalRejectedMoney; rejected.ReceivingType = paymentType; rejected.BillMemo = note; rejected.CreateID = HozestERPContext.Current.User.CustomerID; rejected.CreateDate = DateTime.Now; rejected.UpdateID = HozestERPContext.Current.User.CustomerID; rejected.UpdateDate = DateTime.Now; rejected.IsEnable = false; rejected.IsAudit = false; rejected.IsStoraged = true; //已经入库 base.XMPurchaseRejectedService.InsertXMPurchaseRejected(rejected); int rejectedID = rejected.Id; if (hiddjsonContent != "") { JArray ja_goods = (JArray)JsonConvert.DeserializeObject(hiddjsonContent); for (int i = 0; i < ja_goods.Count; i++) { string productCode = ja_goods[i]["PlatformMerchantCode"].ToString().Replace('\"', ' ').Trim(); //厂家编码 int productCount = ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim()); //退货数量 XMPurchaseRejectedProductDetails details = new XMPurchaseRejectedProductDetails(); details.PrId = rejectedID; var product = base.XMProductService.getXMProductByManufacturersCode(productCode); if (product != null) { details.ProductId = product.Id; } details.InventoryInfoID = this.ID; //库存ID details.PlatformMerchantCode = productCode; details.RejectionCount = productCount; // 退货数量 details.CreateDate = DateTime.Now; details.CreateID = HozestERPContext.Current.User.CustomerID; details.UpdateDate = DateTime.Now; details.UpdateID = HozestERPContext.Current.User.CustomerID; details.IsEnable = false; base.XMPurchaseRejectedProductDetailsService.InsertXMPurchaseRejectedProductDetails(details); } } XMPaymentApply xmPaymentApply = new XMPaymentApply(); //xmPaymentApply.PurchaseID = this.PurchaseID; xmPaymentApply.PayAmounts = 0 - totalRejectedMoney; xmPaymentApply.PayMode = paymentType; xmPaymentApply.SupplierID = supplierId; xmPaymentApply.RequstDate = DateTime.Now; xmPaymentApply.UserDate = DateTime.Now; xmPaymentApply.IsAudit = false; xmPaymentApply.FinancialStatus = false; xmPaymentApply.ApplicantID = HozestERPContext.Current.User.CustomerID; xmPaymentApply.UpdateDate = DateTime.Now; xmPaymentApply.UpdateID = HozestERPContext.Current.User.CustomerID; xmPaymentApply.IsEnable = false; xmPaymentApply.FinancialConfirm = false; XMPaymentApplyService.InsertXMPaymentApply(xmPaymentApply); base.ShowMessage("操作成功!"); BindGrid(rejected.Id); } else //编辑 { bool isEmpty = false; //判断厂家编码是否填写(厂家编码必填) bool isFlase = false; //判断入库数量值是否正确 int id = this.RejectedID; decimal totalMoney = 0; //总价 var rejected = base.XMPurchaseRejectedService.GetXMPurchaseRejectedById(id); if (rejected != null) { var rejectedDetails = base.XMPurchaseRejectedProductDetailsService.GetXMPurchaseRejectedProductDetailsByRejectedID(rejected.Id); rejected.SupplierId = ddlSuppliers.SelectedValue == "" ? -1 : int.Parse(ddlSuppliers.SelectedValue); rejected.BizUserId = HozestERPContext.Current.User.CustomerID; rejected.BizDt = txtStorageDate.Value == "" ? DateTime.Parse(DateTime.Now.ToShortDateString()) : Convert.ToDateTime(txtStorageDate.Value); //业务时间 string hiddjsonContent = hdfJsonContent.Value; if (hiddjsonContent != "") { JArray ja_goods = (JArray)JsonConvert.DeserializeObject(hiddjsonContent); if (ja_goods.Count == 0) { isEmpty = true; } for (int i = 0; i < ja_goods.Count; i++) { int rejecedCount = ja_goods[i]["Count"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["Count"].ToString().Replace('\"', ' ').Trim()); //可退货数量 bool t = IsNumeric(ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? "0" : ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim()); if (!t) { base.ShowMessage("商品采购数量数量格式不正确!"); BindGrid(hiddjsonContent); return; } int productCount = ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim()); //退货数量 if (productCount == 0 || productCount > rejecedCount) { isFlase = true; } } } if (isFlase) { base.ShowMessage("商品退货数量不能为0 或 大于可退货数量!"); BindGrid(hiddjsonContent); return; } if (isEmpty) { base.ShowMessage("厂家编码不能为空,请输入厂家编码或 商品信息不存在"); BindGrid(hiddjsonContent); return; } rejected.RejectionMoney = totalMoney; rejected.ReceivingType = int.Parse(ddlPayment.SelectedValue); rejected.BillMemo = txtNote.Text.Trim(); rejected.UpdateDate = DateTime.Now; rejected.UpdateID = HozestERPContext.Current.User.CustomerID; base.XMPurchaseRejectedService.UpdateXMPurchaseRejected(rejected); if (rejectedDetails != null && rejectedDetails.Count() > 0) { if (hiddjsonContent != "") { JArray ja_goods = (JArray)JsonConvert.DeserializeObject(hiddjsonContent); for (int i = 0; i < ja_goods.Count; i++) { string productCode = ja_goods[i]["PlatformMerchantCode"].ToString().Replace('\"', ' ').Trim(); //厂家编码 int productCount = ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim()); //退货数量 foreach (XMPurchaseRejectedProductDetails info in rejectedDetails) { if (productCode == info.PlatformMerchantCode) { info.InventoryInfoID = this.ID;//库存ID info.RejectionCount = productCount; info.UpdateID = HozestERPContext.Current.User.CustomerID; info.UpdateDate = DateTime.Now; base.XMPurchaseRejectedProductDetailsService.UpdateXMPurchaseRejectedProductDetails(info); } } } } } } base.ShowMessage("操作成功!"); BindGrid(rejected.Id); } }