protected void gvMain_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "select") { List <Sell_OrderOutHouses> orders = ordersSer.GetListArray(" 1=1 and Sell_OrderOutHouses.id=" + e.CommandArgument); ViewState["Orders"] = orders; gvList.DataSource = orders; gvList.DataBind(); } if (e.CommandName == "print") { var model = new Sell_OrderOutHouseService().GetModel(Convert.ToInt32(e.CommandArgument)); if (model.Status == "通过") { string url = string.Format("NewWFSell_OrderOutHousePrint.aspx?Id={0}", e.CommandArgument); Response.Write(string.Format("<script>window.open('{0}','_blank')</script>", url)); } else { base.ClientScript.RegisterStartupScript(base.GetType(), null, string.Format("<script>alert('该单据尚未通过!!');</script>")); } } }
protected void LinkButton1_Click1(object sender, EventArgs e) { if (Session["Orders"] != null) { if (Session["OrderInHouseSession"] != null) { object selectedId = Session["OrderInHouseSession"]; if (selectedId != null) { Sell_OrderOutHousesService sellOrderServer = new Sell_OrderOutHousesService(); Sell_OrderOutHouseService sellOrderMainServer = new Sell_OrderOutHouseService(); Sell_OrderOutHouse sell_OrderOutHouseModel = sellOrderMainServer.GetModel(Convert.ToInt32(selectedId)); txtSupplier.Text = sell_OrderOutHouseModel.Supplier; txtSellProNo.Text = sell_OrderOutHouseModel.ProNo; txtPOName.Text = sell_OrderOutHouseModel.POName; txtPONo.Text = sell_OrderOutHouseModel.PONo; lblTotal.Text = sell_OrderOutHouseModel.SellTotal.ToString(); List <Sell_OrderOutHouses> POOrders = sellOrderServer.Sell_OrderOutHouse_Sell_OrderInHouse_ListView(" id=" + selectedId);; List <Sell_OrderOutHouseBacks> sellOrderOutList = new List <Sell_OrderOutHouseBacks>(); foreach (var model in POOrders) { Sell_OrderOutHouseBacks sellOrderOutModel = new Sell_OrderOutHouseBacks() { Good_Model = model.Good_Model, GoodName = model.GoodName, GoodNo = model.GoodNo, GoodNum = model.GoodNum, GoodPrice = model.GoodPrice, //GoodRemark = model.GoodRemark, GoodSellPrice = model.GoodSellPrice, GoodSellPriceTotal = model.GoodSellPriceTotal, GoodSpec = model.GoodSpec, GoodTypeSmName = model.GoodTypeSmName, GoodUnit = model.GoodUnit, GooId = model.GooId, HouseID = model.HouseID, HouseName = model.HouseName, SellId = model.Ids, Total = model.Total, }; sellOrderOutList.Add(sellOrderOutModel); } Session["Orders"] = sellOrderOutList; Session["OrderInHouseSession"] = null; gvList.DataSource = sellOrderOutList; gvList.DataBind(); } //} //List<Sell_OrderOutHouseBacks> selectedList = Session["DioSellWFHouseGoods"] as List<Sell_OrderOutHouseBacks>; //if (selectedList.Count > 0) //{ // List<Sell_OrderOutHouseBacks> POOrders = Session["Orders"] as List<Sell_OrderOutHouseBacks>; // if (POOrders == null) POOrders = new List<Sell_OrderOutHouseBacks>(); // POOrders.AddRange(selectedList); // Session["DioSellWFHouseGoods"] = null; // gvList.DataSource = POOrders; // gvList.DataBind(); // Session["Orders"] = POOrders; //} } } }
protected void btnSub_Click(object sender, EventArgs e) { if (txtProNo.Text == "") { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('请填写 采购退货单号!');</script>"); return; } //查询项目信息是否存在 string sql = string.Format("select Id,PoNo,HouseID from CAI_OrderOutHouse where ProNo='{0}' and status='通过'", txtProNo.Text); var obj = DBHelp.getDataTable(sql); if (obj.Rows.Count != 1) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('采购退货信息不存在!');</script>"); return; } sql = string.Format("SELECT count(id) FROM TB_SupplierInvoice where CaiTuiProNo='{0}' and status='通过'", txtProNo.Text); var obj1 = DBHelp.ExeScalar(sql); if (Convert.ToInt32(obj1) != 1) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('支付负数单不存在!');</script>"); return; } // 如果此采购退货单生成的负数的 支付单的支付状态为已支付,结清状态为已结清 //说明有3种可能 1.事后退货的已抵消 2.此采退是全退货单 3.此采退单导致了全部退货 //1.修改此采购退货单生成的负数的支付单的状态 为未支付,结清状态为 未结清。 //2-3 删除基于此入库ID 的所有负数支付单(支付状态为未支付和结清状态为 未结清),修改此采购退货单生成的负数的支付单的状态 为未支付,结清状态为 未结清。 // 你要区分这两种情况!! //4.如果此采购退货单生成的负数的 支付单的支付状态为未支付,结清状态为未结清,由此采购退货单生成的负数的支付单删除即可 sql = string.Format(@"select TB_SupplierInvoice.Id,Ids,RuIds,RePayClear,IsPayStatus from TB_SupplierInvoices left join TB_SupplierInvoice on TB_SupplierInvoices.Id=TB_SupplierInvoice.Id where CAITUIPRONO='{0}' and Status='通过'", txtProNo.Text); var dt = DBHelp.getDataTable(sql); using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlCommand objCommand = conn.CreateCommand(); foreach (DataRow dr in dt.Rows) { if (dr["RePayClear"].ToString() == "1" && dr["IsPayStatus"].ToString() == "2")//已支付 已结清 { //检查是否是事后退货的已抵消 sql = string.Format(@"select COUNT(*) from TB_TempSupplierInvoice left join TB_SupplierInvoice on TB_SupplierInvoice.Id=TB_TempSupplierInvoice.SupplierInvoiceId where SupplierInvoiceIds={0} and Status='通过' ", dr["Ids"]); objCommand.CommandText = sql; var result = objCommand.ExecuteScalar(); if (Convert.ToInt32(result) > 0) { //修改此采购退货单生成的负数的支付单的状态 为未支付,结清状态为 未结清。 sql = "update TB_SupplierInvoices set RePayClear=2,IsPayStatus=0 where ids=" + dr["Ids"]; objCommand.CommandText = sql; objCommand.ExecuteNonQuery(); } else { //删除基于此入库ID 的所有负数支付单(支付状态为未支付和结清状态为 未结清), //修改此采购退货单生成的负数的支付单的状态 为未支付,结清状态为 未结清 sql = "delete from TB_SupplierInvoices where RuIds=" + dr["RuIds"] + " and SupplierInvoiceTotal<0 and RePayClear=2 and IsPayStatus=0"; objCommand.CommandText = sql; objCommand.ExecuteNonQuery(); sql = "update TB_SupplierInvoices set RePayClear=2,IsPayStatus=0 where ids=" + dr["Ids"]; objCommand.CommandText = sql; objCommand.ExecuteNonQuery(); } } else if (dr["RePayClear"].ToString() == "2" && dr["IsPayStatus"].ToString() == "0")//未支付 未结清 { //如果此采购退货单生成的负数的 支付单的支付状态为未支付,结清状态为未结清,由此采购退货单生成的负数的支付单删除即可 sql = "delete from TB_SupplierInvoices where Ids=" + dr["Ids"]; objCommand.CommandText = sql; objCommand.ExecuteNonQuery(); } } conn.Close(); } TB_HouseGoodsService houseGoodsSer = new TB_HouseGoodsService(); CAI_OrderOutHousesService ordersSer = new CAI_OrderOutHousesService(); List <CAI_OrderOutHouses> orders = ordersSer.GetListArray(" 1=1 and CAI_OrderOutHouses.id=" + obj.Rows[0]["Id"]); sql = string.Format(@"delete from tb_EForm where e_No='{0}' and proId=24; delete from tb_EForms where e_Id in (select id from tb_EForm where e_No='{0}' and proId=24); delete from CAI_OrderOutHouses where id = (select ID from CAI_OrderOutHouse where ProNo='{0}'); delete from CAI_OrderOutHouse where ProNo='{0}';", txtProNo.Text); using (var conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); var objCommand = conn.CreateCommand(); objCommand.Transaction = tan; try { for (int i = 0; i < orders.Count; i++) { houseGoodsSer.InHouse(Convert.ToInt32(obj.Rows[0]["HouseID"]), orders[i].GooId, orders[i].GoodNum, orders[i].GoodPrice, objCommand); } objCommand.CommandText = sql; objCommand.ExecuteNonQuery(); tan.Commit(); } catch (Exception) { tan.Rollback(); conn.Close(); base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('删除失败!');</script>"); return; } conn.Close(); } //删除没有表体的数据 sql = "select ProNo from TB_SupplierInvoice where not exists(select Id from TB_SupplierInvoices where TB_SupplierInvoices.Id=TB_SupplierInvoice.Id)"; var db = DBHelp.getDataTable(sql); if (db.Rows.Count > 0) { using (var conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); var objCommand = conn.CreateCommand(); objCommand.Transaction = tan; try { foreach (DataRow dr in db.Rows) { sql = string.Format(@" delete from tb_EForm where e_No='{0}' and proId=31; delete from tb_EForms where e_Id in (select id from tb_EForm where e_No='{0}' and proId=31); delete from TB_SupplierInvoice where ProNo='{0}'; delete from TB_SupplierInvoices where Id = (select Id from TB_SupplierInvoice where ProNo='{0}');", dr["ProNo"]); objCommand.CommandText = sql; objCommand.ExecuteNonQuery(); } tan.Commit(); conn.Close(); } catch (Exception) { tan.Rollback(); conn.Close(); base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('删除失败!');</script>"); return; } } } string PONO = obj.Rows[0]["PoNo"].ToString(); Sell_OrderOutHouseService SellOutSer = new Sell_OrderOutHouseService(); SellOutSer.SellOrderUpdatePoStatus2(PONO); base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('删除成功!');</script>"); }
private void Show() { var comModel = new Dal.BaseInfo.TB_CompanyService().GetModel(Convert.ToInt32(ddlCompany.Text)); lblCompanyName.Text = comModel.ComName; lblSimpName.Text = comModel.ComSimpName; lblDate.Text = ddlYear.Text + ddlMonth.Text; propertyList = this.FIN_PropertyService.GetListArray_CommCost(ddlYear.Text + ddlMonth.Text, ddlCompany.Text); string poName = string.Format("{0}年{1}行政经费", ddlYear.Text, comModel.ComSimpName); //显示系统值 #region 邮寄费 var sql = string.Format(@"---项目中预期报销单的邮寄费合计 select isnull(SUM(Tb_DispatchList.PostTotal),0) from tb_Post left join Tb_DispatchList ON tb_Post.ID=Tb_DispatchList.Post_Id where AppName in (select id from tb_User where CompanyCode='{0}') and tb_Post.poName='{1}' and tb_Post.id in (select allE_id from tb_EForm where state='通过' and proid in (select pro_Id from A_ProInfo where pro_Type='邮寄文档快递表') )", comModel.ComCode, poName); var DispatchList = DBHelp.ExeScalar(sql); if (ddlMonth.Text != "12") { sql = string.Format(@"---项目中预期报销单的邮寄费合计 select isnull(SUM(Tb_DispatchList.PostTotal),0) from tb_Post left join Tb_DispatchList ON tb_Post.ID=Tb_DispatchList.Post_Id where year(AppTime)={0} and MONTH(AppTime)={1} and AppName in (select id from tb_User where CompanyCode='{2}') and tb_Post.poName='{3}' and tb_Post.id in (select allE_id from tb_EForm where state='通过' and proid in (select pro_Id from A_ProInfo where pro_Type='邮寄文档快递表') )", ddlYear.Text, ddlMonth.Text, comModel.ComCode, poName); } else { sql = string.Format(@"---项目中预期报销单的邮寄费合计 select isnull(SUM(Tb_DispatchList.PostTotal),0) from tb_Post left join Tb_DispatchList ON tb_Post.ID=Tb_DispatchList.Post_Id where AppTime>='{0} 00:00:00' and AppName in (select id from tb_User where CompanyCode='{1}') and tb_Post.poName='{2}' and tb_Post.id in (select allE_id from tb_EForm where state='通过' and proid in (select pro_Id from A_ProInfo where pro_Type='邮寄文档快递表') )", ddlYear.Text + "-12-1", comModel.ComCode, poName); } var DispatchList_Month = DBHelp.ExeScalar(sql); #endregion #region 办公用品费 sql = string.Format(@"--小类办公用品费 中的所有合计 select isnull(sum(goodTotal),0) FROM JXC_REPORT left join CG_POOrder on JXC_REPORT.PONo=CG_POOrder.PONo and CG_POOrder.IFZhui=0 and CG_POOrder.Status='通过' where GoodTypeSmName ='办公用品费' and GoodTypeName ='杂费' and CG_POOrder.AppName in (select id from tb_User where CompanyCode='{0}') and CG_POOrder.poName='{1}'", comModel.ComCode, poName); var JXCREPORT = DBHelp.ExeScalar(sql); if (ddlMonth.Text != "12") { sql = string.Format(@"--小类办公用品费 中的所有合计 select isnull(sum(goodTotal),0) FROM JXC_REPORT left join CG_POOrder on JXC_REPORT.PONo=CG_POOrder.PONo and CG_POOrder.IFZhui=0 and CG_POOrder.Status='通过' where GoodTypeSmName ='办公用品费' and GoodTypeName ='杂费' and year(RuTime)={0} and MONTH(RuTime)={1} and CG_POOrder.AppName in (select id from tb_User where CompanyCode='{2}') and CG_POOrder.poName='{3}'", ddlYear.Text, ddlMonth.Text, comModel.ComCode, poName); } else { sql = string.Format(@"--小类办公用品费 中的所有合计 select isnull(sum(goodTotal),0) FROM JXC_REPORT left join CG_POOrder on JXC_REPORT.PONo=CG_POOrder.PONo and CG_POOrder.IFZhui=0 and CG_POOrder.Status='通过' where GoodTypeSmName ='办公用品费' and GoodTypeName ='杂费' and RuTime>='{0} 00:00:00' and CG_POOrder.AppName in (select id from tb_User where CompanyCode='{1}') and CG_POOrder.poName='{2}'", ddlYear.Text + "-12-1", comModel.ComCode, poName); } var JXCREPORT_Month = DBHelp.ExeScalar(sql); #endregion sql = string.Format(@"--项目中除去黄色框的内容的其他成本合计(该项目销售明细报表中除去黄色框的其他总成本+总损失差额) select isnull(sum(goodTotal),0) as totoal FROM JXC_REPORT left join CG_POOrder on JXC_REPORT.PONo=CG_POOrder.PONo and CG_POOrder.IFZhui=0 and CG_POOrder.Status='通过' where CG_POOrder.AppName in (select id from tb_User where CompanyCode='{0}') and CG_POOrder.poName='{1}' ", comModel.ComCode, poName); var JXCREPORT_Cha = (decimal)DBHelp.ExeScalar(sql); if (ddlMonth.Text != "12") { sql = string.Format(@"--行政经费的总额 扣除如下 黄色部分的总额 select isnull(sum(goodTotal),0) as totoal FROM JXC_REPORT left join CG_POOrder on JXC_REPORT.PONo=CG_POOrder.PONo and CG_POOrder.IFZhui=0 and CG_POOrder.Status='通过' where year(RuTime)={0} and MONTH(RuTime)<={1} and CG_POOrder.AppName in (select id from tb_User where CompanyCode='{2}') and CG_POOrder.poName='{3}' ", ddlYear.Text, ddlMonth.Text, comModel.ComCode, poName); } else { sql = string.Format(@"--行政经费的总额 扣除如下 黄色部分的总额 select isnull(sum(goodTotal),0) as totoal FROM JXC_REPORT left join CG_POOrder on JXC_REPORT.PONo=CG_POOrder.PONo and CG_POOrder.IFZhui=0 and CG_POOrder.Status='通过' where RuTime>='{0} 00:00:00' and CG_POOrder.AppName in (select id from tb_User where CompanyCode='{1}') and CG_POOrder.poName='{2}' ", ddlYear.Text + "-12-1", comModel.ComCode, poName); } var JXCREPORT_Cha_Month = (decimal)DBHelp.ExeScalar(sql); Sell_OrderOutHouseService sellOutSer = new Sell_OrderOutHouseService(); string where = string.Format(" and Sell_OrderOutHouse.CreateUserId in (select id from tb_User where CompanyCode='{0}') and poName='{1}'", comModel.ComCode, poName); Dictionary <string, decimal> GetAllTotal = sellOutSer.GetAllTotal_ChengBen(where); if (ddlMonth.Text != "12") { where = string.Format(" and year(RuTime)={0} and MONTH(RuTime)={1} and Sell_OrderOutHouse.CreateUserId in (select id from tb_User where CompanyCode='{2}') and poName='{3}'", ddlYear.Text, ddlMonth.Text, comModel.ComCode, poName); } else { where = string.Format(" and RuTime>='{0} 00:00:00' and Sell_OrderOutHouse.CreateUserId in (select id from tb_User where CompanyCode='{1}') and poName='{2}'", ddlYear.Text + "-12-1", comModel.ComCode, poName); } Dictionary <string, decimal> GetAllTotal_Month = sellOutSer.GetAllTotal_ChengBen(where); foreach (var p in propertyList) { if (p.CostType == "均摊邮费") { p.XiShu_Value = Convert.ToDecimal(DispatchList); p.CurrentMonth_Value = Convert.ToDecimal(DispatchList_Month); } if (p.CostType == "办公用品费") { p.XiShu_Value = Convert.ToDecimal(JXCREPORT); p.CurrentMonth_Value = Convert.ToDecimal(JXCREPORT_Month); } #region 系统值 if (p.CostType == "资质费用" && GetAllTotal.ContainsKey("17110")) { p.XiShu_Value = GetAllTotal["17110"]; } else if (p.CostType == "各类证照" && GetAllTotal.ContainsKey("17112")) { p.XiShu_Value = GetAllTotal["17112"]; } else if (p.CostType == "汽车维修费" && GetAllTotal.ContainsKey("16616")) { p.XiShu_Value = GetAllTotal["16616"]; } else if (p.CostType == "汽车保险" && GetAllTotal.ContainsKey("17109")) { p.XiShu_Value = GetAllTotal["17109"]; } else if (p.CostType == "公务汽油费" && GetAllTotal.ContainsKey("14346")) { p.XiShu_Value = GetAllTotal["14346"]; } else if (p.CostType == "律师费" && GetAllTotal.ContainsKey("17111")) { p.XiShu_Value = GetAllTotal["17111"]; } else if (p.CostType == "内部装修改建费" && GetAllTotal.ContainsKey("14350")) { p.XiShu_Value = GetAllTotal["14350"]; } else if (p.CostType == "软件开发费" && GetAllTotal.ContainsKey("14396")) { p.XiShu_Value = GetAllTotal["14396"]; } else if (p.CostType == "公务费" && GetAllTotal.ContainsKey("14423")) { p.XiShu_Value = GetAllTotal["14423"]; } else if (p.CostType == "交通费" && GetAllTotal.ContainsKey("15317")) { p.XiShu_Value = GetAllTotal["15317"]; } else if (p.CostType == "水费" && GetAllTotal.ContainsKey("14348")) { p.XiShu_Value = GetAllTotal["14348"]; } else if (p.CostType == "电费" && GetAllTotal.ContainsKey("14349")) { p.XiShu_Value = GetAllTotal["14349"]; } else if (p.CostType == "物业管理费" && GetAllTotal.ContainsKey("17108")) { p.XiShu_Value = GetAllTotal["17108"]; } else if (p.CostType == "设备投资费" && GetAllTotal.ContainsKey("17158")) { p.XiShu_Value = GetAllTotal["17158"]; } else if (p.CostType == "电信费用" && GetAllTotal.ContainsKey("17167")) { p.XiShu_Value = GetAllTotal["17167"]; } #endregion #region 当月值 if (p.CostType == "资质费用" && GetAllTotal_Month.ContainsKey("17110")) { p.CurrentMonth_Value = GetAllTotal_Month["17110"]; } else if (p.CostType == "各类证照" && GetAllTotal_Month.ContainsKey("17112")) { p.CurrentMonth_Value = GetAllTotal_Month["17112"]; } else if (p.CostType == "汽车维修费" && GetAllTotal_Month.ContainsKey("16616")) { p.CurrentMonth_Value = GetAllTotal_Month["16616"]; } else if (p.CostType == "汽车保险" && GetAllTotal_Month.ContainsKey("17109")) { p.CurrentMonth_Value = GetAllTotal_Month["17109"]; } else if (p.CostType == "公务汽油费" && GetAllTotal_Month.ContainsKey("14346")) { p.CurrentMonth_Value = GetAllTotal_Month["14346"]; } else if (p.CostType == "律师费" && GetAllTotal_Month.ContainsKey("17111")) { p.CurrentMonth_Value = GetAllTotal_Month["17111"]; } else if (p.CostType == "内部装修改建费" && GetAllTotal_Month.ContainsKey("14350")) { p.CurrentMonth_Value = GetAllTotal_Month["14350"]; } else if (p.CostType == "软件开发费" && GetAllTotal_Month.ContainsKey("14396")) { p.CurrentMonth_Value = GetAllTotal_Month["14396"]; } else if (p.CostType == "公务费" && GetAllTotal_Month.ContainsKey("14423")) { p.CurrentMonth_Value = GetAllTotal_Month["14423"]; } else if (p.CostType == "交通费" && GetAllTotal_Month.ContainsKey("15317")) { p.CurrentMonth_Value = GetAllTotal_Month["15317"]; } else if (p.CostType == "水费" && GetAllTotal_Month.ContainsKey("14348")) { p.CurrentMonth_Value = GetAllTotal_Month["14348"]; } else if (p.CostType == "电费" && GetAllTotal_Month.ContainsKey("14349")) { p.CurrentMonth_Value = GetAllTotal_Month["14349"]; } else if (p.CostType == "物业管理费" && GetAllTotal_Month.ContainsKey("17108")) { p.CurrentMonth_Value = GetAllTotal_Month["17108"]; } else if (p.CostType == "设备投资费" && GetAllTotal_Month.ContainsKey("17158")) { p.CurrentMonth_Value = GetAllTotal_Month["17158"]; } else if (p.CostType == "电信费用" && GetAllTotal_Month.ContainsKey("17167")) { p.CurrentMonth_Value = GetAllTotal_Month["17167"]; } #endregion #region 商品编码 if (p.CostType == "资质费用") { p.Code_Value = "17110"; } else if (p.CostType == "各类证照") { p.Code_Value = "17112"; } else if (p.CostType == "汽车维修费") { p.Code_Value = "16616"; } else if (p.CostType == "汽车保险") { p.Code_Value = "17109"; } else if (p.CostType == "公务汽油费") { p.Code_Value = "14346"; } else if (p.CostType == "律师费") { p.Code_Value = "17111"; } else if (p.CostType == "内部装修改建费") { p.Code_Value = "14350"; } else if (p.CostType == "软件开发费") { p.Code_Value = "14396"; } else if (p.CostType == "公务费") { p.Code_Value = "14423"; } else if (p.CostType == "交通费") { p.Code_Value = "15317"; } else if (p.CostType == "水费") { p.Code_Value = "14348"; } else if (p.CostType == "电费") { p.Code_Value = "14349"; } else if (p.CostType == "物业管理费") { p.Code_Value = "17108"; } else if (p.CostType == "设备投资费") { p.Code_Value = "17158"; } else if (p.CostType == "电信费用") { p.Code_Value = "17167"; } #endregion } var other_M = propertyList.Find(t => t.CostType == "均摊杂费"); if (other_M != null) { var others = JXCREPORT_Cha - propertyList.Sum(t => t.XiShu_Value); other_M.XiShu_Value = others; other_M.CurrentMonth_Value = JXCREPORT_Cha_Month - propertyList.Sum(t => t.CurrentMonth_Value); } }
protected void btnSub_Click(object sender, EventArgs e) { if (txtProNo.Text.Trim() == "") { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('请填写 销售退货单号!');</script>"); return; } else { if (CheckProNo(txtProNo.Text) == false) { return; } } //查询项目信息是否存在 string sql = string.Format("select Id,PoNo from Sell_OrderInHouse where ProNo='{0}' and status='通过'", txtProNo.Text.Trim()); var obj = DBHelp.getDataTable(sql); if (obj.Rows.Count != 1) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('销售退货信息不存在!');</script>"); return; } Sell_OrderInHousesService ordersSer = new Sell_OrderInHousesService(); TB_HouseGoodsService houseGoodsSer = new TB_HouseGoodsService(); //查询销售退货信息 List <Sell_OrderInHouses> orders = ordersSer.GetListArray(" 1=1 and Sell_OrderInHouses.id=" + obj.Rows[0]["Id"]); sql = string.Format(@"--销售退货还原--25 销售退货 delete from tb_EForm where e_No='{0}' and proId=25; delete from tb_EForms where e_Id in (select id from tb_EForm where e_No='{0}' and proId=25); delete from Sell_OrderInHouses where id = (select ID from Sell_OrderInHouse where ProNo='{0}'); delete from Sell_OrderInHouse where ProNo='{0}';", txtProNo.Text.Trim()); using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); SqlCommand objCommand = conn.CreateCommand(); objCommand.Transaction = tan; try { for (int i = 0; i < orders.Count; i++) { if (orders[i].GoodPriceSecond != 0) { houseGoodsSer.OutHouse(orders[i].HouseID, orders[i].GooId, orders[i].GoodNum, orders[i].GoodPriceSecond, objCommand); } else { houseGoodsSer.OutHouse(orders[i].HouseID, orders[i].GooId, orders[i].GoodNum, orders[i].GoodPrice, objCommand); } } objCommand.CommandText = sql; objCommand.ExecuteNonQuery(); tan.Commit(); } catch (Exception) { tan.Rollback(); conn.Close(); base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('删除失败!');</script>"); return; } conn.Close(); string PONO = obj.Rows[0]["PoNo"].ToString(); Sell_OrderOutHouseService SellOutSer = new Sell_OrderOutHouseService(); SellOutSer.SellOrderUpdatePoStatus2(PONO); new CG_POOrdersService().GetListArrayToFpsAndUpdatePoStatue(PONO, "通过"); new CG_POOrderService().GetOrder_ToInvoiceAndUpdatePoStatus(PONO); base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('删除成功!');</script>"); } }
private void Show() { string sql = " 1=1 "; if (txtZhuJi.Text != "") { //string goodName = txtZhuJi.Text.Replace(@"\", ","); string[] allList = txtZhuJi.Text.Split('\\'); int goodId = goodsSer.GetGoodId(allList[1], allList[3], allList[4], allList[2], allList[5]); if (goodId == 0) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('你填写的商品不存在!');</script>"); return; } sql += string.Format(" and TB_HouseGoods.GoodId={0}", goodId); } if (ddlGoodSmType.Text != "" && ddlGoodType.Text != "") { sql += string.Format(" and GoodTypeSmName ='{0}' ", ddlGoodSmType.SelectedItem.Value); } else { if (ddlGoodSmType.Text != "" && ddlGoodType.Text == "") { sql += string.Format(" and GoodTypeSmName ='{0}' ", ddlGoodSmType.SelectedItem.Value); } if (ddlGoodSmType.Text == "" && ddlGoodType.Text != "") { sql += string.Format(" and GoodTypeName ='{0}'", ddlGoodType.SelectedItem.Value); } } if (ddlHouse.Text != "" && ddlHouse.Text != "0") { sql += string.Format(" and HouseId ={0}", ddlHouse.SelectedItem.Value); } if (Request["ChuKuPoNo"] != null) { sql += string.Format(" and TB_Good.GoodId in ( select GoodId from CG_POOrder left join CG_POOrders on CG_POOrder.id=CG_POOrders.id where Status='通过' and PONo='{0}')", Request["ChuKuPoNo"]); //sql += string.Format(" and CG_POOrder.PONo='{0}'", Request["ChuKuPoNo"]); } if (txtGuiGe.Text != "") { sql += string.Format(" and GoodSpec like '%{0}%'", txtGuiGe.Text); } List <TB_HouseGoods> gooQGooddList = this.houseSer.GetListArray_ToDio_1(sql, Request["ChuKuPoNo"]); if (gooQGooddList.Count > 0 && Request["ChuKuPoNo"] != null) { Sell_OrderOutHouseService sellOutSer = new Sell_OrderOutHouseService(); var allNums = sellOutSer.GetSellOrderNum(Request["ChuKuPoNo"].ToString()); System.Text.StringBuilder goodIds = new System.Text.StringBuilder(); foreach (var model in gooQGooddList) { if (allNums.ContainsKey(model.GoodId)) { model.LastNum = allNums[model.GoodId]; } goodIds.AppendFormat("{0},", model.GoodId); } if (goodIds.ToString().Length > 0) { var DoingOrderNums = sellOutSer.GetDoingOrderNum(goodIds.ToString().Trim(',')); var caiNums = GetDs_New(Request["ChuKuPoNo"], goodIds.ToString().Trim(',')); foreach (var model in gooQGooddList) { if (DoingOrderNums.ContainsKey(model.GoodId)) { model.DoingNum = DoingOrderNums[model.GoodId]; } if (caiNums.ContainsKey(model.GoodId.ToString())) { model.CaiNum = Convert.ToDecimal(caiNums[model.GoodId.ToString()]); } } } } this.gvList.DataSource = gooQGooddList; this.gvList.DataBind(); }