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 addCustomerAccountO2MInfo(SqlConnection conn, SqlTransaction trans, Customer_Account_O2M  customerAccount)
        {
            ConnectionDao ConnectionDao = new ConnectionDao();
            string returnString = IdProConstants.SUCCESS;
            SqlCommand cmd = null;
            SqlDataReader rs = null;
            //string query = "INSERT INTO Employees([FIRST_NAME],[LAST_NAME],[EMAIL],[USERNAME],[STATUS],[ADDED_BY],[ADDED_DATE],[LAST_UPDATED_BY],[LAST_UPDATED_DATE]) VALUES(@FIRST_NAME,@LAST_NAME,@EMAIL,@USERNAME,@STATUS,@ADDED_BY,@ADDED_DATE,@LAST_UPDATED_BY,@LAST_UPDATED_DATE)";
            string query = "INSERT INTO Customer_Account_O2M([Account_ID],[Customer_ID]) VALUES(@AccountID,@CustomerID)";
            // string query = "INSERT INTO Employees([FIRST_NAME],[LAST_NAME],[EMAIL],[USERNAME],[STATUS],[Department],[Title],[ADDED_BY],[ADDED_DATE]) VALUES('" + employee.FirstName + "','" + employee.LastName + "','" + employee.Email + "','" + employee.Username + "','A','" + employee.department + "','" + employee.title + "','121',getdate())";
            try
            {
                cmd = ConnectionDao.getSqlCommand(query, conn, trans);

                SqlParameter param1 = new SqlParameter();
                param1.ParameterName = "@AccountID";
                param1.Value = customerAccount.AccountID;
                cmd.Parameters.Add(param1);

                SqlParameter param2 = new SqlParameter();
                param2.ParameterName = "@CustomerID";
                param2.Value = customerAccount.CustomerID;
                cmd.Parameters.Add(param2);

                cmd.ExecuteNonQuery();

            }
            catch (Exception exception)
            {
                System.Diagnostics.Trace.WriteLine("[EmployeeDAO:addEmployee] Exception " + exception.StackTrace);
                returnString = IdProConstants.FAIL;
            }
            finally
            {
                ConnectionDao.closeDabaseEntities(cmd, rs);
            }

            return returnString;
        }
Esempio n. 3
0
        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;
        }