public string addCustomerAccountInfo(Customer_Account_O2M customerAccount) { SqlConnection conn = null; SqlTransaction trans = null; string returnString = IdProConstants.FAIL; Customer_Account_O2MDAO customerAccounto2mDao = new Customer_Account_O2MDAO(); long AccountID = 0; ConnectionDao ConnectionDao = new ConnectionDao(); try { conn = ConnectionDao.getConnection(); trans = conn.BeginTransaction(); returnString = customerAccounto2mDao.addCustomerAccountO2MInfo(conn, trans, customerAccount); if (!AccountID.Equals(0)) { trans.Commit(); } else { trans.Rollback(); } } catch (Exception exception) { trans.Rollback(); System.Diagnostics.Trace.WriteLine("[EmployeeServices:addEmployee] Exception " + exception.StackTrace); } finally { ConnectionDao.closeConnection(conn); } return returnString ; }
public string customeradd(customer customer1, Account account) { string str = ""; SqlConnection conn = null; SqlTransaction trans = null; string returnString = IdProConstants.SUCCESS; CustomerDAO customerdao = new CustomerDAO(); AccountDao accountdao = new AccountDao(); ConnectionDao ConnectionDao = new ConnectionDao(); Customer_Account_O2M customerAccountO2M = new Customer_Account_O2M(); Customer_Account_O2MDAO customerAccountO2Mservice = new Customer_Account_O2MDAO(); try { conn = ConnectionDao.getConnection(); trans = conn.BeginTransaction(); customerAccountO2M.CustomerID = customerdao.addCustomerBasicInfo(conn, trans, customer1); if (!customerAccountO2M.CustomerID.Equals(0)) { customerAccountO2M.AccountID = accountdao.addAccountBasicInfo(conn, trans, account); if (!customerAccountO2M.AccountID.Equals(0)) { returnString = customerAccountO2Mservice.addCustomerAccountO2MInfo(conn, trans,customerAccountO2M); } str = customer1.cofirstname; if (str != "") { customerAccountO2M.CustomerID = customerdao.addCustomerCoinfo(conn, trans, customer1); if (!customerAccountO2M.CustomerID.Equals(0)) { customerAccountO2M.AccountID = accountdao.addAccountBasicInfo(conn, trans, account); if (!customerAccountO2M.AccountID.Equals(0)) { returnString = customerAccountO2Mservice.addCustomerAccountO2MInfo(conn, trans, customerAccountO2M); } } } } if (returnString.Equals(IdProConstants.SUCCESS)) { trans.Commit(); } else { trans.Rollback(); } } catch (Exception exception) { trans.Rollback(); System.Diagnostics.Trace.WriteLine("[EmployeeServices:addEmployee] Exception " + exception.StackTrace); } finally { ConnectionDao.closeConnection(conn); } string finalreturnvalue=""; if (returnString == "Success") { finalreturnvalue = "Thanks record saved successfully"; } else { finalreturnvalue = "Sorry, Your request could not be processed. Please try after some time"; } return finalreturnvalue; }