protected void Button1_Click(object sender, EventArgs e) { int id = AddCai(); CAI_POOrderService mainSer = new CAI_POOrderService(); CAI_POOrder pp = mainSer.GetModel(id); CAI_POOrdersService ordersSer = new CAI_POOrdersService(); List <CAI_POOrders> orders = ordersSer.GetListArray(" 1=1 and CAI_POOrders.id=" + id); CAI_POCaiService CaiSer = new CAI_POCaiService(); List <CAI_POCai> caiList = CaiSer.GetListArray(" 1=1 and CAI_POCai.id=" + id); foreach (var cai in caiList) { var m = orders_CaiIn.Single(t => t.GooId == cai.GoodId); cai.Supplier = "本部门(含税)"; cai.SupperPrice = m.GoodPrice; cai.UpdateUser = "******"; cai.Idea = ""; cai.Num = m.GoodNum; cai.FinPrice1 = m.GoodPrice; cai.GoodId = m.GooId; cai.cbifDefault1 = true; cai.lastSupplier = "本部门(含税)"; cai.IsHanShui = true; cai.LastTruePrice = m.GoodPrice; cai.IfUpdate = true; } CAI_POOrderService POOrderSer = new CAI_POOrderService(); POOrderSer.UpdataCai(caiList); int checkId = AddCAI_OrderCheck(id); LastUpdate(checkId); base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('成功!');</script>"); }
protected void gvMain_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "select") { List <CAI_POOrders> orders = ordersSer.GetListArray(" 1=1 and Cai_POOrders.id=" + e.CommandArgument); ViewState["Orders"] = orders; gvList.DataSource = orders; gvList.DataBind(); List <CAI_POCai> caiList = CaiSer.GetListArray(" 1=1 and Cai_POCai.id=" + e.CommandArgument); gvCai.DataSource = caiList; gvCai.DataBind(); } else if (e.CommandName == "Copy")//复制 { //是否是此单据的申请人 var model = POSer.GetModel(Convert.ToInt32(e.CommandArgument)); if (model != null && model.Status == "不通过") { } else { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('此单据必须已经审批‘不通过’才能复制!');</script>"); return; } string url = "~/JXC/CAI_Order.aspx?ProId=20&Id=" + e.CommandArgument + "&&Copy=true"; Response.Redirect(url); } else if (e.CommandName == "ReEdit") { //是否是此单据的申请人 var model = POSer.GetModel(Convert.ToInt32(e.CommandArgument)); if (Session["currentUserId"].ToString() != model.AppName.ToString()) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('必须由原单据申请人 重新发起,其他人不能重新提交编辑!');</script>"); return; } //首先单子要先通过 if (model != null && model.Status == "通过") { } else { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('此单据必须已经审批通过才能重新编辑!');</script>"); return; } string check = string.Format("select count(*) from CAI_OrderChecks left join CAI_OrderCheck on CAI_OrderChecks.CheckId=CAI_OrderCheck.Id where Status in ('通过','执行中') and caiProNo='{0}' ", model.ProNo); if (Convert.ToInt32(DBHelp.ExeScalar(check)) > 0) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('此单据已经被检验单使用!');</script>"); return; } check = string.Format(@"select count(*) from TB_SupplierAdvancePayments left join TB_SupplierAdvancePayment on TB_SupplierAdvancePayments.Id=TB_SupplierAdvancePayment.Id where caiIds in (select Ids from CAI_POCai where ID={0}) and Status<>'不通过'", model.Id); if (Convert.ToInt32(DBHelp.ExeScalar(check)) > 0) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('此单据已经被预付款单使用!');</script>"); return; } //判断当前采购信息有没有‘库存’的信息,按照 库存+项目编号+商品Id来判断 商品有没有入库 如果入库不可以编辑 check = string.Format(@"select COUNT(*) from CAI_POOrder left join CAI_POCai on CAI_POOrder.Id=CAI_POCai.Id where CAI_POCai.lastSupplier='库存' and GoodId in (select Sell_OrderOutHouses.GooId from Sell_OrderOutHouse left join Sell_OrderOutHouses on Sell_OrderOutHouse.Id=Sell_OrderOutHouses.id where Status<>'不通过' and POno='{0}') and Status='通过' and CAI_POOrder.Id={1}", model.PONo, model.Id); if (Convert.ToInt32(DBHelp.ExeScalar(check)) > 0) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('此订单已出库,无法重新编辑!');</script>"); return; } string sql = "select pro_Id from A_ProInfo where pro_Type='采购订单'"; string efromId = string.Format("select id from tb_EForm where alle_id={0} and proId=(select pro_Id from A_ProInfo where pro_Type='采购订单')", e.CommandArgument); string url = "~/JXC/CAI_Order.aspx?ProId=" + DBHelp.ExeScalar(sql) + "&allE_id=" + e.CommandArgument + "&EForm_Id=" + DBHelp.ExeScalar(efromId) + "&&ReAudit=true"; Response.Redirect(url); //没有做过检验单 } }