private void ProductAutoSelect()
    {
        try
        {
            RegularOrderENT entRegularOrder = new RegularOrderENT();
            RegularOrderBAL balRegularOrder = new RegularOrderBAL();

            if (ddlProductID.SelectedIndex > 0)
            {
                DataTable dt = balRegularOrder.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();
                            txtAmount.Enabled = false;
                        }
                        BottleAmount_TextChanged();
                        Quantity_TextChanged();

                        break;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            lblErrorMessage.Text = ex.Message.ToString();
        }
    }
    private void Search()
    {
        RegularOrderENT entRegularOrder = new RegularOrderENT();
        RegularOrderBAL balRegularOrder = new RegularOrderBAL();

        if (ddlCustomerID.SelectedIndex > 0)
        {
            entRegularOrder.CustomerID = Convert.ToInt32(ddlCustomerID.SelectedValue);
        }

        if (txtfromdate.Text.Trim() != String.Empty)
        {
            entRegularOrder.FromDate = Convert.ToDateTime(txtfromdate.Text.Trim());
        }

        if (txttodate.Text.Trim() != String.Empty)
        {
            entRegularOrder.ToDate = Convert.ToDateTime(txttodate.Text.Trim());
        }

        DataTable dtInvoice = balRegularOrder.RegularOrderSelectCustomerWiseSearchInvoice(entRegularOrder);

        rvInvoice.LocalReport.DataSources.Add(new ReportDataSource("RegularOrderSelectCustomerWiseSearchInvoice", dtInvoice));
        rvInvoice.LocalReport.ReportPath  = Server.MapPath("~/AdminPanel/Invoice/Report.rdlc");
        rvInvoice.LocalReport.DisplayName = ddlCustomerID.SelectedItem.Text + " Invoice Sheet";
    }
Пример #3
0
    private void Search()
    {
        SqlInt32    BranchID      = SqlInt32.Null;
        SqlInt32    CustomerID    = SqlInt32.Null;
        SqlInt32    DistributorID = SqlInt32.Null;
        SqlInt32    ProductID     = SqlInt32.Null;
        SqlDateTime FromDate      = SqlDateTime.Null;
        SqlDateTime ToDate        = SqlDateTime.Null;

        RegularOrderENT entRegularOrder = new RegularOrderENT();

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

        if (ddlCustomerID.SelectedIndex > 0)
        {
            entRegularOrder.CustomerID = Convert.ToInt32(ddlCustomerID.SelectedValue);
        }

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

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

        if (txtfromdate.Text.Trim() != "")
        {
            entRegularOrder.FromDate = DateTime.Parse(txtfromdate.Text.Trim());
        }

        if (txttodate.Text.Trim() != "")
        {
            entRegularOrder.ToDate = DateTime.Parse(txttodate.Text.Trim());
        }

        RegularOrderBAL balRegularOrder = new RegularOrderBAL();
        DataTable       dtRegularOrder  = balRegularOrder.RegularOrderSelectSearch(entRegularOrder);

        if (dtRegularOrder != null && dtRegularOrder.Rows.Count > 0)
        {
            gvRegularOrder.DataSource = dtRegularOrder;
            gvRegularOrder.DataBind();
        }
        else
        {
            gvRegularOrder.DataSource = null;
            gvRegularOrder.DataBind();
        }
    }
    private void LoadControls(SqlInt32 RegularOrderID)
    {
        RegularOrderENT entRegularOrder = new RegularOrderENT();
        RegularOrderBAL balRegularOrder = new RegularOrderBAL();

        entRegularOrder = balRegularOrder.SelectByPK(RegularOrderID);

        if (!entRegularOrder.CustomerID.IsNull)
        {
            ddlCustomerID.SelectedValue = entRegularOrder.CustomerID.Value.ToString();
        }

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

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

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

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

        if (ddlProductID.SelectedIndex > 0)
        {
            ProductAutoSelect();
        }

        if (!entRegularOrder.TotalAmount.IsNull)
        {
            txtTotalAmount.Text = entRegularOrder.TotalAmount.Value.ToString();
        }

        if (!entRegularOrder.BottleIn.IsNull)
        {
            txtBottleIn.Text = entRegularOrder.BottleIn.Value.ToString();
        }

        if (!entRegularOrder.OrderDate.IsNull)
        {
            txtOrderDate.Text = entRegularOrder.OrderDate.Value.ToString("yyyy-MM-dd");
        }
    }
Пример #5
0
        public Boolean Update(RegularOrderENT entRegularOrder)
        {
            RegularOrderDAL regularOrderDAL = new RegularOrderDAL();

            if (regularOrderDAL.Update(entRegularOrder))
            {
                return(true);
            }
            else
            {
                this.Message = regularOrderDAL.Message;
                return(false);
            }
        }
        public DataTable RegularOrderSelectSearch(RegularOrderENT entRegularOrder)
        {
            using (SqlConnection objConn = new SqlConnection(ConnectionString))
            {
                objConn.Open();
                using (SqlCommand objCmd = objConn.CreateCommand())
                    try
                    {
                        #region Prepare Command
                        objCmd.CommandType = CommandType.StoredProcedure;
                        objCmd.CommandText = "PR_RegularOrder_SelectSearch";
                        objCmd.Parameters.AddWithValue("@BranchID", entRegularOrder.BranchID);
                        objCmd.Parameters.AddWithValue("@CustomerID", entRegularOrder.CustomerID);
                        objCmd.Parameters.AddWithValue("@DistributorID", entRegularOrder.DistributorID);
                        objCmd.Parameters.AddWithValue("@ProductID", entRegularOrder.ProductID);
                        objCmd.Parameters.AddWithValue("@FromDate", entRegularOrder.FromDate);
                        objCmd.Parameters.AddWithValue("@ToDate", entRegularOrder.ToDate);
                        #endregion Prepare Command

                        #region ReadData and Set Controls
                        DataTable dt = new DataTable();
                        using (SqlDataReader objSDR = objCmd.ExecuteReader())
                        {
                            dt.Load(objSDR);
                        }
                        return(dt);

                        #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();
                    }
                }
            }
        }
        public Boolean Update(RegularOrderENT entRegulrOrder)
        {
            using (SqlConnection objConn = new SqlConnection(ConnectionString))
            {
                objConn.Open();
                using (SqlCommand objCmd = objConn.CreateCommand())
                    try
                    {
                        #region Prepare Command
                        objCmd.CommandType = CommandType.StoredProcedure;
                        objCmd.CommandText = "PR_RegularOrder_UpdateByPK";
                        objCmd.Parameters.AddWithValue("@RegularOrderID", entRegulrOrder.RegularOrderID);
                        objCmd.Parameters.AddWithValue("@CustomerID", entRegulrOrder.CustomerID);
                        objCmd.Parameters.AddWithValue("@BranchID", entRegulrOrder.BranchID);
                        objCmd.Parameters.AddWithValue("@DistributorID", entRegulrOrder.DistributorID);
                        objCmd.Parameters.AddWithValue("@ProductID", entRegulrOrder.ProductID);
                        objCmd.Parameters.AddWithValue("@Quantity", entRegulrOrder.Quantity);
                        objCmd.Parameters.AddWithValue("@TotalAmount", entRegulrOrder.TotalAmount);
                        objCmd.Parameters.AddWithValue("@BottleIn", entRegulrOrder.BottleIn);
                        objCmd.Parameters.AddWithValue("@OrderDate", entRegulrOrder.OrderDate);
                        objCmd.Parameters.AddWithValue("@UserID", entRegulrOrder.UserID);
                        #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();
                    }
                }
            }
        }
    public void ddlCustomer_SelectedIndexChanged(object sender, EventArgs e)
    {
        RegularOrderENT entRegularOrder = new RegularOrderENT();
        RegularOrderBAL balRegularOrder = new RegularOrderBAL();

        if (ddlCustomerID.SelectedIndex > 0)
        {
            DataTable dt = balRegularOrder.FillCustomer(Convert.ToInt32(ddlCustomerID.SelectedValue));

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if (!dr["BranchID"].Equals(DBNull.Value))
                    {
                        ddlBranchID.SelectedValue = Convert.ToInt32(dr["BranchID"]).ToString();
                    }

                    CommonFillMethod.FillDropDownListBranchToDistributor(ddlDistributorID, Convert.ToInt32(ddlBranchID.SelectedValue));

                    if (!dr["ProductID"].Equals(DBNull.Value))
                    {
                        ddlProductID.SelectedValue = Convert.ToInt32(dr["ProductID"]).ToString();
                    }

                    if (!dr["Quantity"].Equals(DBNull.Value))
                    {
                        txtQuantity.Text = Convert.ToInt32(dr["Quantity"]).ToString();
                    }

                    ProductAutoSelect();
                    BottleAmount_TextChanged();
                    Quantity_TextChanged();
                }
            }
        }
    }
        public RegularOrderENT SelectByPK(SqlInt32 RegularOrderID)
        {
            using (SqlConnection objConn = new SqlConnection(ConnectionString))
            {
                objConn.Open();
                using (SqlCommand objcmd = objConn.CreateCommand())
                    try
                    {
                        #region Prepar Command

                        objcmd.CommandType = CommandType.StoredProcedure;
                        objcmd.CommandText = "PR_RegularOrder_SelectByPK";
                        objcmd.Parameters.AddWithValue("@RegularOrderID", RegularOrderID);

                        #endregion Prepar Command

                        #region ReadData and Set Controls

                        RegularOrderENT entRegularOrder = new RegularOrderENT();
                        using (SqlDataReader objSDR = objcmd.ExecuteReader())
                        {
                            while (objSDR.Read())
                            {
                                if (!objSDR["RegularOrderID"].Equals(DBNull.Value))
                                {
                                    entRegularOrder.RegularOrderID = Convert.ToInt32(objSDR["RegularOrderID"]);
                                }
                                if (!objSDR["CustomerID"].Equals(DBNull.Value))
                                {
                                    entRegularOrder.CustomerID = Convert.ToInt32(objSDR["CustomerID"]);
                                }
                                if (!objSDR["BranchID"].Equals(DBNull.Value))
                                {
                                    entRegularOrder.BranchID = Convert.ToInt32(objSDR["BranchID"]);
                                }
                                if (!objSDR["DistributorID"].Equals(DBNull.Value))
                                {
                                    entRegularOrder.DistributorID = Convert.ToInt32(objSDR["DistributorID"]);
                                }
                                if (!objSDR["ProductID"].Equals(DBNull.Value))
                                {
                                    entRegularOrder.ProductID = Convert.ToInt32(objSDR["ProductID"]);
                                }
                                if (!objSDR["Quantity"].Equals(DBNull.Value))
                                {
                                    entRegularOrder.Quantity = Convert.ToInt32(objSDR["Quantity"]);
                                }
                                if (!objSDR["TotalAmount"].Equals(DBNull.Value))
                                {
                                    entRegularOrder.TotalAmount = Convert.ToDecimal(objSDR["TotalAmount"]);
                                }
                                if (!objSDR["BottleIn"].Equals(DBNull.Value))
                                {
                                    entRegularOrder.BottleIn = Convert.ToInt32(objSDR["BottleIn"]);
                                }
                                if (!objSDR["OrderDate"].Equals(DBNull.Value))
                                {
                                    entRegularOrder.OrderDate = Convert.ToDateTime(objSDR["OrderDate"]);
                                }
                                if (!objSDR["UserID"].Equals(DBNull.Value))
                                {
                                    entRegularOrder.UserID = Convert.ToInt32(objSDR["UserID"]);
                                }
                            }
                        }
                        return(entRegularOrder);

                        #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();
                    }
                }
            }
        }
        public DataTable RegularOrderSelectCustomerWiseSearchInvoice(RegularOrderENT entRegularOrder)
        {
            RegularOrderDAL dalRegularOrder = new RegularOrderDAL();

            return(dalRegularOrder.RegularOrderSelectCustomerWiseSearchInvoice(entRegularOrder));
        }
        public DataTable RegularOrderSelectSearch(RegularOrderENT entRegularOrder)
        {
            RegularOrderDAL dalRegularOrder = new RegularOrderDAL();

            return(dalRegularOrder.RegularOrderSelectSearch(entRegularOrder));
        }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            #region Server Side Validation

            String strError = String.Empty;

            if (ddlCustomerID.SelectedIndex == 0)
            {
                strError += "- Select Customer Name<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 (txtTotalAmount.Text.Trim() == String.Empty)
            {
                strError += "- Enter Total Amount<br />";
            }

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

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

            #endregion Server Side Validation


            RegularOrderENT entRegularOrder = new RegularOrderENT();
            RegularOrderBAL balRegularOrder = new RegularOrderBAL();

            #region Gather Data

            if (ddlCustomerID.SelectedIndex > 0)
            {
                entRegularOrder.CustomerID = Convert.ToInt32(ddlCustomerID.SelectedValue);
            }

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

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

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

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

            if (txtTotalAmount.Text.Trim() != String.Empty)
            {
                entRegularOrder.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text.Trim());
            }

            if (txtOrderDate.Text.Trim() != String.Empty)
            {
                entRegularOrder.OrderDate = Convert.ToDateTime(txtOrderDate.Text.Trim());
            }

            if (txtBottleIn.Text.Trim() != String.Empty)
            {
                entRegularOrder.BottleIn = Convert.ToInt32(txtBottleIn.Text.Trim());
            }

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

            if (Request.QueryString["RegularOrderID"] == null)
            {
                balRegularOrder.Insert(entRegularOrder);
                lblMessage.Text = "Data Inserted Successfully";
                ClearControls();
            }
            else
            {
                entRegularOrder.RegularOrderID = Convert.ToInt32(Request.QueryString["RegularOrderID"]);
                balRegularOrder.Update(entRegularOrder);
                Response.Redirect("~/AdminPanel/RegularOrder/RegularOrderList.aspx");
            }

            #endregion Gather Data
        }
        catch (Exception ex)
        {
            lblErrorMessage.Text = ex.Message.ToString();
        }
    }