コード例 #1
0
ファイル: CustomerDAO.cs プロジェクト: smirsingh02/idpro-1
        public long addCustomerCoinfo(SqlConnection conn, SqlTransaction trans, customer customer)
        {
            ConnectionDao connectionDao = new ConnectionDao();
             string returnString = IdProConstants.SUCCESS;
             SqlCommand cmd = null;
             SqlDataReader rs = null;
             long Customer_ID = 0;
             string query = "INSERT INTO Customer([First_name],[Last_name],[DOB],[SSN],[Customer_Type]) VALUES (@First_name,@Last_name,@DOB,@SSN,@Customer_Type);SELECT Customer_ID=scope_identity();";
             try
             {

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

                 SqlParameter param1 = new SqlParameter();
                 param1.ParameterName = "@First_name";
                 param1.Value = customer.cofirstname;
                 cmd.Parameters.Add(param1);

                 SqlParameter param2 = new SqlParameter();
                 param2.ParameterName = "@Last_name";
                 param2.Value = customer.colastname;
                 cmd.Parameters.Add(param2);

                 SqlParameter param3 = new SqlParameter();
                 param3.ParameterName = "@DOB";
                 param3.Value = customer.Codob;
                 cmd.Parameters.Add(param3);

                 SqlParameter param4 = new SqlParameter();
                 param4.ParameterName = "@SSN";
                 param4.Value = customer.cossn;
                 cmd.Parameters.Add(param4);

                 SqlParameter param16 = new SqlParameter();
                 param16.ParameterName = "@Customer_Type";
                 param16.Value = "Secondary";
                 cmd.Parameters.Add(param16);

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

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

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

               //  return returnString;

             return Customer_ID;
        }
コード例 #2
0
ファイル: CustomerDAO.cs プロジェクト: smirsingh02/idpro-1
        public long addCustomerBasicInfo(SqlConnection conn, SqlTransaction trans, customer customer)
        {
            string strdrop = "";
             ConnectionDao connectionDao = new ConnectionDao();
             string returnString = IdProConstants.SUCCESS;
             SqlCommand cmd = null;
             SqlDataReader rs = null;
             long Customer_ID = 0;
             string query = "INSERT INTO Customer([First_name],[Last_name],[DOB],[SSN],[Address],[City],[State],[zip],[Primary_email],[Secondary_Email],[phone1],[phone2],[Customer_Type]) VALUES (@First_name,@Last_name,@DOB,@SSN,@Address,@City,@State,@zip,@Primary_email,@Secondary_Email,@phone1,@phone2,@Customer_Type);SELECT Customer_ID=scope_identity();";
             try
             {
                strdrop = customer.dropphone1;
                cmd = connectionDao.getSqlCommand(query, conn, trans);

                SqlParameter param1 = new SqlParameter();
                param1.ParameterName = "@First_name";
                param1.Value = customer.firstname;
                cmd.Parameters.Add(param1);

                SqlParameter param2 = new SqlParameter();
                param2.ParameterName = "@Last_name";
                param2.Value = customer.lastname;
                cmd.Parameters.Add(param2);

                SqlParameter param3 = new SqlParameter();
                param3.ParameterName = "@SSN";
                param3.Value = customer.ssn;
                cmd.Parameters.Add(param3);

                SqlParameter param4 = new SqlParameter();
                param4.ParameterName = "@Address";
                param4.Value = customer.address1;
                cmd.Parameters.Add(param4);

                SqlParameter param5 = new SqlParameter();
                param5.ParameterName = "@City";
                param5.Value = customer.city;
                cmd.Parameters.Add(param5);

                SqlParameter param6 = new SqlParameter();
                param6.ParameterName = "@State";
                param6.Value = customer.states;
                cmd.Parameters.Add(param6);

                SqlParameter param7 = new SqlParameter();
                param7.ParameterName = "@zip";
                param7.Value = customer.zip;
                cmd.Parameters.Add(param7);

                SqlParameter param9 = new SqlParameter();
                param9.ParameterName = "@Primary_email";
                param9.Value = customer.primaryemail;
                cmd.Parameters.Add(param9);

                SqlParameter param10 = new SqlParameter();
                param10.ParameterName = "@Secondary_Email";
                param10.Value = customer.secondaryemail;
                cmd.Parameters.Add(param10);

                    SqlParameter param11 = new SqlParameter();
                    param11.ParameterName = "@phone1";
                    param11.Value = customer.phone1;
                    cmd.Parameters.Add(param11);

                    SqlParameter param12 = new SqlParameter();
                    param12.ParameterName = "@phone2";
                    param12.Value = customer.phone2;
                    cmd.Parameters.Add(param12);

                SqlParameter param16 = new SqlParameter();
                param16.ParameterName = "@Customer_Type";
                param16.Value = "primary";
                cmd.Parameters.Add(param16);

                SqlParameter param17 = new SqlParameter();
                param17.ParameterName = "@DOB";
                param17.Value = customer.dob;
                cmd.Parameters.Add(param17);

                rs = cmd.ExecuteReader();
                if (rs.Read())
                {
                    Customer_ID = Int32.Parse(rs["Customer_ID"].ToString());
                }
                //while (rs.Read())
                //{
                //    customerNumber = Int32.Parse(rs["Customer_ID"].ToString());
                //}

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

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

             return Customer_ID;
        }
コード例 #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;
        }