Beispiel #1
0
 public long addaccount(Account account)
 {
     SqlConnection conn = null;
     SqlTransaction trans = null;
     AccountDao accountDao = new AccountDao();
     long AccountID = 0;
     ConnectionDao ConnectionDao = new ConnectionDao();
     try
     {
         conn = ConnectionDao.getConnection();
         trans = conn.BeginTransaction();
         AccountID = accountDao.addAccountBasicInfo(conn, trans, account);
         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 AccountID;
 }
Beispiel #2
0
        public long addAccountBasicInfo(SqlConnection conn, SqlTransaction trans, Account account)
        {
            ConnectionDao connectionDao = new ConnectionDao();
            SqlCommand cmd = null;
            SqlDataReader rs = null;
            int AccountID = 0;
            string query = "INSERT INTO account([Status],[Added_By],[Added_Date]) VALUES (@Status,@Added_By,@Added_Date);SELECT Account_ID=scope_identity();";
            try
            {

                cmd = connectionDao.getSqlCommand(query, conn, trans);

                SqlParameter param1 = new SqlParameter();
                param1.ParameterName = "@Status";
                param1.Value = "Active";
                cmd.Parameters.Add(param1);

                SqlParameter param2 = new SqlParameter();
                param2.ParameterName = "@Added_By";
                param2.Value = HttpContext .Current.Session["username"];
                cmd.Parameters.Add(param2);

                SqlParameter param3 = new SqlParameter();
                param3.ParameterName = "@Added_Date";
                param3.Value = System.DateTime.Now;
                cmd.Parameters.Add(param3);

                rs = cmd.ExecuteReader();
                if (rs.Read())
                {
                    AccountID = Int32.Parse(rs["Account_ID"].ToString());
                }

            }
            catch (Exception exception)
            {
                System.Diagnostics.Trace.WriteLine("[CustomerDAO:addCustomerBasicInfo] Exception " + exception.StackTrace);

            }
            finally
            {
                connectionDao.closeDabaseEntities(cmd, rs);
            }

            return AccountID;
        }
Beispiel #3
0
        public int getNumberOfCustomerBySSN(string ssn)
        {
            ConnectionDao connectionDao = new ConnectionDao();
            Account account = new Account();

            SqlCommand cmd = null;
            SqlConnection conn = null;
            SqlDataReader rs = null;

            int count = 0;

            string query = "select count(*) as count from customer where ssn=@ssn";

            try
            {
                conn = connectionDao.getConnection();
                cmd = connectionDao.getSqlCommandWithoutTransaction(query, conn);

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

                rs = cmd.ExecuteReader();

                if (rs.Read())
                {
                    count = Int32.Parse(rs["count"].ToString());
                }

            }
            catch (Exception exception)
            {
                System.Diagnostics.Trace.WriteLine("[CustomerDAO:getNumberOfCustomerBySSN] Exception " + exception.StackTrace);

            }
            finally
            {
                connectionDao.closeConnection(conn);
                connectionDao.closeDabaseEntities(cmd, rs);
            }

            return count;
        }
        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;
        }