Exemple #1
0
    //Adding first row into grid
    private void AddFirstRow()
    {
        try
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("sno");
            dt.Columns.Add("CatagoryID");
            dt.Columns.Add("Catagory");
            dt.Columns.Add("ProductID");
            dt.Columns.Add("Product");
            dt.Columns.Add("FCurentStock");
            dt.Columns.Add("TCurentStock");
            dt.Columns.Add("Quantity");

            DataRow dr1 = dt.NewRow();
            dr1["sno"]          = "";
            dr1["CatagoryID"]   = "";
            dr1["Catagory"]     = "";
            dr1["ProductID"]    = "";
            dr1["FCurentStock"] = "";
            dr1["TCurentStock"] = "";
            dr1["Product"]      = "";

            dt.Rows.Add(dr1);
            GvStockTransfer.DataSource = dt;
            GvStockTransfer.DataBind();
        }
        catch (Exception ex)
        {
        }
    }
Exemple #2
0
 protected void GvStockTransfer_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         DataTable dt = new DataTable();
         dt.Columns.Add("sno");
         dt.Columns.Add("CatagoryID");
         dt.Columns.Add("Catagory");
         dt.Columns.Add("ProductID");
         dt.Columns.Add("Product");
         dt.Columns.Add("FCurentStock");
         dt.Columns.Add("TCurentStock");
         dt.Columns.Add("Quantity");
         foreach (GridViewRow gvRow in GvStockTransfer.Rows)
         {
             DataRow dr = dt.NewRow();
             dr["CatagoryID"]   = ((Label)gvRow.FindControl("lblCatagoryID")).Text;
             dr["Catagory"]     = ((Label)gvRow.FindControl("lblCatagory")).Text;
             dr["ProductID"]    = ((Label)gvRow.FindControl("LblProductID")).Text;
             dr["FCurentStock"] = ((Label)gvRow.FindControl("lblFCurntStock")).Text;
             dr["TCurentStock"] = ((Label)gvRow.FindControl("lblTCurntStock")).Text;
             dr["Product"]      = ((Label)gvRow.FindControl("LblProduct")).Text;
             dr["Quantity"]     = ((Label)gvRow.FindControl("LblQuantity")).Text;
             dt.Rows.Add(dr);
         }
         dt.Rows[e.RowIndex].Delete();
         GvStockTransfer.DataSource = dt;
         GvStockTransfer.DataBind();
         BindSubCategory();
         ((DropDownList)GvStockTransfer.FooterRow.FindControl("DdlCatagory")).Focus();
         int i = GvStockTransfer.Rows.Count;
         if (i == 0)
         {
             AddFirstRow();
             BindSubCategory();
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemple #3
0
    protected void BtnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            Button BtnAdd = (Button)sender;
            // Get the GridViewRow
            GridViewRow row = (GridViewRow)BtnAdd.Parent.Parent;

            DropDownList DdlCatagory    = (DropDownList)row.FindControl("DdlCatagory");
            DropDownList DdlProduct     = (DropDownList)row.FindControl("DdlProduct");
            Label        lblFCurntStock = (Label)row.FindControl("lblFFtCurntStock");
            Label        lblTCurntStock = (Label)row.FindControl("lblTFtCurntStock");
            TextBox      TxtQuantity    = (TextBox)row.FindControl("TxtQuantity");
            //if (DdlCatagory.SelectedIndex ==0)
            //{
            //    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please select category...');</script>", false);
            //    return;
            //}
            //else if (DdlProduct.SelectedIndex == 0)
            //{
            //    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please select Product...');</script>", false);
            //    return;
            //}
            if (lblFCurntStock.Text == "" || lblTCurntStock.Text == "" || TxtQuantity.Text == "")
            {
                ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please fill all fields in the grid...');</script>", false);
                return;
            }
            else
            if (Convert.ToInt32(TxtQuantity.Text) == 0)
            {
                ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('0 qty can not be be transferred...');</script>", false);
                return;
            }
            else
            if (Convert.ToInt32(lblFCurntStock.Text) < Convert.ToInt32(TxtQuantity.Text))
            {
                ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Transfer qty cant be greater than from location available stock...');</script>", false);
                return;
            }

            DataTable dt = new DataTable();
            dt.Columns.Add("sno");
            dt.Columns.Add("CatagoryID");
            dt.Columns.Add("Catagory");
            dt.Columns.Add("ProductID");
            dt.Columns.Add("Product");
            dt.Columns.Add("FCurentStock");
            dt.Columns.Add("TCurentStock");
            dt.Columns.Add("Quantity");
            string Product = DdlProduct.SelectedItem.ToString();
            foreach (GridViewRow gvRow in GvStockTransfer.Rows)
            {
                if (((Label)gvRow.FindControl("lblCatagory")).Text != "")
                {
                    // && ((Label)gvRow.FindControl("lblCatagoryID")).Text == DdlCatagory.SelectedValue.ToString()
                    if (((Label)gvRow.FindControl("LblProductID")).Text == DdlProduct.SelectedValue.ToString())
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('You cant select same product twice...');</script>", false);

                        return;
                    }
                    DataRow dr = dt.NewRow();
                    dr["CatagoryID"]   = ((Label)gvRow.FindControl("lblCatagoryID")).Text;
                    dr["Catagory"]     = ((Label)gvRow.FindControl("lblCatagory")).Text;
                    dr["ProductID"]    = ((Label)gvRow.FindControl("LblProductID")).Text;
                    dr["FCurentStock"] = ((Label)gvRow.FindControl("lblFCurntStock")).Text;
                    dr["TCurentStock"] = ((Label)gvRow.FindControl("lblTCurntStock")).Text;
                    dr["Product"]      = ((Label)gvRow.FindControl("LblProduct")).Text;
                    dr["Quantity"]     = ((Label)gvRow.FindControl("LblQuantity")).Text;
                    dt.Rows.Add(dr);
                }
            }


            DataRow dr1 = dt.NewRow();
            dr1["CatagoryID"]   = ((DropDownList)GvStockTransfer.FooterRow.FindControl("DdlCatagory")).SelectedValue.ToString();
            dr1["Catagory"]     = ((DropDownList)GvStockTransfer.FooterRow.FindControl("DdlCatagory")).SelectedItem.Text;
            dr1["ProductID"]    = ((DropDownList)GvStockTransfer.FooterRow.FindControl("DdlProduct")).SelectedValue.ToString();
            dr1["FCurentStock"] = ((Label)GvStockTransfer.FooterRow.FindControl("lblFFtCurntStock")).Text;
            dr1["TCurentStock"] = ((Label)GvStockTransfer.FooterRow.FindControl("lblTFtCurntStock")).Text;
            dr1["Product"]      = ((DropDownList)GvStockTransfer.FooterRow.FindControl("DdlProduct")).SelectedItem.Text;
            dr1["Quantity"]     = ((TextBox)GvStockTransfer.FooterRow.FindControl("TxtQuantity")).Text;

            dt.Rows.Add(dr1);
            GvStockTransfer.DataSource = dt;
            GvStockTransfer.DataBind();
            BindSubCategory();
            ViewState["dtcount"] = dt;
        }
        catch (Exception ex)
        {
        }
    }