public bool updateTran(VAN_OA.Model.EFrom.TB_UseCarDetail 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(); Update(model, objCommand); tb_EFormService eformSer = new tb_EFormService(); eformSer.Update(eform, objCommand); tb_EFormsService eformsSer = new tb_EFormsService(); eformsSer.Add(forms, objCommand); tan.Commit(); } catch (Exception) { tan.Rollback(); return(false); } } return(true); }
public bool updateTran(VAN_OA.Model.EFrom.Tb_ProjectInv model, VAN_OA.Model.EFrom.tb_EForm eform, tb_EForms forms, List <Tb_ProjectInvs> proInvs, string IDS) { using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); SqlCommand objCommand = conn.CreateCommand(); objCommand.Transaction = tan; Tb_ProjectInvsService prosInvsSer = new Tb_ProjectInvsService(); try { objCommand.Parameters.Clear(); Update(model, objCommand); tb_EFormService eformSer = new tb_EFormService(); eformSer.Update(eform, objCommand); tb_EFormsService eformsSer = new tb_EFormsService(); eformsSer.Add(forms, objCommand); for (int i = 0; i < proInvs.Count; i++) { proInvs[i].PId = model.Id; if (proInvs[i].IfUpdate == true && proInvs[i].Id != 0) { prosInvsSer.Update(proInvs[i], objCommand); } else if (proInvs[i].Id == 0) { prosInvsSer.Add(proInvs[i], objCommand); } } if (IDS != "") { IDS = IDS.Substring(0, IDS.Length - 1); prosInvsSer.DeleteByIds(IDS, objCommand); } tan.Commit(); } catch (Exception) { tan.Rollback(); return(false); } } return(true); }
public bool updateTran(VAN_OA.Model.EFrom.tb_FundsUse 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(); 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.state == "通过") { string[] nos = model.HouseNo.Split('/'); if (nos.Length > 0) { string sql = string.Format("update CAI_OrderInHouse set FPNo='{0}' where ProNo in (", model.Invoce); foreach (var no in nos) { sql += string.Format(" '{0}',", no); } sql = sql.Substring(0, sql.Length - 1); sql += ")"; objCommand.CommandText = sql; objCommand.ExecuteNonQuery(); foreach (var no in nos) { if (no == "") { continue; } string insertRu = string.Format("insert into TB_CaiXiaoNo values ('入库','{0}')", no); objCommand.CommandText = insertRu; objCommand.ExecuteNonQuery(); } } string[] chuNo = model.ExpNo.Split('/'); foreach (var no in chuNo) { if (no == "") { continue; } string insertRu = string.Format("insert into TB_CaiXiaoNo values ('出库','{0}')", no); objCommand.CommandText = insertRu; objCommand.ExecuteNonQuery(); } } tan.Commit(); } catch (Exception) { tan.Rollback(); return(false); } } return(true); }
public bool updateTran(VAN_OA.Model.EFrom.TB_POOrder model, VAN_OA.Model.EFrom.tb_EForm eform, tb_EForms forms, List <TB_POOrders> orders, string IDS, List <TB_POCai> Cais, string CAI_IDS) { using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); SqlCommand objCommand = conn.CreateCommand(); objCommand.Transaction = tan; TB_POOrdersService OrdersSer = new TB_POOrdersService(); TB_POCaiService CaiSer = new TB_POCaiService(); try { objCommand.Parameters.Clear(); Update(model, objCommand); tb_EFormService eformSer = new tb_EFormService(); eformSer.Update(eform, objCommand); tb_EFormsService eformsSer = new tb_EFormsService(); eformsSer.Add(forms, objCommand); for (int i = 0; i < orders.Count; i++) { orders[i].Id = model.Id; //if (orders[i].IfUpdate == true && orders[i].Ids != 0) //{ OrdersSer.Update(orders[i], objCommand); //} //else if (orders[i].Ids == 0) //{ // OrdersSer.Add(orders[i], objCommand); //} } if (IDS != "") { IDS = IDS.Substring(0, IDS.Length - 1); OrdersSer.DeleteByIds(IDS, objCommand); } #region 采购 for (int i = 0; i < Cais.Count; i++) { Cais[i].Id = model.Id; if (Cais[i].IfUpdate == true && Cais[i].Ids != 0) { CaiSer.Update(Cais[i], objCommand); } else if (Cais[i].Ids == 0) { CaiSer.Add(Cais[i], objCommand); } } if (CAI_IDS != "") { CAI_IDS = CAI_IDS.Substring(0, CAI_IDS.Length - 1); CaiSer.DeleteByIds(CAI_IDS, objCommand); } #endregion tan.Commit(); } catch (Exception) { tan.Rollback(); return(false); } } return(true); }