Example #1
0
    private void Fn_GetCurrentDataTable()
    {
        DataTable dtCurrentTable = (DataTable)ViewState["DataTableSpareSalePurchaseByASC"];

        dtCurrentTable.Rows.Clear();
        DataRow dr = dtCurrentTable.NewRow();

        dtCurrentTable.Rows.Add(dr);
        GvSpareSalePurchaseByASC.EditIndex  = 0;
        ViewState["EditIndex"]              = "0";
        GvSpareSalePurchaseByASC.DataSource = dtCurrentTable;
        GvSpareSalePurchaseByASC.DataBind();
        ViewState["DataTableSpareSalePurchaseByASC"] = dtCurrentTable;
        FillDropDowns();
    }
Example #2
0
    private void Fn_GetCurrentDataTable()
    {
        DataTable dtCurrentTable = (DataTable)ViewState["DataTableSparePurchaseOutside"];

        if (ViewState["EditIndex"] == null)
        {
            dtCurrentTable.Rows.Clear();
            GvSpareSalePurchaseByASC.EditIndex = 0;
            ViewState["EditIndex"]             = "0";
        }
        DataRow dr = dtCurrentTable.NewRow();

        dtCurrentTable.Rows.Add(dr);

        GvSpareSalePurchaseByASC.DataSource = dtCurrentTable;
        GvSpareSalePurchaseByASC.DataBind();
        ViewState["DataTableSparePurchaseOutside"] = dtCurrentTable;
        FillSparesDropDown();
    }
Example #3
0
 protected void btnDeleteRow_Click(object sender, EventArgs e)
 {
     try
     {
         Button btnDelete = ((Button)(sender));
         if (btnDelete != null)
         {
             string    strTransactionNo = btnDelete.CommandArgument;
             DataTable dtCurrentTable;
             if (ViewState["DataTableSpareSalePurchaseByASC"] != null)
             {
                 dtCurrentTable = (DataTable)ViewState["DataTableSpareSalePurchaseByASC"];
             }
             else
             {
                 dtCurrentTable = null;
             }
             for (int i = 0; i < dtCurrentTable.Rows.Count; i++)
             {
                 if (strTransactionNo == Convert.ToString(dtCurrentTable.Rows[i]["Spare_Id"]))
                 {
                     dtCurrentTable.Rows.RemoveAt(i);
                     break;
                 }
             }
             ViewState["DataTableSpareSalePurchaseByASC"] = dtCurrentTable;
             ViewState["EditIndex"]              = dtCurrentTable.Rows.Count - 1;
             GvSpareSalePurchaseByASC.EditIndex  = dtCurrentTable.Rows.Count - 1;
             GvSpareSalePurchaseByASC.DataSource = dtCurrentTable;
             GvSpareSalePurchaseByASC.DataBind();
             FillDropDowns();
         }
     }
     catch (Exception ex)
     {
         SIMSCommonClass.WriteErrorErrFile(Request.RawUrl.ToString(), ex.StackTrace.ToString() + "-->" + ex.Message.ToString());
     }
     FillDropDownToolTip();
 }
Example #4
0
    void RefreshPage()
    {
        ddlRegion.SelectedIndex         = 0;
        ddlBranch.SelectedIndex         = 0;
        ddlASC.SelectedIndex            = 0;
        ddlProductDivison.SelectedIndex = 0;

        DataTable dtCurrentTable = (DataTable)ViewState["DataTableSparePurchaseOutside"];

        dtCurrentTable.Rows.Clear();
        DataRow dr = dtCurrentTable.NewRow();

        dtCurrentTable.Rows.Add(dr);
        dtCurrentTable.AcceptChanges();

        ViewState["DataTableSparePurchaseOutside"] = dtCurrentTable;
        ViewState["EditIndex"] = 0;

        GvSpareSalePurchaseByASC.EditIndex  = 0;
        GvSpareSalePurchaseByASC.DataSource = dtCurrentTable;
        GvSpareSalePurchaseByASC.DataBind();
        FillSparesDropDown();
    }
Example #5
0
    protected void btnAddRow_Click(object sender, EventArgs e)
    {
        GridViewRow  gvrow                 = (GridViewRow)(((Control)sender).NamingContainer);
        DropDownList ddlSpareCode          = (DropDownList)gvrow.FindControl("ddlSpareCode");
        TextBox      lblCurrentStock       = (TextBox)gvrow.FindControl("lblCurrentStock");
        DropDownList ddlLocation           = (DropDownList)gvrow.FindControl("ddlLocation");
        TextBox      lblStockAsPerLocation = (TextBox)gvrow.FindControl("lblStockAsPerLocation");
        DropDownList ddlDefLocation        = (DropDownList)gvrow.FindControl("ddlDefLocation");
        TextBox      txtQuantity           = (TextBox)gvrow.FindControl("txtQuantity");
        DropDownList ddlActionType         = (DropDownList)gvrow.FindControl("ddlActionType");
        TextBox      txtComments           = (TextBox)gvrow.FindControl("txtComments");

        if ((Convert.ToInt32(lblStockAsPerLocation.Text) < Convert.ToInt32(txtQuantity.Text)) && (ddlActionType.SelectedItem.Value == "2"))
        {
            ScriptManager.RegisterClientScriptBlock(btnConfirm, GetType(), "Spare", "alert('Entered Qty should not be greater than available qty.');", true);
            return;
        }
        DataTable dtCurrentTable;

        if (ViewState["DataTableSpareSalePurchaseByASC"] != null)
        {
            dtCurrentTable = (DataTable)ViewState["DataTableSpareSalePurchaseByASC"];
        }
        else
        {
            dtCurrentTable = new DataTable();
        }
        int  ConsumeSpareId = Convert.ToInt32(ddlSpareCode.SelectedValue);
        bool blnIsUpdate    = true;

        for (int i = 0; i < GvSpareSalePurchaseByASC.Rows.Count; i++)
        {
            if (i != gvrow.RowIndex)
            {
                int PreConsumeSpareId = Convert.ToInt32(GvSpareSalePurchaseByASC.Rows[i].Cells[9].Text);
                if (PreConsumeSpareId == 0)
                {
                    PreConsumeSpareId = Convert.ToInt32(GvSpareSalePurchaseByASC.Rows[i].Cells[9].Text);
                }
                if (ConsumeSpareId == PreConsumeSpareId)
                {
                    blnIsUpdate = false;
                    //ScriptManager.RegisterClientScriptBlock(btnAddRow_Click, GetType(), "Spare", "alert('Same Spare can not be entered.');", true);
                }
            }
        }


        if (blnIsUpdate == true)
        {
            DataRow drCurrentRow = dtCurrentTable.NewRow();
            drCurrentRow["Spare_Id"]         = ddlSpareCode.SelectedItem.Value;
            drCurrentRow["Spare"]            = ddlSpareCode.SelectedItem.Text;
            drCurrentRow["Current_Stock"]    = lblCurrentStock.Text;
            drCurrentRow["Loc_Id"]           = ddlLocation.SelectedItem.Value;
            drCurrentRow["Location"]         = ddlLocation.SelectedItem.Text;
            drCurrentRow["QtyAsPerLocation"] = lblStockAsPerLocation.Text;
            drCurrentRow["Def_Loc_Id"]       = ddlDefLocation.SelectedItem.Value;
            drCurrentRow["Def_Location"]     = ddlDefLocation.SelectedItem.Text;
            drCurrentRow["Quantity"]         = txtQuantity.Text;
            drCurrentRow["Action_Type_Id"]   = ddlActionType.SelectedItem.Value;
            drCurrentRow["Action_Type"]      = ddlActionType.SelectedItem.Text;
            drCurrentRow["Comments"]         = txtComments.Text.Trim();

            dtCurrentTable.Rows.InsertAt(drCurrentRow, dtCurrentTable.Rows.Count - 1);
            ViewState["DataTableSpareSalePurchaseByASC"] = dtCurrentTable;
            ViewState["EditIndex"] = dtCurrentTable.Rows.Count - 1;

            GvSpareSalePurchaseByASC.EditIndex  = dtCurrentTable.Rows.Count - 1;
            GvSpareSalePurchaseByASC.DataSource = dtCurrentTable;
            GvSpareSalePurchaseByASC.DataBind();
            FillDropDowns();
        }
        FillDropDownToolTip();
    }
Example #6
0
    protected void btnAddRow_Click(object sender, EventArgs e)
    {
        GridViewRow  gvrow        = (GridViewRow)(((Control)sender).NamingContainer);
        DropDownList ddlSpareCode = (DropDownList)gvrow.FindControl("ddlSpareCode");
        TextBox      txtVendor    = (TextBox)gvrow.FindControl("txtVendor");

        TextBox txtQuantity      = (TextBox)gvrow.FindControl("txtQuantity");
        TextBox txtbillNo        = (TextBox)gvrow.FindControl("txtBillNo");
        TextBox txtBilldate      = (TextBox)gvrow.FindControl("txtBilldate");
        Label   lblrate          = (Label)gvrow.FindControl("lblrate");
        TextBox txtPurchasedRate = (TextBox)gvrow.FindControl("txtpurRate");

        TextBox txtComments = (TextBox)gvrow.FindControl("txtComments");

        DataTable dtCurrentTable;

        if (ViewState["DataTableSparePurchaseOutside"] != null)
        {
            dtCurrentTable = (DataTable)ViewState["DataTableSparePurchaseOutside"];
        }
        else
        {
            dtCurrentTable = new DataTable();
        }
        int ConsumeSpareId = Convert.ToInt32(ddlSpareCode.SelectedValue);
        //bool blnIsUpdate = true;
        //for (int i = 0; i < GvSpareSalePurchaseByASC.Rows.Count; i++)
        //{
        //    if (i != gvrow.RowIndex)
        //    {
        //        int PreConsumeSpareId = Convert.ToInt32(GvSpareSalePurchaseByASC.Rows[i].Cells[9].Text);
        //        if (PreConsumeSpareId == 0)
        //        {
        //            PreConsumeSpareId = Convert.ToInt32(GvSpareSalePurchaseByASC.Rows[i].Cells[9].Text);
        //        }
        //        if (ConsumeSpareId == PreConsumeSpareId)
        //        {
        //            blnIsUpdate = false;
        //            //ScriptManager.RegisterClientScriptBlock(btnAddRow_Click, GetType(), "Spare", "alert('Same Spare can not be entered.');", true);
        //        }
        //    }
        //}


        //if (blnIsUpdate == true)
        //{
        DataRow drCurrentRow = dtCurrentTable.NewRow();

        drCurrentRow["Spare_Id"] = ddlSpareCode.SelectedItem.Value;
        drCurrentRow["Spare"]    = ddlSpareCode.SelectedItem.Text;

        drCurrentRow["Vendor"] = txtVendor.Text;

        drCurrentRow["BillNo"]        = txtbillNo.Text.Trim();
        drCurrentRow["Billdate"]      = txtBilldate.Text.Trim();
        drCurrentRow["Amount"]        = Convert.ToInt32(txtQuantity.Text) * Convert.ToDecimal(txtPurchasedRate.Text);
        drCurrentRow["Rate"]          = lblrate.Text;
        drCurrentRow["PurchasedRate"] = txtPurchasedRate.Text;

        drCurrentRow["Quantity"] = txtQuantity.Text;
        drCurrentRow["Comments"] = txtComments.Text.Trim();

        dtCurrentTable.Rows.InsertAt(drCurrentRow, dtCurrentTable.Rows.Count - 1);
        ViewState["DataTableSparePurchaseOutside"] = dtCurrentTable;
        ViewState["EditIndex"] = dtCurrentTable.Rows.Count - 1;

        GvSpareSalePurchaseByASC.EditIndex  = dtCurrentTable.Rows.Count - 1;
        GvSpareSalePurchaseByASC.DataSource = dtCurrentTable;
        GvSpareSalePurchaseByASC.DataBind();
        FillSparesDropDown();
        //}
    }