public bool updateTran(TB_ToInvoice model, VAN_OA.Model.EFrom.tb_EForm eform, tb_EForms forms) { using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); SqlCommand objCommand = conn.CreateCommand(); objCommand.Transaction = tan; try { model.State = eform.state; objCommand.Parameters.Clear(); model.UpAccount = accountXishu(model, eform, objCommand); Update(model, objCommand); tb_EFormService eformSer = new tb_EFormService(); eformSer.Update(eform, objCommand); tb_EFormsService eformsSer = new tb_EFormsService(); eformsSer.Add(forms, objCommand); //判断是否是删除 -到款单删除 if (eform.proId == 38 && eform.state == "通过") { //及到款单删除会有两个层面, //1,预付款模式,这时只需要在审批的最后一个流程总经理点确定时,删除相应的到款单;并弹出一个提示框,该预付到款单已删除,点确定,完成。 //2,发票到款模式,我们需要在最后一个审批流程点确定时,删除相应项目编号针对该发票号的发票签回单(如果有在审批执行中或已完成审批的),再删除该项目编号针对该发票号的到款单, //并弹出一个提示框,该发票到款单已删除,点确定,完成。 if (model.BusType == 0)//实际发票到款 { //删除发票签回单(如果有) string deleteFPBack = string.Format("delete tb_EForms where e_Id in (select id from tb_EForm where proId=29 and allE_id in (select id from Sell_OrderFPBack where PId={0}));", model.FPId); deleteFPBack += string.Format("delete tb_EForm where proId=29 and allE_id in (select id from Sell_OrderFPBack where PId={0});", model.FPId); deleteFPBack += string.Format("delete Sell_OrderFPBacks where Id in (select id from Sell_OrderFPBack where PId={0});delete Sell_OrderFPBack where PId={0};", model.FPId); objCommand.CommandText = deleteFPBack; objCommand.ExecuteNonQuery(); } //删除发票删除单 审批流 string deleteFPDelete = string.Format("delete tb_EForms where e_Id in (select id from tb_EForm where proId in (26,34,37) and allE_id={0});", model.Id); deleteFPDelete += string.Format("delete tb_EForm where proId in (27,38) and allE_id={0};", model.Id); objCommand.CommandText = deleteFPDelete; objCommand.ExecuteNonQuery(); string DeleteAll = string.Format("delete from [TB_ToInvoice] where id={0};", model.Id); objCommand.CommandText = DeleteAll; objCommand.ExecuteNonQuery(); } tan.Commit(); } catch (Exception) { tan.Rollback(); return(false); } } return(true); }
public bool updateTran(VAN_OA.Model.JXC.Sell_OrderOutHouseBack model, VAN_OA.Model.EFrom.tb_EForm eform, tb_EForms forms, List <Sell_OrderOutHouseBacks> orders, string IDS) { decimal total = 0; for (int i = 0; i < orders.Count; i++) { total += orders[i].GoodSellPriceTotal; } model.SellTotal = total; using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); SqlCommand objCommand = conn.CreateCommand(); objCommand.Transaction = tan; Sell_OrderOutHouseBacksService OrdersSer = new Sell_OrderOutHouseBacksService(); try { objCommand.Parameters.Clear(); model.Status = eform.state; Update(model, objCommand); tb_EFormService eformSer = new tb_EFormService(); eformSer.Update(eform, objCommand); tb_EFormsService eformsSer = new tb_EFormsService(); eformsSer.Add(forms, objCommand); //====删除所有子单据 string delete = "delete from Sell_OrderOutHouseBacks where id=" + model.Id; objCommand.CommandText = delete; objCommand.ExecuteNonQuery(); //==== for (int i = 0; i < orders.Count; i++) { orders[i].id = model.Id; OrdersSer.Add(orders[i], objCommand); } tan.Commit(); } catch (Exception) { tan.Rollback(); return(false); } } return(true); }
public bool updateTran(VAN_OA.Model.JXC.CAI_OrderCheck model, VAN_OA.Model.EFrom.tb_EForm eform, tb_EForms forms, List <CAI_OrderChecks> orders, string IDS) { using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); SqlCommand objCommand = conn.CreateCommand(); objCommand.Transaction = tan; CG_POOrdersService OrdersSer = new CG_POOrdersService(); CG_POCaiService CaiSer = new CG_POCaiService(); try { objCommand.Parameters.Clear(); model.Status = eform.state; Update(model, objCommand); tb_EFormService eformSer = new tb_EFormService(); eformSer.Update(eform, objCommand); tb_EFormsService eformsSer = new tb_EFormsService(); eformsSer.Add(forms, objCommand); CAI_OrderChecksService myOrderChecks = new CAI_OrderChecksService(); for (int i = 0; i < orders.Count; i++) { // orders[i].CheckId = model.Id; //if (orders[i].IfUpdate == true && orders[i].Ids != 0) //{ myOrderChecks.Update(orders[i], objCommand); //} //else if (orders[i].Ids == 0) //{ // OrdersSer.Add(orders[i], objCommand); //} } //入库 if (eform.state == "通过") { tb_EForm eformMain = new tb_EForm(); int proId = 0; string sql = "select Pro_Id from A_ProInfo where pro_Type='采购入库'"; objCommand.CommandText = sql; proId = Convert.ToInt32(objCommand.ExecuteScalar()); eformMain.appPer = eform.appPer; eformMain.appTime = DateTime.Now; eformMain.createPer = eform.appPer; eformMain.createTime = DateTime.Now; eformMain.proId = proId; eformMain.state = "通过"; eformMain.toPer = 0; eformMain.toProsId = 0; CAI_OrderInHouseService orderInHouse = new CAI_OrderInHouseService(); sql = "select top 1 id from TB_HouseInfo where ifdefault=1 "; objCommand.CommandText = sql; int objhouseId = Convert.ToInt32(objCommand.ExecuteScalar()); CAI_OrderInHouse orderInModel = new CAI_OrderInHouse() { ChcekProNo = model.ProNo, CreateTime = DateTime.Now, CreateUserId = eform.appPer, GuestName = orders[0].GuestName, HouseID = objhouseId, POName = orders[0].POName, PONo = orders[0].PONo, RuTime = DateTime.Now, Status = "通过", Supplier = orders[0].SupplierName, DoPer = orders[0].CaiGouPer, DaiLi = orders[0].CaiGouPer, FPNo = "", Remark = "" }; List <CAI_OrderInHouses> ordersInHouses = new List <CAI_OrderInHouses>(); foreach (var m in orders) { CAI_OrderInHouses orderM = new CAI_OrderInHouses() { GooId = m.CheckGoodId, GoodNum = m.CheckNum, GoodPrice = m.CheckPrice, OrderCheckIds = m.Ids, QingGouPer = m.QingGou, CaiLastTruePrice = m.CheckLastTruePrice }; ordersInHouses.Add(orderM); } orderInHouse.addTran(orderInModel, eformMain, ordersInHouses, objCommand); } tan.Commit(); } catch (Exception) { tan.Rollback(); return(false); } } return(true); }