Exemple #1
0
        public Boolean Insert(AddressENT entAddress)
        {
            using (SqlConnection objConn = new SqlConnection(ConnectionString))
            {
                objConn.Open();

                using (SqlCommand objCmd = objConn.CreateCommand())
                {
                    try
                    {
                        #region Prepare Command
                        objCmd.CommandType = CommandType.StoredProcedure;
                        objCmd.CommandText = "PR_Address_Insert";
                        objCmd.Parameters.Add("@AddressID", SqlDbType.Int, 4).Direction = ParameterDirection.Output;
                        objCmd.Parameters.Add("@UserID", SqlDbType.Int).Value           = entAddress.UserID;
                        objCmd.Parameters.Add("@FullName", SqlDbType.VarChar).Value     = entAddress.FullName;
                        objCmd.Parameters.Add("@StateID", SqlDbType.Int).Value          = entAddress.StateID;
                        objCmd.Parameters.Add("@CityID", SqlDbType.Int).Value           = entAddress.CityID;
                        objCmd.Parameters.Add("@Address1", SqlDbType.VarChar).Value     = entAddress.Address1;
                        objCmd.Parameters.Add("@Address2", SqlDbType.VarChar).Value     = entAddress.Address2;
                        objCmd.Parameters.Add("@Postcode", SqlDbType.Int).Value         = entAddress.Postcode;
                        objCmd.Parameters.Add("@MobileNo", SqlDbType.VarChar).Value     = entAddress.MobileNo;
                        #endregion Prepare Command

                        objCmd.ExecuteNonQuery();

                        if (objCmd.Parameters["@AddressID"] != null)
                        {
                            entAddress.AddressID = Convert.ToInt32(objCmd.Parameters["@AddressID"].Value);
                        }

                        return(true);
                    }
                    catch (SqlException sqlex)
                    {
                        Message = sqlex.InnerException.Message.ToString();
                        return(false);
                    }
                    catch (Exception ex)
                    {
                        Message = ex.InnerException.Message.ToString();
                        return(false);
                    }
                    finally
                    {
                        if (objConn.State == ConnectionState.Open)
                        {
                            objConn.Close();
                        }
                    }
                }
            }
        }
Exemple #2
0
        public AddressENT GetAddressIDByUserID(SqlInt32 UserID)
        {
            using (SqlConnection objConn = new SqlConnection(ConnectionString))
            {
                objConn.Open();

                using (SqlCommand objCmd = objConn.CreateCommand())
                {
                    try
                    {
                        #region Prepare Command
                        objCmd.CommandType = CommandType.StoredProcedure;
                        objCmd.CommandText = "PR_Address_GetAddressIDByUserID";
                        objCmd.Parameters.AddWithValue("@UserID", UserID);
                        #endregion Prepare Command

                        #region ReadData and Set Controls
                        AddressENT entAddress = new AddressENT();
                        using (SqlDataReader objSDR = objCmd.ExecuteReader())
                        {
                            while (objSDR.Read())
                            {
                                if (!objSDR["AddressID"].Equals(DBNull.Value))
                                {
                                    entAddress.AddressID = Convert.ToInt32(objSDR["AddressID"]);
                                }
                            }
                        }
                        return(entAddress);

                        #endregion ReadData and Set Controls
                    }
                    catch (SqlException sqlex)
                    {
                        Message = sqlex.InnerException.Message.ToString();
                        return(null);
                    }
                    catch (Exception ex)
                    {
                        Message = ex.InnerException.Message.ToString();
                        return(null);
                    }
                    finally
                    {
                        if (objConn.State == ConnectionState.Open)
                        {
                            objConn.Close();
                        }
                    }
                }
            }
        }
Exemple #3
0
        public Boolean Update(AddressENT entAddress, SqlInt32 AddressID, SqlInt32 UserID)
        {
            AddressDAL dalAddress = new AddressDAL();

            if (dalAddress.Update(entAddress, AddressID, UserID))
            {
                return(true);
            }
            else
            {
                Message = dalAddress.Message;
                return(false);
            }
        }
Exemple #4
0
        public Boolean Insert(AddressENT entAddress)
        {
            AddressDAL dalAddress = new AddressDAL();

            if (dalAddress.Insert(entAddress))
            {
                return(true);
            }
            else
            {
                Message = dalAddress.Message;
                return(false);
            }
        }
Exemple #5
0
        public Boolean Update(AddressENT entAddress, SqlInt32 AddressID, SqlInt32 UserID)
        {
            using (SqlConnection objConn = new SqlConnection(ConnectionString))
            {
                objConn.Open();

                using (SqlCommand objCmd = objConn.CreateCommand())
                {
                    try
                    {
                        #region Prepare Command
                        objCmd.CommandType = CommandType.StoredProcedure;
                        objCmd.CommandText = "PR_Address_Update";
                        objCmd.Parameters.AddWithValue("@AddressID", AddressID);
                        objCmd.Parameters.AddWithValue("@UserID", UserID);
                        objCmd.Parameters.AddWithValue("@FullName", entAddress.FullName);
                        objCmd.Parameters.AddWithValue("@StateID", entAddress.StateID);
                        objCmd.Parameters.AddWithValue("@CityID", entAddress.CityID);
                        objCmd.Parameters.AddWithValue("@Address1", entAddress.Address1);
                        objCmd.Parameters.AddWithValue("@Address2", entAddress.Address2);
                        objCmd.Parameters.AddWithValue("@Postcode", entAddress.Postcode);
                        objCmd.Parameters.AddWithValue("@MobileNo", entAddress.MobileNo);
                        #endregion Prepare Command

                        objCmd.ExecuteNonQuery();

                        return(true);
                    }
                    catch (SqlException sqlex)
                    {
                        Message = sqlex.InnerException.Message.ToString();
                        return(false);
                    }
                    catch (Exception ex)
                    {
                        Message = ex.InnerException.Message.ToString();
                        return(false);
                    }
                    finally
                    {
                        if (objConn.State == ConnectionState.Open)
                        {
                            objConn.Close();
                        }
                    }
                }
            }
        }
Exemple #6
0
    private void FilAddressDetails()
    {
        AddressBAL balAddress = new AddressBAL();
        AddressENT entAddress = new AddressENT();

        entAddress = balAddress.SelectByPK(Convert.ToInt32(Session["AddressID"]), Convert.ToInt32(Session["UserID"]));

        if (!entAddress.FullName.IsNull)
        {
            txtFullName.Text = entAddress.FullName.Value;
        }

        if (!entAddress.StateID.IsNull)
        {
            ddlState.SelectedValue = entAddress.StateID.Value.ToString();
        }

        if (!entAddress.CityID.IsNull)
        {
            ddlCity.SelectedValue = entAddress.CityID.Value.ToString();
            CommonFillMethods.FillDropDownListCityByStateID(ddlCity, entAddress.StateID);
        }

        if (!entAddress.Address1.IsNull)
        {
            txtAddressLine1.Text = entAddress.Address1.Value;
        }

        if (!entAddress.Address2.IsNull)
        {
            txtAddressLine2.Text = entAddress.Address2.Value;
        }

        if (!entAddress.Postcode.IsNull)
        {
            txtPostCode.Text = entAddress.Postcode.Value.ToString();
        }

        if (!entAddress.MobileNo.IsNull)
        {
            txtMobileNo.Text = entAddress.MobileNo.Value;
        }
    }
Exemple #7
0
    protected void btnNext_Click(object sender, EventArgs e)
    {
        #region ServerSide Validation

        String strErrorMessage = "";

        if (txtFullName.Text == "")
        {
            strErrorMessage += "Enter Full Name<br/>";
        }

        if (ddlState.SelectedIndex <= 0)
        {
            strErrorMessage += "Select State<br/>";
        }

        if (ddlCity.SelectedIndex <= 0)
        {
            strErrorMessage += "Select City<br/>";
        }

        if (txtAddressLine1.Text == "")
        {
            strErrorMessage += "Enter AddressLine 1<br/>";
        }

        if (txtMobileNo.Text == "")
        {
            strErrorMessage += "Enter Mobile No.<br/>";
        }

        if (strErrorMessage != "")
        {
            lblMessage.Text    = strErrorMessage;
            divMessage.Visible = true;
            return;
        }
        #endregion ServerSide Validation

        #region Collect Form Data
        AddressENT entAddress = new AddressENT();

        if (Session["UserID"] != null)
        {
            entAddress.UserID = Convert.ToInt32(Session["UserID"]);
        }

        if (txtFullName.Text != "")
        {
            entAddress.FullName = txtFullName.Text.Trim();
        }

        if (ddlState.SelectedIndex > 0)
        {
            entAddress.StateID = Convert.ToInt32(ddlState.SelectedValue.ToString());
        }

        if (ddlCity.SelectedIndex > 0)
        {
            entAddress.CityID = Convert.ToInt32(ddlCity.SelectedValue.ToString());
        }

        if (txtAddressLine1.Text != "")
        {
            entAddress.Address1 = txtAddressLine1.Text.Trim();
        }

        if (txtAddressLine2.Text != "")
        {
            entAddress.Address2 = txtAddressLine2.Text.Trim();
        }

        if (txtPostCode.Text != "")
        {
            entAddress.Postcode = Convert.ToInt32(txtPostCode.Text.Trim());
        }

        if (txtMobileNo.Text != "")
        {
            entAddress.MobileNo = txtMobileNo.Text.Trim();
        }

        #endregion Collect Form Data
        AddressBAL balAddress = new AddressBAL();
        if (Session["AddressID"] == null)
        {
            if (balAddress.Insert(entAddress))
            {
                Session["AddressID"] = entAddress.AddressID.Value;
                ClearControls();
            }
            else
            {
                lblMessage.Text    = balAddress.Message;
                divMessage.Visible = true;
            }
        }
        else
        {
            entAddress.AddressID = Convert.ToInt32(Session["AddressID"]);
            if (balAddress.Update(entAddress, entAddress.AddressID, entAddress.UserID))
            {
                ClearControls();
                Response.Redirect("~/User/Order.aspx");
            }
            else
            {
                lblMessage.Text    = balAddress.Message;
                divMessage.Visible = true;
            }
        }
    }
Exemple #8
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        #region ServerSide Validatiion
        String strErrorMessage = "";

        if (txtUserName.Text == "")
        {
            strErrorMessage += "Enter User Name<br/>";
        }

        if (txtPassword.Text == "")
        {
            strErrorMessage += "Enter Password<br/>";
        }

        if (strErrorMessage != "")
        {
            lblMessage.Text    = strErrorMessage;
            divMessage.Visible = true;
            return;
        }
        #endregion ServerSide Validatiion

        #region Collect Data
        String UserName = txtUserName.Text.ToString();
        String Password = txtPassword.Text.ToString();

        UserENT entUser = new UserENT();
        UserBAL balUser = new UserBAL();

        entUser = balUser.SelectByUserPassword(UserName, Password);

        if (!entUser.UserID.IsNull)
        {
            Session["UserID"] = entUser.UserID.Value.ToString();
        }

        if (!entUser.UserName.IsNull)
        {
            Session["UserName"] = entUser.UserName.Value.ToString();
        }

        if (!entUser.UserID.IsNull)
        {
            #region Get AddressID
            AddressENT entAddress = new AddressENT();
            AddressBAL balAddress = new AddressBAL();

            entAddress = balAddress.GetAddressIDByUserID(entUser.UserID.Value);

            if (!entAddress.AddressID.IsNull)
            {
                Session["AddressID"] = entAddress.AddressID.Value;
            }

            #endregion Get AddressID
        }

        if (!entUser.UserID.IsNull)
        {
            if (entUser.UserType == "user")
            {
                Response.Redirect("~/User/Home.aspx");
            }

            else
            {
                Response.Redirect("~/AdminPanel/Product/ProductList.aspx");
            }
        }

        else
        {
            lblMessage.Text    = "Enter Valid Name or Password";
            divMessage.Visible = true;
        }

        #endregion Collect Data
    }