public bool UpdataCai(List <CAI_POCai> Cais) { using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); SqlCommand objCommand = conn.CreateCommand(); objCommand.Transaction = tan; CAI_POCaiService CaiSer = new CAI_POCaiService(); try { objCommand.Parameters.Clear(); #region 采购 for (int i = 0; i < Cais.Count; i++) { 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); } } #endregion tan.Commit(); } catch (Exception) { tan.Rollback(); return(false); } } return(true); }
public bool updateTran(VAN_OA.Model.JXC.CAI_POOrder model, VAN_OA.Model.EFrom.tb_EForm eform, tb_EForms forms, List <CAI_POOrders> orders, string IDS, List <CAI_POCai> Cais, string CAI_IDS) { using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); SqlCommand objCommand = conn.CreateCommand(); objCommand.Transaction = tan; CAI_POOrdersService OrdersSer = new CAI_POOrdersService(); CAI_POCaiService CaiSer = new CAI_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); //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); }