protected void btnExport_Click(object sender, EventArgs e) { KPOrder kpOrder = TheKPOrderMgr.LoadKPOrder(this.OrderId, true); this.Gv_List.DataSource = kpOrder.KPItems; this.ExportXLS(this.Gv_List, "KPOrder" + DateTime.Now.ToString("ddhhmmss") + ".xls"); }
protected void btnRejectInvoice_Click(object sender, EventArgs e) { try { KPOrder kpOrder = TheKPOrderMgr.LoadKPOrder(this.OrderId, true); kpOrder.InvoiceStatus = BusinessConstants.CODE_MASTER_INVOICE_STATUS_VALUE_REJECTED; //if (kpOrder.CLN_ORDER != null) // UnBindSP(kpOrder); TheKPOrderMgr.UpdateKPOrder(kpOrder); this.ShowSuccessMessage("MasterData.Bill.RejectInvoice.Successful"); UpdateView(); } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
protected void UnBindSP(KPOrder kpOrder) { string[] cln_order = kpOrder.CLN_ORDER.Split(new char[] { ',' }); foreach (string orderno in cln_order) { KPOrder ko = TheKPOrderMgr.LoadKPOrder(decimal.Parse(orderno)); if (ko != null) { ko.CLN_ORDER = null; TheKPOrderMgr.UpdateKPOrder(ko); } } kpOrder.CLN_ORDER = null; kpOrder.CLN_amount = 0; TheKPOrderMgr.UpdateKPOrder(kpOrder); }
protected void btnSubmitInvoice_Click(object sender, EventArgs e) { try { KPOrder kpOrder = TheKPOrderMgr.LoadKPOrder(this.OrderId, true); decimal invoiceAmountWithoutTax = Convert.ToDecimal(tbInvoiceAmountWithoutTax.Text.Trim()); if (kpOrder.CLN_ORDER == null) { process(kpOrder); } #region 只校验不含税金额 if (System.Math.Abs(kpOrder.TotalAmount - invoiceAmountWithoutTax - kpOrder.CLN_amount) > 1) { ShowErrorMessage("MasterData.Bill.InvoiceAmountWithoutTax.AmountMustLessThanOne"); return; } #endregion kpOrder.InvoiceCount = Convert.ToInt32(tbInvoceCount.Text.Trim()); kpOrder.InvoiceDate = DateTime.Parse(tbInvoiceDate.Text.Trim()); kpOrder.InvoiceNumber = tbInvoiceNumber.Text.Trim(); kpOrder.InvoiceRemark = tbInvoiceRemark.Text.Trim(); kpOrder.InvoiceTax = tbInvoiceTax.Text.Trim(); kpOrder.InvoiceAmountWithoutTax = invoiceAmountWithoutTax; kpOrder.InvoiceAmount = Convert.ToDecimal(tbInvoiceAmount.Text.Trim()); kpOrder.InvoiceStatus = BusinessConstants.CODE_MASTER_INVOICE_STATUS_VALUE_INPROCESS; TheKPOrderMgr.UpdateKPOrder(kpOrder); this.ShowSuccessMessage("MasterData.Bill.SubmitInvoice.Successful"); UpdateView(); } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
protected void process(KPOrder kpOrder) { if (string.IsNullOrEmpty(kpOrder.CLN_ORDER) && kpOrder.ORDER_TYPE_ID == "KP") { DetachedCriteria clnorder = DetachedCriteria.For <KPOrder>() .Add(Expression.Eq("ORDER_TYPE_ID", "SP")) .Add(Expression.IsNull("CLN_ORDER")) .Add(Expression.Eq("PARTY_FROM_ID", kpOrder.PARTY_FROM_ID)) .Add(Expression.Eq("SYS_CODE", kpOrder.SYS_CODE)); IList <KPOrder> kpcln = TheCriteriaMgr.FindAll <KPOrder>(clnorder); if (kpcln != null && kpcln.Count > 0) { decimal?tempamount = 0; decimal offsetamount = 0; decimal tempOrderAmount = kpOrder.TotalAmount; string _clnorder = string.Empty; // tempamount = kpOrder.InvoiceAmountWithoutTax; foreach (KPOrder kp in kpcln) { tempamount = kp.TotalAmount; if (tempamount.HasValue) { if (tempOrderAmount - tempamount > 0) { _clnorder += kp.ORDER_ID.ToString() + ","; kp.CLN_ORDER = kpOrder.ORDER_ID.ToString(); offsetamount += (decimal)tempamount; TheKPOrderMgr.UpdateKPOrder(kp); } } } //kpOrder.InvoiceAmountWithoutTax += offsetamount; kpOrder.CLN_amount = offsetamount; kpOrder.CLN_ORDER = _clnorder.Trim(new char[] { ',' }); TheKPOrderMgr.UpdateKPOrder(kpOrder); } } }
protected void btnPrint_Click(object sender, EventArgs e) { try { KPOrder kpOrder = TheKPOrderMgr.LoadKPOrder(this.OrderId, true); IList <object> list = new List <object>(); if (kpOrder != null) { list.Add(kpOrder); list.Add(kpOrder.KPItems); } string barCodeUrl = ""; //测试 //if (kpOrder.SYS_CODE == "YK") //{ // barCodeUrl = WriteToFile("Bill_BJ.xls", list); //} if (kpOrder.SYS_CODE == "YK") { barCodeUrl = TheReportMgr.WriteToFile("Bill.xls", list); } if (kpOrder.SYS_CODE == "BJ") { barCodeUrl = WriteToFile("Bill_BJ.xls", list); } Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + barCodeUrl + "'); </script>"); kpOrder.ORDER_PRINT = "Y"; kpOrder.PRINT_MODIFY_DATE = DateTime.Now; TheKPOrderMgr.UpdateKPOrder(kpOrder); this.ShowSuccessMessage("MasterData.Bill.Print.Successful"); } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } }
public void InitPageParameter(decimal orderId) { this.OrderId = orderId; KPOrder kpOrder = TheKPOrderMgr.LoadKPOrder(orderId, true); this.tbOrderId.Text = kpOrder.QAD_ORDER_ID; if (kpOrder.InvoiceStatus == null) { process(kpOrder); } //this.tbTotalAmount.Text = kpOrder.TotalAmount.ToString("0.########"); // this.tbTotalAmount.Text = (kpOrder.TotalAmount - kpOrder.CLN_amount).ToString("0.########"); if (kpOrder.ORDER_PUB_DATE != null) { this.tbCreateDate.Text = ((DateTime)kpOrder.ORDER_PUB_DATE).ToString("yyyy-MM-dd"); } UpdateView(); this.Gv_List.DataSource = kpOrder.KPItems; this.Gv_List.DataBind(); }
protected void Button9_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(this.tbImportStartDate.Text)) { throw new Exception("请填写开票日期。"); } DateTime startTime = DateTime.Parse(this.tbImportStartDate.Text); TheKPOrderMgr.ImportKPOrder(startTime); ShowSuccessMessage("操作成功"); fs01.Visible = false; } catch (BusinessErrorException ex) { ShowErrorMessage(ex); } catch (Exception ex) { ShowErrorMessage(ex.Message); } }
public override void UpdateView() { KPOrder kpOrder = TheKPOrderMgr.LoadKPOrder(this.OrderId, true); this.tbInvoceCount.Text = kpOrder.InvoiceCount.ToString(); this.tbInvoiceAmount.Text = kpOrder.InvoiceAmount.ToString("F2"); this.tbInvoiceDate.Text = kpOrder.InvoiceDate.ToString(); this.tbInvoiceNumber.Text = kpOrder.InvoiceNumber; this.tbInvoiceRemark.Text = kpOrder.InvoiceRemark; this.tbInvoiceTax.Text = Convert.ToDecimal(kpOrder.InvoiceTax).ToString("F2"); this.tbInvoiceAmountWithoutTax.Text = kpOrder.InvoiceAmountWithoutTax.ToString("F2"); this.tbTotalAmount.Text = (kpOrder.TotalAmount - kpOrder.CLN_amount).ToString("0.########"); this.tbCln.Text = kpOrder.CLN_ORDER; div_inv.Visible = true; if (kpOrder.ORDER_TYPE_ID == "SP") { this.btnSubmitInvoice.Visible = false; this.btnRejectInvoice.Visible = false; this.btnApproveInvoice.Visible = false; this.tbInvoceCount.ReadOnly = false; this.tbInvoiceAmountWithoutTax.ReadOnly = false; this.tbInvoiceDate.ReadOnly = false; this.tbInvoiceNumber.ReadOnly = false; this.tbInvoiceRemark.ReadOnly = false; this.tbInvoiceTax.ReadOnly = false; this.lblCln.Text = "绑定账单:"; div_inv.Visible = false; } else if (kpOrder.InvoiceStatus == null || kpOrder.InvoiceStatus == string.Empty || kpOrder.InvoiceStatus == BusinessConstants.CODE_MASTER_INVOICE_STATUS_VALUE_REJECTED) { this.btnSubmitInvoice.Visible = true; this.btnRejectInvoice.Visible = false; this.btnApproveInvoice.Visible = false; this.tbInvoceCount.ReadOnly = false; this.tbInvoiceAmountWithoutTax.ReadOnly = false; this.tbInvoiceDate.ReadOnly = false; this.tbInvoiceNumber.ReadOnly = false; this.tbInvoiceRemark.ReadOnly = false; this.tbInvoiceTax.ReadOnly = false; this.tbInvoiceTax.Attributes["onchange"] += "calculate();"; this.tbInvoiceAmountWithoutTax.Attributes["onchange"] += "calculate();"; } else if (kpOrder.InvoiceStatus == BusinessConstants.CODE_MASTER_INVOICE_STATUS_VALUE_INPROCESS) { this.btnSubmitInvoice.Visible = false; this.btnRejectInvoice.Visible = true; this.btnApproveInvoice.Visible = true; this.tbInvoceCount.ReadOnly = true; this.tbInvoiceAmountWithoutTax.ReadOnly = true; this.tbInvoiceDate.ReadOnly = true; this.tbInvoiceNumber.ReadOnly = true; this.tbInvoiceRemark.ReadOnly = true; this.tbInvoiceTax.ReadOnly = true; } else if (kpOrder.InvoiceStatus == BusinessConstants.CODE_MASTER_INVOICE_STATUS_VALUE_APPROVED) { this.btnSubmitInvoice.Visible = false; this.btnRejectInvoice.Visible = false; this.btnApproveInvoice.Visible = false; this.tbInvoceCount.ReadOnly = true; this.tbInvoiceAmountWithoutTax.ReadOnly = true; this.tbInvoiceDate.ReadOnly = true; this.tbInvoiceNumber.ReadOnly = true; this.tbInvoiceRemark.ReadOnly = true; this.tbInvoiceTax.ReadOnly = true; } }