public int PassAudit(int ViseCode, List <LocaleViseCostModel> CostList) { int num = 0; using (SqlConnection connection = new SqlConnection(FunctionRule.GetConnectionString())) { connection.Open(); SqlTransaction transaction = connection.BeginTransaction(); try { try { LocaleViseBLL ebll = new LocaleViseBLL(); foreach (LocaleViseCostModel model in CostList) { ebll.UpdateCost(model, transaction); } num = ebll.PassAudit(ViseCode, transaction); transaction.Commit(); } catch (SqlException exception) { transaction.Rollback(); connection.Close(); throw exception; } return(num); } finally { connection.Close(); } } return(num); }
public static int ViseAuditForCreateContractChange(int Code, string UserCode, List <LocaleViseCostModel> CostList) { int num = 0; DataTable table = new DataTable(); DataColumn column = new DataColumn("Code", Type.GetType("System.String")); DataColumn column2 = new DataColumn("Type", Type.GetType("System.String")); table.Columns.Add(column); table.Columns.Add(column2); DataRow row = table.NewRow(); row["Code"] = Code; row["Type"] = "Vise"; table.Rows.Add(row); using (SqlConnection connection = new SqlConnection(FunctionRule.GetConnectionString())) { connection.Open(); SqlTransaction transaction = connection.BeginTransaction(); try { try { LocaleViseBLL ebll = new LocaleViseBLL(); foreach (LocaleViseCostModel model in CostList) { ebll.UpdateCost(model, transaction); } num = ebll.PassAudit(Code, transaction); ebll.Balance(Code, transaction); string viseContractCode = ebll.GetModel(Code, transaction).ViseContractCode; if (viseContractCode != "") { ContractRule.BuildContractChangeByNexusCodeType(viseContractCode, table, transaction, UserCode); } transaction.Commit(); } catch (SqlException exception) { transaction.Rollback(); connection.Close(); throw exception; } return(num); } finally { connection.Close(); } } return(num); }