From a2cff9fff48803c4596c8ec1bff32ba249f6c838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Thu, 13 Aug 2020 11:29:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=AE=A1=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SupplierData/SCP_INVOICE_CREATE.aspx | 2 +- .../SupplierData/SCP_INVOICE_CREATE.aspx.cs | 298 ++++++++++-------- .../SupplierData/SCP_INVOICE_EDIT.aspx.cs | 7 +- 3 files changed, 165 insertions(+), 142 deletions(-) diff --git a/SCP/Views/SupplierData/SCP_INVOICE_CREATE.aspx b/SCP/Views/SupplierData/SCP_INVOICE_CREATE.aspx index cfa0128..0c8d907 100644 --- a/SCP/Views/SupplierData/SCP_INVOICE_CREATE.aspx +++ b/SCP/Views/SupplierData/SCP_INVOICE_CREATE.aspx @@ -33,7 +33,7 @@ > p_action) { V_TB_RECEIVE_LIST _entity = new V_TB_RECEIVE_LIST(); - MyQueryStringDeCode de = new MyQueryStringDeCode(); - string ReceiveID = de.QueryString("ReceiveID"); - if (ReceiveID == "") - { Alert.Show("参数不正确!"); return; } - var ary = ReceiveID.Split(','); - if (ary != null && ary.Length > 0) + + + if (Session["InvoiceCreateQueryParm"] != null) { - _entity.UIDList = new List(); - foreach (var itm in ary) - { - _entity.UIDList.Add(long.Parse(itm)); - } - _entity.State = 1; - _entity.UserInVendIds = CurrentUser.VenderList; - SCP_RECIVECE_CONTROLLER.Get_V_TB_RECEIVE_LIST_List(_entity, (ret) => + InvoiceCreateQueryParm parm = Session["InvoiceCreateQueryParm"] as InvoiceCreateQueryParm; + + if (string.IsNullOrEmpty(parm.ReceiveID)) + + { Alert.Show("参数不正确!"); return; } + var ary = parm.ReceiveID.Split(','); + if (ary != null && ary.Length > 0) { - if (ret.State == ReturnStatus.Succeed) + _entity.UIDList = new List(); + foreach (var itm in ary) { - p_action(ret.Result); + _entity.UIDList.Add(long.Parse(itm)); } - }); + _entity.State = 1; + _entity.UserInVendIds = CurrentUser.VenderList; + SCP_RECIVECE_CONTROLLER.Get_V_TB_RECEIVE_LIST_List(_entity, (ret) => + { + if (ret.State == ReturnStatus.Succeed) + { + p_action(ret.Result); + } + }); + } } + else + { + Alert.Show("操作超时!"); + } + + + + } public void BindData() { SearchData(q => { - MyQueryStringDeCode de = new MyQueryStringDeCode(); + + InvoiceCreateQueryParm parm = Session["InvoiceCreateQueryParm"] as InvoiceCreateQueryParm; Grid_SCP_INVOICE_CREATE.RecordCount = q.Count(); q = SortAndPage(q, Grid_SCP_INVOICE_CREATE); List temp = SCP_RECIVECE_CONTROLLER.Get_V_TB_RECEIVE_LIST(q.ToList()); @@ -106,7 +121,7 @@ namespace SCP.Views.SupplierData if (CurrentUser.RoleList.Contains("采购人员")) { - _vendId = de.QueryString("VendId"); + _vendId = parm.VendId; } else { @@ -144,7 +159,7 @@ namespace SCP.Views.SupplierData // } //}); - var _isall=de.QueryString("IsAll"); + var _isall=parm.IsAll; if(_isall=="0") { temp.ForEach(p => { @@ -182,63 +197,68 @@ namespace SCP.Views.SupplierData //确认创建发票 protected void btnOk_OnClick(object sender, EventArgs e) { - - V_TB_INVOICE invoice = new V_TB_INVOICE(); - invoice.InvcBillNum = SCP_BILLCODE_CONTROLLER.MakeInvoiceCode(); - invoice.CreateTime = DateTime.Now; - invoice.InvoiceNum = ""; - invoice.Remark = txtRemark.Text; - invoice.CreateUser = CurrentUser.Name; - MyQueryStringDeCode de = new MyQueryStringDeCode(); - string _VendId= de.QueryString("VendId"); - string _tax = de.QueryString("Tax"); - invoice.VendId = _VendId; - invoice.State = (int)InvoiceState.New; - invoice.Tax = decimal.Parse(_tax); - string _cj = de.QueryString("CJ"); - string _tz= de.QueryString("TZ"); - invoice.BlancePrice = decimal.Parse(_tz); - invoice.ContractPrice = decimal.Parse(_cj); - - int num = 0; - List _list = new List(); - for (int i = 0; i < Grid_SCP_INVOICE_CREATE.Rows.Count; i++) + if (Session["InvoiceCreateQueryParm"] != null) { - object[] rowDataKeys = Grid_SCP_INVOICE_CREATE.DataKeys[i]; - string uid = rowDataKeys[0].ToString(); - var _entity=new V_TB_RECEIVE_LIST(); - _entity.UID = ConvertHelper.To(rowDataKeys[0]); - _entity.RecvBillNum = rowDataKeys[1] as string; - _entity.PoLine = ConvertHelper.To(rowDataKeys[2]); - _entity.PartCode = rowDataKeys[3] as string; - _entity.Batch = rowDataKeys[4] as string; - _entity.Qty = ConvertHelper.To(rowDataKeys[5]); - _entity.DockCode = rowDataKeys[6] as string; - _entity.Remark = rowDataKeys[7] as string; - _entity.CreateTime = ConvertHelper.To(rowDataKeys[8]); - _entity.CreateUser = rowDataKeys[9] as string; - if (string.IsNullOrEmpty(_entity.CreateUser)) + + + InvoiceCreateQueryParm parm = Session["InvoiceCreateQueryParm"] as InvoiceCreateQueryParm; + + V_TB_INVOICE invoice = new V_TB_INVOICE(); + invoice.InvcBillNum = SCP_BILLCODE_CONTROLLER.MakeInvoiceCode(); + invoice.CreateTime = DateTime.Now; + invoice.InvoiceNum = ""; + invoice.Remark = txtRemark.Text; + invoice.CreateUser = CurrentUser.Name; + + string _VendId = parm.VendId; + string _tax = parm.Tax; + invoice.VendId = _VendId; + invoice.State = (int)InvoiceState.New; + invoice.Tax = decimal.Parse(_tax); + string _cj = parm.CJ; + string _tz = parm.TZ; + invoice.BlancePrice = decimal.Parse(_tz); + invoice.ContractPrice = decimal.Parse(_cj); + + int num = 0; + List _list = new List(); + for (int i = 0; i < Grid_SCP_INVOICE_CREATE.Rows.Count; i++) { - _entity.CreateUser = CurrentUser.Name; - } - _entity.IsDeleted = ConvertHelper.To(rowDataKeys[10]); - _entity.AsnBillNum = rowDataKeys[12] as string; - _entity.Site = rowDataKeys[13] as string; - invoice.Site = rowDataKeys[13] as string; - _entity.VendId = rowDataKeys[14] as string; - _entity.ShipTime = ConvertHelper.To(rowDataKeys[15]); - _entity.OperName = rowDataKeys[16] as string; - _entity.PartDesc1 = rowDataKeys[17] as string; - _entity.State = ConvertHelper.To(rowDataKeys[18]); - _entity.PoBillNum = rowDataKeys[19] as string; - _entity.VendName = rowDataKeys[20] as string; - _entity.Site_Desc = rowDataKeys[21] as string; - _entity.PoUnit = rowDataKeys[22] as string; - _entity.LocUnit = rowDataKeys[23] as string; - _entity.Price = ConvertHelper.To(rowDataKeys[24]); - _entity.VendBatch = rowDataKeys[25] as string; - _entity.Currency = rowDataKeys[26] as string; - _entity.BillType_DESC = rowDataKeys[27] as string; + object[] rowDataKeys = Grid_SCP_INVOICE_CREATE.DataKeys[i]; + string uid = rowDataKeys[0].ToString(); + var _entity = new V_TB_RECEIVE_LIST(); + _entity.UID = ConvertHelper.To(rowDataKeys[0]); + _entity.RecvBillNum = rowDataKeys[1] as string; + _entity.PoLine = ConvertHelper.To(rowDataKeys[2]); + _entity.PartCode = rowDataKeys[3] as string; + _entity.Batch = rowDataKeys[4] as string; + _entity.Qty = ConvertHelper.To(rowDataKeys[5]); + _entity.DockCode = rowDataKeys[6] as string; + _entity.Remark = rowDataKeys[7] as string; + _entity.CreateTime = ConvertHelper.To(rowDataKeys[8]); + _entity.CreateUser = rowDataKeys[9] as string; + if (string.IsNullOrEmpty(_entity.CreateUser)) + { + _entity.CreateUser = CurrentUser.Name; + } + _entity.IsDeleted = ConvertHelper.To(rowDataKeys[10]); + _entity.AsnBillNum = rowDataKeys[12] as string; + _entity.Site = rowDataKeys[13] as string; + invoice.Site = rowDataKeys[13] as string; + _entity.VendId = rowDataKeys[14] as string; + _entity.ShipTime = ConvertHelper.To(rowDataKeys[15]); + _entity.OperName = rowDataKeys[16] as string; + _entity.PartDesc1 = rowDataKeys[17] as string; + _entity.State = ConvertHelper.To(rowDataKeys[18]); + _entity.PoBillNum = rowDataKeys[19] as string; + _entity.VendName = rowDataKeys[20] as string; + _entity.Site_Desc = rowDataKeys[21] as string; + _entity.PoUnit = rowDataKeys[22] as string; + _entity.LocUnit = rowDataKeys[23] as string; + _entity.Price = ConvertHelper.To(rowDataKeys[24]); + _entity.VendBatch = rowDataKeys[25] as string; + _entity.Currency = rowDataKeys[26] as string; + _entity.BillType_DESC = rowDataKeys[27] as string; @@ -246,83 +266,89 @@ namespace SCP.Views.SupplierData - System.Web.UI.WebControls.Label _label = (System.Web.UI.WebControls.Label)Grid_SCP_INVOICE_CREATE.Rows[i].FindControl("Total1"); - _entity.CanQty = ConvertHelper.To(_label.Text);//ConvertHelper.To < Int32 >(rowDataKeys[2]); - GridRow row = Grid_SCP_INVOICE_CREATE.Rows[i]; - System.Web.UI.WebControls.TextBox txtQty = (System.Web.UI.WebControls.TextBox)row.FindControl("txtQty"); - System.Web.UI.WebControls.TextBox txtPrice = (System.Web.UI.WebControls.TextBox)row.FindControl("txtPrice"); - System.Web.UI.WebControls.TextBox txtLineMemo = (System.Web.UI.WebControls.TextBox)row.FindControl("txtLineMemo"); + System.Web.UI.WebControls.Label _label = (System.Web.UI.WebControls.Label)Grid_SCP_INVOICE_CREATE.Rows[i].FindControl("Total1"); + _entity.CanQty = ConvertHelper.To(_label.Text);//ConvertHelper.To < Int32 >(rowDataKeys[2]); + GridRow row = Grid_SCP_INVOICE_CREATE.Rows[i]; + System.Web.UI.WebControls.TextBox txtQty = (System.Web.UI.WebControls.TextBox)row.FindControl("txtQty"); + System.Web.UI.WebControls.TextBox txtPrice = (System.Web.UI.WebControls.TextBox)row.FindControl("txtPrice"); + System.Web.UI.WebControls.TextBox txtLineMemo = (System.Web.UI.WebControls.TextBox)row.FindControl("txtLineMemo"); - decimal Qty = 0; - try - { - if (txtQty.Text.Trim() != "") + decimal Qty = 0; + try { - Qty = Convert.ToDecimal(txtQty.Text.Trim()); + if (txtQty.Text.Trim() != "") + { + Qty = Convert.ToDecimal(txtQty.Text.Trim()); + } + } + catch + { + PageContext.RegisterStartupScript(Alert.GetShowInTopReference("开票数量输入不正确")); + return; } - } - catch - { - PageContext.RegisterStartupScript(Alert.GetShowInTopReference("开票数量输入不正确")); - return; - } - decimal Price = 0; - try - { - if (txtPrice.Text.Trim() != "") + decimal Price = 0; + try { - Price = Convert.ToDecimal(txtPrice.Text.Trim()); + if (txtPrice.Text.Trim() != "") + { + Price = Convert.ToDecimal(txtPrice.Text.Trim()); + } + } + catch + { + PageContext.RegisterStartupScript(Alert.GetShowInTopReference("单价输入不正确")); + return; } - } - catch - { - PageContext.RegisterStartupScript(Alert.GetShowInTopReference("单价输入不正确")); - return; - } - if (Qty == 0) - { - continue; + if (Qty == 0) + { + continue; + } + if (Qty > _entity.CanQty) + { + PageContext.RegisterStartupScript(Alert.GetShowInTopReference("开票数量不能大于可用开票数量")); + return; + } + _entity.Qty = Qty; + _entity.Price = Price; + _entity.Remark = txtLineMemo.Text; + _list.Add(_entity); + num++; } - if (Qty >_entity.CanQty) + if (num == 0) { - PageContext.RegisterStartupScript(Alert.GetShowInTopReference("开票数量不能大于可用开票数量")); + PageContext.RegisterStartupScript(Alert.GetShowInTopReference("没有可用的开票记录")); return; } - _entity.Qty = Qty; - _entity.Price = Price; - _entity.Remark = txtLineMemo.Text; - _list.Add(_entity); - num++; - } - if (num == 0) - { - PageContext.RegisterStartupScript(Alert.GetShowInTopReference("没有可用的开票记录")); - return; - } - int _number= 0; - _list.ForEach(p =>{ - if(p.Qty>0) + int _number = 0; + _list.ForEach(p => { - _number++; + if (p.Qty > 0) + { + _number++; + } + }); + if (_number == _list.Count) + { + string _modify = parm.Modify; + if (_modify == "1") + { + Alert.Show("有退货单未处理!"); + return; + } } - }); - if(_number == _list.Count) - { - string _modify = de.QueryString("Modify"); - if (_modify == "1") + var ret = SCP_INVOICE_CONTROLLER.CREATE_TB_INVOICE(invoice, _list); + if (ret.State == ReturnStatus.Succeed) { - Alert.Show("有退货单未处理!"); - return; + string script = $"alert(\'发票 {invoice.InvcBillNum} 生成成功\');"; + script += ActiveWindow.GetHidePostBackReference(); + PageContext.RegisterStartupScript(script); } } - var ret=SCP_INVOICE_CONTROLLER.CREATE_TB_INVOICE(invoice, _list); - if (ret.State == ReturnStatus.Succeed) + else { - string script = $"alert(\'发票 {invoice.InvcBillNum} 生成成功\');"; - script += ActiveWindow.GetHidePostBackReference(); - PageContext.RegisterStartupScript(script); + Alert.Show("操作超时"); } @@ -378,7 +404,7 @@ namespace SCP.Views.SupplierData } //_info.SupplierCode = vu.VenderId; } - + Session["InvoiceCreateQueryParm"] = null; return strTax; } diff --git a/SCP/Views/SupplierData/SCP_INVOICE_EDIT.aspx.cs b/SCP/Views/SupplierData/SCP_INVOICE_EDIT.aspx.cs index bf197ca..419a272 100644 --- a/SCP/Views/SupplierData/SCP_INVOICE_EDIT.aspx.cs +++ b/SCP/Views/SupplierData/SCP_INVOICE_EDIT.aspx.cs @@ -391,19 +391,16 @@ namespace SCP.Views.SupplierData Alert.Show("单价输入不正确"); return; } - - - _entity.Remark = txtLineMemo.Text; _entity.Price = PriceNew; _entity.Qty = QtyNew; - - _ls.Add(_entity); } } + // SCPDB.Database.SqlQuery("select * from V_TB_INVOICE WHERE STATE==0 AND ").ToArray + if (_ls.Count > 0) { var ret = SCP_INVOICE_CONTROLLER.SAVE_TB_INVOICE_APPLY(_invoice,_ls);