Пример #1
0
        public void LoadData()
        {
            #region Display Requests
            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("Sp_GetPendingPOs", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@p_RequestedByID", Session["UserSys"]);
                if (StockAt.SelectedIndex > 0)
                {
                    command.Parameters.AddWithValue("@p_RequestedForID", Convert.ToInt32(StockAt.SelectedValue.ToString()));
                }
                else
                {
                    command.Parameters.AddWithValue("@p_RequestedForID", DBNull.Value);
                }
                DataSet ds = new DataSet();

                SqlDataAdapter sA = new SqlDataAdapter(command);
                sA.Fill(ds);
                StockDisplayGrid.DataSource = null;
                StockDisplayGrid.DataSource = ds.Tables[0];
                StockDisplayGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
Пример #2
0
        public void PopulateDropDown(String Text)
        {
            #region Populating Product Name Dropdown

            try
            {
                connection.Open();

                Text = Text + "%";
                SqlCommand     command = new SqlCommand("SELECT * From tbl_ProductSuperMaster Where tbl_ProductSuperMaster.DrugName LIKE '" + Text + "'", connection);
                DataSet        ds      = new DataSet();
                SqlDataAdapter sA      = new SqlDataAdapter(command);
                sA.Fill(ds);
                if (StockDisplayGrid.DataSource != null)
                {
                    StockDisplayGrid.DataSource = null;
                }

                ProductSet = null;
                ProductSet = ds;
                StockDisplayGrid.DataSource = ds.Tables[0];
                StockDisplayGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
Пример #3
0
        private void BindGrid()
        {
            DataTable dt = new DataTable();
            DataSet   ds = new DataSet();

            #region Getting Product Details
            try
            {
                DataView dv = new DataView();
                dv           = ProductSet.Tables[0].DefaultView;
                dv.RowFilter = "ProductID = '" + SelectProduct.SelectedValue.ToString() + "'";
                dt           = dv.ToTable();
                String Query = "Select tblStock_Detail.ProductID AS ProductID ,tbl_ProductMaster.Description AS ProductName, tblStock_Detail.BarCode AS BarCode,tblStock_Detail.StockID AS StockID, tblStock_Detail.Quantity AS Qauntity, tblStock_Detail.ExpiryDate As Expiry, tblStock_Detail.UCostPrice AS CostPrice, tblStock_Detail.USalePrice AS SalePrice, tblStock_Detail.StoredAt AS Location From  tblStock_Detail INNER JOIN tbl_ProductMaster ON tblStock_Detail.ProductID = tbl_ProductMaster.ProductID Where tblStock_Detail.ProductID = '" + Int32.Parse(dt.Rows[0]["ProductID"].ToString()) + "'";

                connection.Open();
                SqlCommand     command = new SqlCommand(Query, connection);
                SqlDataAdapter SA      = new SqlDataAdapter(command);
                SA.Fill(ds);
                StockDisplayGrid.DataSource = ds;
                StockDisplayGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
        public void LoadData()
        {
            #region Display Requests
            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("sp_GetPendingStoreTransfers_SysID", connection); // change SP name and add parameter
                command.CommandType = CommandType.StoredProcedure;
                int UserSys = 0;
                if (int.TryParse(Session["UserSys"].ToString(), out UserSys))
                {
                    command.Parameters.AddWithValue("@p_SysID", UserSys);
                }
                DataSet ds = new DataSet();

                SqlDataAdapter sA = new SqlDataAdapter(command);
                sA.Fill(ds);
                StockDisplayGrid.DataSource = null;
                StockDisplayGrid.DataSource = ds.Tables[0];
                StockDisplayGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
Пример #5
0
        private void BindGrid()
        {
            try
            {
                #region Query Execution
                connection.Open();
                SqlCommand command = new SqlCommand("Sp_GetOrderDetail_ReceiveEntries", connection);
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@p_OrderDetailID", Convert.ToInt32(Session["ordetailID"].ToString()));

                DataSet ds = new DataSet();

                SqlDataAdapter sA = new SqlDataAdapter(command);
                sA.Fill(ds);
                ProductSet = ds;
                StockDisplayGrid.DataSource = null;
                StockDisplayGrid.DataSource = ds.Tables[0];
                StockDisplayGrid.DataBind();
                #endregion
            }
            catch (Exception exp) { }
            finally
            {
                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }
        protected void SelectProduct_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                connection.Open();

                String         Text    = SelectProduct.SelectedItem.ToString() + "%";
                SqlCommand     command = new SqlCommand("SELECT * From tbl_ProductMaster Where tbl_ProductMaster.Product_Name LIKE '" + Text + "' AND Status = 1", connection);
                DataSet        ds      = new DataSet();
                SqlDataAdapter sA      = new SqlDataAdapter(command);
                sA.Fill(ds);
                if (SelectProduct.DataSource != null)
                {
                    SelectProduct.DataSource = null;
                }

                ProductSet = null;
                ProductSet = ds;

                StockDisplayGrid.DataSource = ds;
                StockDisplayGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
        }
Пример #7
0
        public void LoadData()
        {
            #region Display Requests
            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("Sp_GetPendingOrderByID", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@p_RequestedByID", Session["UserSys"]);
                DataSet ds = new DataSet();

                SqlDataAdapter sA = new SqlDataAdapter(command);
                sA.Fill(ds);
                StockDisplayGrid.DataSource = null;
                StockDisplayGrid.DataSource = ds.Tables[0];
                StockDisplayGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
        public void GenerateSales(DateTime Salefrom, DateTime Saleto, int SysID)
        {
            try
            {
                connection.Open();
                SqlCommand cmd = new SqlCommand("sp_GenerateAutoRequest_Sales", connection);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@p_SysID", SysID);
                cmd.Parameters.AddWithValue("@p_SaleFROM", Salefrom);
                cmd.Parameters.AddWithValue("@p_SaleTO", Saleto);
                DataSet        ds = new DataSet();
                SqlDataAdapter sA = new SqlDataAdapter(cmd);
                sA.Fill(ds);
                ProductSet = ds;

                StockDisplayGrid.DataSource = ds.Tables[0];
                StockDisplayGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
        }
        private void BindGrid()
        {
            DataTable dt = new DataTable();
            DataSet   ds = new DataSet();

            #region Getting Product Details
            try
            {
                int id;
                if (int.TryParse(Session["UserSys"].ToString(), out id))
                {
                    String Query = "Select * FROM tbl_ProductMaster Where Status = 1";

                    connection.Open();
                    SqlCommand     command = new SqlCommand(Query, connection);
                    SqlDataAdapter SA      = new SqlDataAdapter(command);
                    ProductSet = null;
                    SA.Fill(ds);
                    ProductSet = ds;
                    StockDisplayGrid.DataSource = ds;
                    StockDisplayGrid.DataBind();
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
Пример #10
0
        private void BindGrid()
        {
            #region Display Products
            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("sp_GetOrderbyVendor", connection);
                command.CommandType = CommandType.StoredProcedure;
                int     OrderNumber = 0;
                DataSet ds          = new DataSet();

                if (int.TryParse(Session["OrderNumber"].ToString(), out OrderNumber))
                {
                    command.Parameters.AddWithValue("@p_OrderID", OrderNumber);
                }

                SqlDataAdapter sA = new SqlDataAdapter(command);
                sA.Fill(ds);
                StockDisplayGrid.DataSource = null;
                StockDisplayGrid.DataSource = ds.Tables[0];
                StockDisplayGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
        public void LoadData()
        {
            //InvNO.Text = Session["S_RequestInvoice"].ToString();
            RequestDate.Text = System.DateTime.Now.ToShortDateString();
            #region Display Products
            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("sp_GetStoreRequest_byOrderID", connection);
                command.CommandType = CommandType.StoredProcedure;
                int     OrderNumber = 0;
                DataSet ds          = new DataSet();

                if (int.TryParse(Session["OrderNumber"].ToString(), out OrderNumber))
                {
                    command.Parameters.AddWithValue("@p_OrderID", OrderNumber);
                }

                SqlDataAdapter sA = new SqlDataAdapter(command);
                sA.Fill(ds);
                StockDisplayGrid.DataSource = null;
                StockDisplayGrid.DataSource = ds.Tables[0];
                StockDisplayGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
        public void LoadData(String OrderID)
        {
            #region Display Requests
            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("sp_GetGenSODetails_OrdID", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@p_OrderID", OrderID);

                DataSet ds = new DataSet();

                SqlDataAdapter sA = new SqlDataAdapter(command);
                sA.Fill(ds);
                ProductSet = ds;
                StockDisplayGrid.DataSource = null;
                StockDisplayGrid.DataSource = ds.Tables[0];
                StockDisplayGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
        public void LoadData(String StoreID)
        {
            #region Display Requests
            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("sp_GetGeneratedOrder_store_warehouse", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@p_StoreID", StoreID);
                Session["RequestedFromID"] = StoreID;
                DataSet ds = new DataSet();

                SqlDataAdapter sA = new SqlDataAdapter(command);
                sA.Fill(ds);
                ProductSet = ds;
                StockDisplayGrid.DataSource = null;
                StockDisplayGrid.DataSource = ds.Tables[0];
                StockDisplayGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
        public void LoadData()
        {
            ReceiptNum.Text = Session["RequestedNO"].ToString();
            // RequestFrom.Text = Session["RequestedFrom"].ToString();
            //RequestDate.Text = Session["RequestedDate"].ToString();
            #region Display Products
            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("Sp_GetPODetails_ByID", connection);
                command.CommandType = CommandType.StoredProcedure;
                int     OrderNumber = 0;
                DataSet ds          = new DataSet();

                if (int.TryParse(Session["RequestedNO"].ToString(), out OrderNumber))
                {
                    command.Parameters.AddWithValue("@p_OrderID", OrderNumber);
                }

                SqlDataAdapter sA = new SqlDataAdapter(command);
                sA.Fill(ds);
                StockDisplayGrid.DataSource = null;
                StockDisplayGrid.DataSource = ds.Tables[0];
                StockDisplayGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
Пример #15
0
        private void LoadData()
        {
            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("sp_GeneratePO", connection);
                command.CommandType = CommandType.StoredProcedure;

                int OrderNumber = 0;
                if (int.TryParse(Session["OrderNumber"].ToString(), out OrderNumber))
                {
                    command.Parameters.AddWithValue("@p_OrderNo", OrderNumber);
                }

                SqlDataAdapter dA = new SqlDataAdapter(command);
                dA.Fill(ProductSet);
                StockDisplayGrid.DataSource = ProductSet;
                StockDisplayGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
        }
        protected void StockDisplayGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            DataSet dsManipulation = new DataSet();

            dsManipulation = ProductSet;
            try
            {
                if (e.CommandName.Equals("UpdateStock"))
                {
                    Label   Barcode  = (Label)StockDisplayGrid.Rows[StockDisplayGrid.EditIndex].FindControl("BarCode");
                    TextBox Quantity = (TextBox)StockDisplayGrid.Rows[StockDisplayGrid.EditIndex].FindControl("txtQuantity");

                    for (int i = 0; i < dsManipulation.Tables[0].Rows.Count; i++)
                    {
                        if (dsManipulation.Tables[0].Rows[i]["BarCode"].ToString().Equals(Barcode.Text.ToString()))
                        {
                            dsManipulation.Tables[0].Rows[i]["SaleQuantity"] = Convert.ToInt32(Quantity.Text.ToString());
                            break;
                        }
                    }
                }
            }
            catch (Exception exp)
            {
            }
            finally
            {
                StockDisplayGrid.EditIndex = -1;
                ProductSet = null;
                ProductSet = dsManipulation;
                StockDisplayGrid.DataSource = ProductSet.Tables[0];
                StockDisplayGrid.DataBind();
            }
        }
        public void LoadData()
        {
            RequestFrom.Text = Session["RequestedFrom"].ToString();
            RequestDate.Text = Session["RequestedDate"].ToString();

            #region Getting Products against an OrderID
            int RequestNumber = 0;
            if (int.TryParse(Session["RequestedNO"].ToString(), out RequestNumber))
            {
                try
                {
                    int SysID = 0;
                    if (int.TryParse(Session["UserSys"].ToString(), out SysID))
                    {
                        connection.Open();
                        SqlCommand command = new SqlCommand("sp_GetOrderDetailsbyID", connection);
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@p_OrderID", RequestNumber);
                        command.Parameters.AddWithValue("@p_SysID", SysID);

                        DataSet        ds = new DataSet();
                        SqlDataAdapter dA = new SqlDataAdapter(command);
                        dA.Fill(ds);
                        ProductSet = ds;

                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            for (int j = 0; j < ds.Tables[1].Rows.Count; j++)
                            {
                                if (ds.Tables[0].Rows[i]["ProductID"].Equals(ds.Tables[1].Rows[j]["ProductID"]))
                                {
                                    ds.Tables[0].Rows[i]["Stock"] = ds.Tables[1].Rows[j]["Inventory"];
                                    break;
                                }
                            }
                        }

                        StockDisplayGrid.DataSource = null;
                        StockDisplayGrid.DataSource = ds.Tables[0];
                        StockDisplayGrid.DataBind();
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    connection.Close();
                }
            }
            else
            {
                //send to Main Request Screen of warehouse
            }
            #endregion
        }
 protected void btnDecline_Click(object sender, EventArgs e)
 {
     //should clean everything if final accept is not pressed
     //  InvNO.Text = "";
     RequestTo.Enabled           = true;
     StockDisplayGrid.DataSource = null;
     StockDisplayGrid.DataBind();
     SelectQuantity.Text         = "";
     SelectProduct.SelectedIndex = -1;
     RequestTo.SelectedIndex     = -1;
     btnAccept.Visible           = false;
     btnDecline.Visible          = false;
 }
Пример #19
0
 protected void btnRefresh_Click(object sender, EventArgs e)
 {
     txtVendor.Text              = "";
     RequestTo.Visible           = false;
     RequestTo.Enabled           = true;
     StockDisplayGrid.DataSource = null;
     StockDisplayGrid.DataBind();
     SelectQuantity.Text         = "";
     SelectProduct.SelectedIndex = -1;
     RequestTo.SelectedIndex     = -1;
     btnAccept.Visible           = false;
     btnDecline.Visible          = false;
 }
 protected void btnCancelOrder_Click(object sender, EventArgs e)
 {
     //must be checked for sessions
     if (Session["OrderSalesDetail"].Equals(true) && Session["OrderSalesDetail"].ToString() != null && Session["OrderSalesDetail"] != null)
     {
         Session["OrderNumber"]      = "";
         Session["OrderSalesDetail"] = false;
         Response.Redirect("ViewSalesOrders.aspx", false); //must be rechecked
     }
     else
     {
         try
         {
             if (Session["OrderNumber"] != null)
             {
                 int orderID = int.Parse(Session["OrderNumber"].ToString());
                 connection.Open();
                 SqlCommand command = new SqlCommand("sp_DeleteSO", connection);
                 command.CommandType = CommandType.StoredProcedure;
                 command.Parameters.AddWithValue("@p_OrderID", orderID);
                 command.ExecuteNonQuery();
             }
             Session["OrderNumber"]          = null;
             Session["FromViewPlacedOrders"] = "false";
             txtProduct.Text             = "";
             SelectProduct.Visible       = false;
             StockAt.Enabled             = true;
             StockDisplayGrid.DataSource = null;
             StockDisplayGrid.DataBind();
             SelectQuantity.Text         = "";
             SelectProduct.SelectedIndex = -1;
             StockAt.SelectedIndex       = -1;
             btnAccept.Visible           = false;
             btnDecline.Visible          = false;
             FirstOrder = false;
         }
         catch (Exception ex)
         {
         }
         finally
         {
             if (connection.State == ConnectionState.Open)
             {
                 connection.Close();
             }
         }
         Session["OrderNumber"]      = "";
         Session["OrderSalesDetail"] = false;
         Response.Redirect("ManageOrders.aspx", false);
     }
 }
 protected void btnCancelRequest_Click(object sender, EventArgs e)
 {
     if (DateTextBox.Enabled.Equals(false))
     {
         DateTextBox.Enabled = true;
     }
     if (DateTextBox2.Enabled.Equals(false))
     {
         DateTextBox2.Enabled = true;
     }
     StockDisplayGrid.DataSource = null;
     StockDisplayGrid.DataBind();
     ProductSet         = null;
     btnAccept.Visible  = false;
     btnDecline.Visible = false;
 }
Пример #22
0
        private void BindGrid()
        {
            DataTable dt = new DataTable();
            DataSet   ds = new DataSet();

            #region Getting Product Details
            try
            {
                int id;
                if (int.TryParse(Session["UserSys"].ToString(), out id))
                {
                    String Query = "Select tblStock_Detail.ProductID AS ProductID ,tbl_ProductMaster.Product_Name AS ProductName, tblStock_Detail.BarCode AS BarCode, tblStock_Detail.Quantity AS Qauntity, tblStock_Detail.ExpiryDate As Expiry,tbl_ProductMaster.Product_Name AS ProductName," +
                                   " tbl_ProductMaster.itemPackSize as PackageSize, tbl_ProductMaster.itemStrength as strength, tbl_ProductMaster.itemForm as dosageForm, FORMAT(tblStock_Detail.UCostPrice, 'N2') AS CostPrice, FORMAT(tblStock_Detail.USalePrice, 'N2') AS SalePrice, tbl_System.SystemName AS Location" +
                                   " From  tblStock_Detail INNER JOIN tbl_ProductMaster ON tblStock_Detail.ProductID = tbl_ProductMaster.ProductID INNER JOIN tbl_System ON tblStock_Detail.StoredAt = tbl_System.SystemID AND tblStock_Detail.StoredAt = '" + id.ToString() + "'";

                    connection.Open();
                    SqlCommand     command = new SqlCommand(Query, connection);
                    SqlDataAdapter SA      = new SqlDataAdapter(command);
                    SA.Fill(ds);
                    if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        StockDisplayGrid.DataSource = ds;
                        StockDisplayGrid.DataBind();
                    }
                    else
                    {
                        WebMessageBoxUtil.Show("No stock available to show");
                        NoProductMessage.Visible = true;
                        ProductCat.Enabled       = false;
                        ProductDept.Enabled      = false;
                        ProductSubCat.Enabled    = false;
                        ProductType.Enabled      = false;
                        SelectProduct.Enabled    = false;
                        btnSearch.Enabled        = false;
                        btnRefresh.Enabled       = false;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
Пример #23
0
        public void PopulateDropDown(String Text)
        {
            #region Populating Product Name Dropdown

            try
            {
                connection.Open();

                Text = Text + "%";
                SqlCommand     command = new SqlCommand("SELECT * From tbl_ProductMaster Where tbl_ProductMaster.Product_Name LIKE '" + Text + "' AND Status = 1", connection);
                DataSet        ds      = new DataSet();
                SqlDataAdapter sA      = new SqlDataAdapter(command);
                sA.Fill(ds);
                if (SelectProduct.DataSource != null)
                {
                    SelectProduct.DataSource = null;
                }

                ProductSet = null;
                ProductSet = ds;

                StockDisplayGrid.DataSource = ds;
                StockDisplayGrid.DataBind();

                SelectProduct.DataSource     = ds.Tables[0];
                SelectProduct.DataTextField  = "Product_Name";
                SelectProduct.DataValueField = "ProductID";
                SelectProduct.DataBind();
                if (SelectProduct != null)
                {
                    SelectProduct.Items.Insert(0, "Select Product");
                    SelectProduct.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
Пример #24
0
 protected void btnDecline_Click(object sender, EventArgs e)
 {
     try
     {
         if (Session["OrderNumber"] != null)
         {
             int orderID = int.Parse(Session["OrderNumber"].ToString());
             connection.Open();
             SqlCommand command = new SqlCommand("sp_DeleteOrder", connection);
             command.CommandType = CommandType.StoredProcedure;
             command.Parameters.AddWithValue("@p_OrderID", orderID);
             command.ExecuteNonQuery();
         }
         Session["OrderNumber"]          = null;
         Session["FromViewPlacedOrders"] = "false";
         txtVendor.Text              = "";
         txtProduct.Text             = "";
         txtVendor.Enabled           = true;
         btnSearchVendor.Enabled     = true;
         SelectProduct.Visible       = false;
         RequestTo.Visible           = false;
         RequestTo.Enabled           = true;
         StockDisplayGrid.DataSource = null;
         StockDisplayGrid.DataBind();
         SelectQuantity.Text         = "";
         SelectProduct.SelectedIndex = -1;
         RequestTo.SelectedIndex     = -1;
         btnAccept.Visible           = false;
         btnDecline.Visible          = false;
         FirstOrder = false;
     }
     catch (Exception ex)
     {
     }
     finally
     {
         if (connection.State == ConnectionState.Open)
         {
             connection.Close();
         }
     }
 }
Пример #25
0
        public void BindGrid()
        {
            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("sp_getProductStock", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@p_orderDetailID", Convert.ToInt32(Session["OderDetailID"].ToString()));
                command.Parameters.AddWithValue("@p_ProductID", Convert.ToInt32(Session["ProductID"].ToString()));
                DataSet        ds = new DataSet();
                SqlDataAdapter dA = new SqlDataAdapter(command);
                dA.Fill(ds);

                int Total = 0;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    Total += Convert.ToInt32(ds.Tables[0].Rows[i]["SentQuantity"].ToString()) + Convert.ToInt32(ds.Tables[0].Rows[i]["BonusQuantity"].ToString());
                }
                if (Total >= Convert.ToInt32(lblTotalQuantity.Text.ToString()))
                {
                    TotalExceeded = true;
                }
                else
                {
                    TotalExceeded = false;
                }
                if (ds != null || ds.Tables[0] != null)
                {
                    ProductSet = ds;
                    StockDisplayGrid.DataSource = ds.Tables[0];
                    StockDisplayGrid.DataBind();
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
        }
 protected void StockDisplayGrid_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
 {
     StockDisplayGrid.EditIndex  = -1;
     StockDisplayGrid.DataSource = ProductSet.Tables[0];
     StockDisplayGrid.DataBind();
 }
 protected void StockDisplayGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     StockDisplayGrid.PageIndex  = e.NewPageIndex;
     StockDisplayGrid.DataSource = ProductSet.Tables[0];
     StockDisplayGrid.DataBind();
 }
        public void BindGridbyFilters()
        {
            DataTable dt = new DataTable();
            DataSet   ds = new DataSet();

            #region Getting Product Details
            try
            {
                int id;
                if (int.TryParse(Session["UserSys"].ToString(), out id))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand("sp_ViewInventory_byFilters", connection);
                    #region with parameter approach
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@p_SysID", id);
                    int depID, catID, subCatID, prodIDOrg, prodType, prodID = -1;
                    int.TryParse(Session["Search_DepID"].ToString(), out depID);
                    int.TryParse(Session["Search_CatID"].ToString(), out catID);
                    int.TryParse(Session["Search_SubCatID"].ToString(), out subCatID);
                    int.TryParse(Session["Search_ProdIdOrg"].ToString(), out prodIDOrg);
                    int.TryParse(Session["Search_ProdType"].ToString(), out prodType);
                    int.TryParse(Session["Search_ProdId"].ToString(), out prodID);

                    if (depID <= 0)
                    {
                        command.Parameters.AddWithValue("@p_DeptID", DBNull.Value);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@p_DeptID", depID);
                    }

                    if (catID <= 0)
                    {
                        command.Parameters.AddWithValue("@p_CatID", DBNull.Value);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@p_CatID", catID);
                    }

                    if (subCatID <= 0)
                    {
                        command.Parameters.AddWithValue("@p_SubCatID", DBNull.Value);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@p_SubCatID", subCatID);
                    }

                    if (prodIDOrg <= 0)
                    {
                        command.Parameters.AddWithValue("@p_productOrderType", DBNull.Value);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@p_productOrderType", prodIDOrg);
                    }


                    if (prodType <= 0)
                    {
                        command.Parameters.AddWithValue("@p_ProdType", DBNull.Value);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@p_ProdType", prodType);
                    }

                    if (prodID <= 0)
                    {
                        command.Parameters.AddWithValue("@p_ProdID", DBNull.Value);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@p_ProdID", prodID);
                    }
                    #endregion

                    SqlDataAdapter SA = new SqlDataAdapter(command);
                    SA.Fill(ds);
                    StockDisplayGrid.DataSource = ds;
                    StockDisplayGrid.DataBind();
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
Пример #29
0
        public void BindGridbyFilters()
        {
            DataTable dt = new DataTable();
            DataSet   ds = new DataSet();

            #region Getting Product Details
            try
            {
                int id;
                if (int.TryParse(Session["UserSys"].ToString(), out id))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand("sp_ViewInventory_byFilters", connection);
                    #region with parameter approach
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@p_SysID", id);

                    if (ProductDept.SelectedIndex <= 0)
                    {
                        command.Parameters.AddWithValue("@p_DeptID", DBNull.Value);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@p_DeptID", Convert.ToInt32(ProductDept.SelectedValue.ToString()));
                    }

                    if (ProductCat.SelectedIndex <= 0)
                    {
                        command.Parameters.AddWithValue("@p_CatID", DBNull.Value);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@p_CatID", Convert.ToInt32(ProductCat.SelectedValue.ToString()));
                    }

                    if (ProductSubCat.SelectedIndex <= 0)
                    {
                        command.Parameters.AddWithValue("@p_SubCatID", DBNull.Value);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@p_SubCatID", Convert.ToInt32(ProductSubCat.SelectedValue.ToString()));
                    }

                    if (ddlProductOrderType.SelectedIndex <= 0)
                    {
                        command.Parameters.AddWithValue("@p_productOrderType", DBNull.Value);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@p_productOrderType", Convert.ToInt32(ddlProductOrderType.SelectedValue.ToString()));
                    }


                    if (ProductType.SelectedIndex <= 0)
                    {
                        command.Parameters.AddWithValue("@p_ProdType", DBNull.Value);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@p_ProdType", ProductType.SelectedItem.ToString());
                    }

                    if (ProductList.SelectedIndex <= 0)
                    {
                        command.Parameters.AddWithValue("@p_ProdID", DBNull.Value);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@p_ProdID", Convert.ToInt32(ProductList.SelectedValue.ToString()));
                    }
                    #endregion

                    SqlDataAdapter SA = new SqlDataAdapter(command);
                    SA.Fill(ds);
                    StockDisplayGrid.DataSource = ds;
                    StockDisplayGrid.DataBind();
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }
        public void LoadData(String VendorID)
        {
            #region Display Orders
            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("sp_GetPendingSO_byID", connection);
                command.CommandType = CommandType.StoredProcedure;
                if (String.IsNullOrWhiteSpace(VendorID) || StockAt.SelectedIndex <= 0)
                {
                    command.Parameters.AddWithValue("@p_VendID", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@p_VendID", VendorID);
                }

                if (OrderStatus.SelectedIndex <= 0)
                {
                    command.Parameters.AddWithValue("@p_OrderStatus", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@p_OrderStatus", OrderStatus.SelectedValue.ToString());
                }

                if (String.IsNullOrWhiteSpace(DateTextBox.Text.ToString()))
                {
                    command.Parameters.AddWithValue("@p_OrderDate", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@p_OrderDate", Convert.ToDateTime(DateTextBox.Text.ToString()));
                }


                if (String.IsNullOrWhiteSpace(txtOrderNO.Text.ToString()))
                {
                    command.Parameters.AddWithValue("@p_OrderID", DBNull.Value);
                }
                else
                {
                    command.Parameters.AddWithValue("@p_OrderID", Convert.ToInt32(txtOrderNO.Text.ToString()));
                }

                DataSet ds = new DataSet();

                SqlDataAdapter sA = new SqlDataAdapter(command);
                sA.Fill(ds);
                ProductSet = ds;
                StockDisplayGrid.DataSource = null;
                StockDisplayGrid.DataSource = ds.Tables[0];
                StockDisplayGrid.DataBind();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                connection.Close();
            }
            #endregion
        }