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";
    }
    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();
        }
    }
Beispiel #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");
        }
    }
Beispiel #5
0
 private void FillRegularOrderGridView()
 {
     if (Session["UserID"] != null)
     {
         RegularOrderBAL balRegularOrder = new RegularOrderBAL();
         DataTable       dtRegularOrder  = balRegularOrder.SelectAll();
         if (dtRegularOrder != null && dtRegularOrder.Rows.Count > 0)
         {
             gvRegularOrder.DataSource = dtRegularOrder;
             gvRegularOrder.DataBind();
         }
     }
 }
Beispiel #6
0
 protected void gvRegularOrder_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "DeleteRecord" && e.CommandArgument != null)
         {
             RegularOrderBAL balRegularOrder = new RegularOrderBAL();
             if (balRegularOrder.Delete(Convert.ToInt32(e.CommandArgument)))
             {
                 FillRegularOrderGridView();
             }
             else
             {
                 lblMessage.Text = balRegularOrder.Message;
             }
         }
     }
     catch (Exception ex)
     {
         lblMessage.Text = ex.Message.ToString();
     }
 }
    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();
                }
            }
        }
    }
    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();
        }
    }