Exemple #1
0
        public Boolean Insert(CustomerENT entCustomer)
        {
            CustomerDAL CustomerDAL = new CustomerDAL();

            if (CustomerDAL.Insert(entCustomer))
            {
                return(true);
            }
            else
            {
                this.Message = CustomerDAL.Message;
                return(false);
            }
        }
Exemple #2
0
        public Boolean Update(CustomerENT entCustomer)
        {
            CustomerDAL customerDAL = new CustomerDAL();

            if (customerDAL.Update(entCustomer))
            {
                return(true);
            }
            else
            {
                this.Message = customerDAL.Message;
                return(false);
            }
        }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        #region ServerSide Validation


        #endregion ServerSide Validations

        CustomerENT entCustomer = new CustomerENT();
        CustomerBAL balCustomer = new CustomerBAL();

        #region Gather Data

        if (txtCustomerName.Text.Trim() != String.Empty)
        {
            entCustomer.CustomerName = txtCustomerName.Text.Trim();
        }
        if (txtEmailAddress.Text.Trim() != String.Empty)
        {
            entCustomer.EmailID = txtEmailAddress.Text.Trim();
        }
        if (txtMobileNo.Text.Trim() != String.Empty)
        {
            entCustomer.MobileNo = txtMobileNo.Text.Trim();
        }
        if (txtAddress.Text.Trim() != String.Empty)
        {
            entCustomer.Address = txtAddress.Text.Trim();
        }

        entCustomer.CreationDate = DateTime.Now;

        entCustomer.UserID = Convert.ToInt32(Session["UserID"]);

        if (Request.QueryString["CustomerID"] == null)
        {
            balCustomer.Insert(entCustomer);
            lblMessage.Text = "Data Insert SuccessFully";
            ClearControl();
        }
        else
        {
            entCustomer.CustomerID = Convert.ToInt32(Request.QueryString["CustomerID"]);
            balCustomer.Update(entCustomer);
            Response.Redirect("~/AdminPanel/Customer/CustomerList.aspx");
        }

        #endregion Gather Data
    }
Exemple #4
0
        public Boolean Update(CustomerENT entCustomer)
        {
            using (SqlConnection objConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand objcmd = objConnection.CreateCommand())
                {
                    try
                    {
                        objConnection.Open();

                        #region Prepare Command
                        objcmd.CommandType = CommandType.StoredProcedure;
                        objcmd.CommandText = "PR_Customer_UpdateByPK";
                        objcmd.Parameters.AddWithValue("@CustomerID", entCustomer.CustomerID);
                        objcmd.Parameters.AddWithValue("@CustomerName", entCustomer.CustomerName);
                        objcmd.Parameters.AddWithValue("@Address", entCustomer.Address);
                        objcmd.Parameters.AddWithValue("@EmailID", entCustomer.EmailID);
                        objcmd.Parameters.AddWithValue("@MobileNo", entCustomer.MobileNo);
                        objcmd.Parameters.AddWithValue("@UserID", entCustomer.UserID);

                        #endregion Prepare Command

                        #region ReadData And SetData
                        objcmd.ExecuteNonQuery();
                        return(true);

                        #endregion ReadData And SetData
                    }
                    catch (SqlException Sqlex)
                    {
                        Message = Sqlex.Message.ToString();
                        return(false);
                    }
                    catch (Exception ex)
                    {
                        Message = ex.Message.ToString();
                        return(false);
                    }
                    finally
                    {
                        if (objConnection.State == ConnectionState.Open)
                        {
                            objConnection.Close();
                        }
                    }
                }
            }
        }
    private void LoadControls(SqlInt32 CustomerID)
    {
        CustomerENT entCustomer = new CustomerENT();
        CustomerBAL balCustomer = new CustomerBAL();

        entCustomer = balCustomer.SelectByPK(CustomerID);

        if (!entCustomer.CustomerName.IsNull)
        {
            txtCustomerName.Text = entCustomer.CustomerName.Value.ToString();
        }

        if (!entCustomer.MobileNo.IsNull)
        {
            txtMobileNo.Text = entCustomer.MobileNo.Value.ToString();
        }

        if (!entCustomer.Address.IsNull)
        {
            txtCustomerAddress.Text = entCustomer.Address.Value.ToString();
        }

        if (!entCustomer.BranchID.IsNull)
        {
            ddlBranchID.SelectedValue = entCustomer.BranchID.Value.ToString();
        }

        if (!entCustomer.DistributorID.IsNull)
        {
            ddlDistributorID.SelectedValue = entCustomer.DistributorID.Value.ToString();
        }

        if (!entCustomer.ProductID.IsNull)
        {
            ddlProductID.SelectedValue = entCustomer.ProductID.Value.ToString();
        }

        if (!entCustomer.Quantity.IsNull)
        {
            txtQuantity.Text = entCustomer.Quantity.Value.ToString();
        }

        if (!entCustomer.BottlePrice.IsNull)
        {
            txtAmount.Text = entCustomer.BottlePrice.Value.ToString();
        }
    }
    public void ddlProduct_SelectedIndexChanged(object sender, EventArgs e)
    {
        CustomerENT entCustomer = new CustomerENT();
        CustomerBAL balCustomer = new CustomerBAL();

        if (ddlProductID.SelectedIndex > 0)
        {
            DataTable dt = balCustomer.SelectProductAmount(Convert.ToInt32(ddlProductID.SelectedValue));

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if (!dr["BottlePrice"].Equals(DBNull.Value))
                    {
                        txtAmount.Text = Convert.ToDecimal(dr["BottlePrice"]).ToString();
                    }
                }
            }
        }
    }
    private void LoadControls(SqlInt32 CustomerID)
    {
        CustomerENT entCustomer = new CustomerENT();
        CustomerBAL balCustomer = new CustomerBAL();

        entCustomer = balCustomer.SelectByPK(CustomerID);

        if (!entCustomer.CustomerName.IsNull)
        {
            txtCustomerName.Text = entCustomer.CustomerName.Value.ToString();
        }
        if (!entCustomer.EmailID.IsNull)
        {
            txtEmailAddress.Text = entCustomer.EmailID.Value.ToString();
        }
        if (!entCustomer.MobileNo.IsNull)
        {
            txtMobileNo.Text = entCustomer.MobileNo.Value.ToString();
        }
        if (!entCustomer.Address.IsNull)
        {
            txtAddress.Text = entCustomer.Address.Value.ToString();
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            #region Server Side Validation

            String strError = String.Empty;

            if (txtCustomerName.Text.Trim() == String.Empty)
            {
                strError += "- Enter Customer Name<br />";
            }

            if (txtMobileNo.Text.Trim() == String.Empty)
            {
                strError += "- Enter Mobile No<br />";
            }

            if (txtCustomerAddress.Text.Trim() == String.Empty)
            {
                strError += "- Enter Customer Address<br />";
            }

            if (ddlBranchID.SelectedIndex == 0)
            {
                strError += "- Select Branch<br />";
            }

            if (ddlDistributorID.SelectedIndex == 0)
            {
                strError += "- Select Distributor<br />";
            }

            if (ddlProductID.SelectedIndex == 0)
            {
                strError += "- Select Product<br />";
            }

            if (txtQuantity.Text.Trim() == String.Empty)
            {
                strError += "- Enter Quantity<br />";
            }

            if (txtAmount.Text.Trim() == String.Empty)
            {
                strError += "- Enter Bottle Amount<br />";
            }

            #endregion Server Side Validation


            CustomerENT entCustomer = new CustomerENT();
            CustomerBAL balCustomer = new CustomerBAL();

            #region Gather Data

            if (txtCustomerName.Text.Trim() != String.Empty)
            {
                entCustomer.CustomerName = txtCustomerName.Text.Trim();
            }

            if (txtMobileNo.Text.Trim() != String.Empty)
            {
                entCustomer.MobileNo = txtMobileNo.Text.Trim();
            }

            if (txtCustomerAddress.Text.Trim() != String.Empty)
            {
                entCustomer.Address = txtCustomerAddress.Text.Trim();
            }

            if (ddlBranchID.SelectedIndex > 0)
            {
                entCustomer.BranchID = Convert.ToInt32(ddlBranchID.SelectedValue);
            }

            if (ddlDistributorID.SelectedIndex > 0)
            {
                entCustomer.DistributorID = Convert.ToInt32(ddlDistributorID.SelectedValue);
            }

            if (ddlProductID.SelectedIndex > 0)
            {
                entCustomer.ProductID = Convert.ToInt32(ddlProductID.SelectedValue);
            }

            if (txtQuantity.Text.Trim() != String.Empty)
            {
                entCustomer.Quantity = Convert.ToInt32(txtQuantity.Text.Trim());
            }

            if (txtAmount.Text.Trim() != String.Empty)
            {
                entCustomer.BottlePrice = Convert.ToDecimal(txtAmount.Text.Trim());
            }

            entCustomer.UserID = Convert.ToInt32(Session["UserID"]);

            if (Request.QueryString["CustomerID"] == null)
            {
                balCustomer.Insert(entCustomer);
                lblMessage.Text = "Data Inserted Successfully";
                ClearControls();
            }
            else
            {
                entCustomer.CustomerID = Convert.ToInt32(Request.QueryString["CustomerID"]);
                balCustomer.Update(entCustomer);
                Response.Redirect("~/AdminPanel/Customer/CustomerList.aspx");
            }
            #endregion Gather Data
        }
        catch (Exception ex)
        {
            lblErrorMessage.Text = ex.Message.ToString();
        }
    }
Exemple #9
0
        public CustomerENT SelectByPK(SqlInt32 CustomerID)
        {
            using (SqlConnection objConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand objcmd = objConnection.CreateCommand())
                {
                    try
                    {
                        objConnection.Open();

                        #region Prepare Command
                        objcmd.CommandType = CommandType.StoredProcedure;
                        objcmd.CommandText = "PR_Customer_SelectByPK";
                        objcmd.Parameters.AddWithValue("@CustomerID", CustomerID.ToString());
                        #endregion Prepare Command

                        #region ReadData And SetData
                        CustomerENT entCustomer = new CustomerENT();
                        using (SqlDataReader objSDR = objcmd.ExecuteReader())
                        {
                            while (objSDR.Read())
                            {
                                if (!objSDR["CustomerName"].Equals(DBNull.Value))
                                {
                                    entCustomer.CustomerName = Convert.ToString(objSDR["CustomerName"]);
                                }
                                if (!objSDR["Address"].Equals(DBNull.Value))
                                {
                                    entCustomer.Address = Convert.ToString(objSDR["Address"]);
                                }
                                if (!objSDR["EmailID"].Equals(DBNull.Value))
                                {
                                    entCustomer.EmailID = Convert.ToString(objSDR["EmailID"]);
                                }
                                if (!objSDR["MobileNo"].Equals(DBNull.Value))
                                {
                                    entCustomer.MobileNo = Convert.ToString(objSDR["MobileNo"]);
                                }
                            }
                        }

                        return(entCustomer);

                        #endregion ReadData And SetData
                    }
                    catch (SqlException Sqlex)
                    {
                        Message = Sqlex.Message.ToString();
                        return(null);
                    }
                    catch (Exception ex)
                    {
                        Message = ex.Message.ToString();
                        return(null);
                    }
                    finally
                    {
                        if (objConnection.State == ConnectionState.Open)
                        {
                            objConnection.Close();
                        }
                    }
                }
            }
        }