Ejemplo n.º 1
0
 private void BindInnerGV()
 {
     GVInner.DataSource = ViewState["DTTable"] as DataTable;
     GVInner.DataBind();
     InnerGVData();
 }
Ejemplo n.º 2
0
    protected void GVKitMaterial_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            int recordId = Convert.ToInt32(e.CommandArgument);
            Session["RecordId"] = recordId;

            #region For Edit Record
            if (e.CommandName == "EditRecord")
            {
                SqlParameter[] arrParam = new SqlParameter[2];
                arrParam[0] = new SqlParameter("@Action", "SELECT_ByID");
                arrParam[1] = new SqlParameter("@ID", recordId);
                DataSet   DSRecords = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_KitMaterial_CRUD", arrParam);
                DataTable DTRecords = DSRecords.Tables[0];
                if (DTRecords.Rows.Count > 0)
                {
                    MVMatrialKit.ActiveViewIndex = 1;
                    TBName.Text        = DTRecords.Rows[0]["Name"].ToString();
                    TBBarcode.Text     = DTRecords.Rows[0]["Barcode"].ToString();
                    TBProductCode.Text = DTRecords.Rows[0]["ProductCode"].ToString();
                    TBHSN.Text         = DTRecords.Rows[0]["HSNCode"].ToString();
                    TBUOM.Text         = DTRecords.Rows[0]["UOM"].ToString();
                    TBCategory.Text    = DTRecords.Rows[0]["Category"].ToString();
                    TBDescription.Text = DTRecords.Rows[0]["Description"].ToString();
                    lblTotalQty.Text   = DTRecords.Rows[0]["TotalQty"].ToString();
                    lblTotalValue.Text = DTRecords.Rows[0]["TotalValue"].ToString();
                    ImgLogo.ImageUrl   = DTRecords.Rows[0]["Image"].ToString();
                    BindRowItemList();

                    SqlParameter[] arrParam2 = new SqlParameter[2];
                    arrParam2[0] = new SqlParameter("@Action", "SELECT_ByMID");
                    arrParam2[1] = new SqlParameter("@MID", recordId);
                    DataSet DSInner = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_KitDetails_CRUD", arrParam2);
                    // Bind Table
                    CreateDTTable();
                    TempDT = ViewState["DTTable"] as DataTable;
                    for (int i = 0; i < DSInner.Tables[0].Rows.Count; i++)
                    {
                        string    SelQuery  = "SELECT * FROM RawMaterial Where ID='" + DSInner.Tables[0].Rows[i]["PID"] + "'";
                        DataTable DTProduct = clsConnectionSql.filldt(SelQuery);

                        double ItemPrice, Quantity, GTotal;
                        Quantity  = Convert.ToDouble(DSInner.Tables[0].Rows[i]["Qty"].ToString());
                        ItemPrice = Convert.ToDouble(DTProduct.Rows[0]["PurPrice"].ToString());
                        GTotal    = ItemPrice * Quantity;

                        TempDT.Rows.Add(DTProduct.Rows[0]["ID"],
                                        DTProduct.Rows[0]["Name"].ToString(),
                                        DTProduct.Rows[0]["Barcode"].ToString(),
                                        Quantity.ToString("0.00"),
                                        ItemPrice.ToString("0.00"),
                                        GTotal.ToString("0.00"));
                    }
                    GVInner.DataSource = TempDT;
                    GVInner.DataBind();
                    ViewState["DTTable"] = TempDT;
                    btnSubmit.Text       = "Update";
                }
            }
            #endregion

            #region For Delete Record
            if (e.CommandName == "DeleteRecord")
            {
                // Delete Image From Folder
                SqlParameter[] arrParamDel = new SqlParameter[2];
                arrParamDel[0] = new SqlParameter("@Action", "SELECT_ByID");
                arrParamDel[1] = new SqlParameter("@ID", recordId);
                DataSet DSRecords = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_KitMaterial_CRUD", arrParamDel);
                if (DSRecords.Tables[0].Rows[0]["Image"].ToString() != "" && DSRecords.Tables[0].Rows[0]["Image"].ToString() != "~/AdminImages/noimg.png")
                {
                    File.Delete(Server.MapPath(DSRecords.Tables[0].Rows[0]["Image"].ToString()));
                }

                SqlParameter[] arrParam = new SqlParameter[2];
                arrParam[0] = new SqlParameter("@Action", "DELETE");
                arrParam[1] = new SqlParameter("@ID", recordId);
                int Result = SqlHelper.ExecuteNonQuery(Connection.connect(), CommandType.StoredProcedure, "SP_KitMaterial_CRUD", arrParam);
            }
            #endregion

            #region For Change Status
            if (e.CommandName == "ChangeStatus")
            {
                SqlParameter[] arrParam = new SqlParameter[2];
                arrParam[0] = new SqlParameter("@Action", "SELECT_ByID");
                arrParam[1] = new SqlParameter("@ID", recordId);
                DataSet   DSRecords = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_KitMaterial_CRUD", arrParam);
                DataTable DTRecords = DSRecords.Tables[0];
                if (DTRecords.Rows.Count > 0)
                {
                    #region Change Status True To False
                    if (DTRecords.Rows[0]["Status"].ToString() == "True")
                    {
                        SqlParameter[] arrParam2 = new SqlParameter[3];
                        arrParam2[0] = new SqlParameter("@Action", "UPDATE_Status");
                        arrParam2[1] = new SqlParameter("@Status", false);
                        arrParam2[2] = new SqlParameter("@ID", recordId);
                        int Result = SqlHelper.ExecuteNonQuery(Connection.connect(), CommandType.StoredProcedure, "SP_KitMaterial_CRUD", arrParam2);
                    }
                    #endregion

                    #region Change Status False TO True
                    if (DTRecords.Rows[0]["Status"].ToString() == "False")
                    {
                        SqlParameter[] arrParam2 = new SqlParameter[3];
                        arrParam2[0] = new SqlParameter("@Action", "UPDATE_Status");
                        arrParam2[1] = new SqlParameter("@Status", true);
                        arrParam2[2] = new SqlParameter("@ID", recordId);
                        int Result = SqlHelper.ExecuteNonQuery(Connection.connect(), CommandType.StoredProcedure, "SP_KitMaterial_CRUD", arrParam2);
                    }
                    #endregion
                }
            }
            #endregion

            BindGVKitMaterial();
        }
        catch (Exception ex)
        {
            ShowMessage(ex.Message, MessageType.Error);
        }
    }
Ejemplo n.º 3
0
    protected void GVItemDetail_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            int recordId = Convert.ToInt32(e.CommandArgument);
            Session["RecordID"] = recordId;
            if (e.CommandName == "EditRecord")
            {
                SqlParameter[] arr = new SqlParameter[2];
                arr[0] = new SqlParameter("@Action", "SELECT_ByID");
                arr[1] = new SqlParameter("@ID", recordId);
                DataSet   ds = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_ItemRequestMaster_CRUD", arr);
                DataTable dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    MVRequest.ActiveViewIndex = 1;
                    LBLReqNo.Text             = dt.Rows[0]["ReqNo"].ToString();
                    LBLTOtQut.Text            = dt.Rows[0]["TotalQty"].ToString();
                    DDLComLoc.SelectedValue   = dt.Rows[0]["ComId"].ToString();
                    BindComForRequest();
                    LBLTotVal.Text  = dt.Rows[0]["TotalValue"].ToString();
                    LBReqDate.Text  = dt.Rows[0]["ReqDate"].ToString();
                    txtDelDate.Text = dt.Rows[0]["DeliverDate"].ToString();
                    BindDDLNGO(DDLComLoc.SelectedValue);
                    DDLNgoLoc.ClearSelection();
                    DDLNgoLoc.SelectedValue = dt.Rows[0]["NgoId"].ToString();
                    DDLItemType.ClearSelection();
                    DDLItemList.ClearSelection();
                    txtRemarks.Text = dt.Rows[0]["Remark"].ToString();
                    txtTermCon.Text = dt.Rows[0]["TermAndCondition"].ToString();
                    BindDDLGodown(DDLComLoc.SelectedValue);
                    DDLDelTo.SelectedValue    = dt.Rows[0]["DeliverTo"].ToString();
                    DDLItemType.SelectedValue = dt.Rows[0]["ItemType"].ToString();
                    switch (DDLItemType.SelectedValue)
                    {
                    case "1":
                        BindItemKitTypeList();
                        break;

                    case "2":
                        BindItemFinishTypeList();
                        break;

                    default:
                        break;
                    }
                    btnSubmit.Text = "Update";
                    SqlParameter[] arrParam2 = new SqlParameter[2];
                    arrParam2[0] = new SqlParameter("@Action", "Select_ByReqId");
                    arrParam2[1] = new SqlParameter("@ReqId", recordId);
                    DataSet DSInner = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_ItemRequestDetail_CRUD", arrParam2);
                    // Bind Table
                    CreateDTTable();
                    TempDT = ViewState["DTTable"] as DataTable;
                    for (int i = 0; i < DSInner.Tables[0].Rows.Count; i++)
                    {
                        string    SelQuery = "SELECT * FROM KitMaterial Where ID='" + DSInner.Tables[0].Rows[i]["ItemId"] + "'";
                        DataTable DTProduct = clsConnectionSql.filldt(SelQuery);
                        double    ItemPrice, Quantity, GTotal;
                        Quantity  = Convert.ToDouble(DSInner.Tables[0].Rows[i]["Qty"].ToString());
                        ItemPrice = Convert.ToDouble(DTProduct.Rows[0]["TotalValue"].ToString());
                        GTotal    = ItemPrice * Quantity;
                        TempDT.Rows.Add(DTProduct.Rows[0]["ID"],
                                        DTProduct.Rows[0]["Image"].ToString(),
                                        DTProduct.Rows[0]["Name"].ToString(),
                                        DTProduct.Rows[0]["ProductCode"].ToString(),
                                        DTProduct.Rows[0]["HSNCode"].ToString(),
                                        DTProduct.Rows[0]["BarCode"].ToString(),
                                        DTProduct.Rows[0]["UOM"].ToString(),
                                        Quantity.ToString("0.00"),
                                        ItemPrice.ToString("0.00"),
                                        GTotal.ToString("0.00"));
                    }
                    GVInner.DataSource = TempDT;
                    GVInner.DataBind();
                    ViewState["DTTable"] = TempDT;
                }
                BindInnerGV();
            }
            else if (e.CommandName == "DeleteRecord")
            {
                SqlParameter[] arr = new SqlParameter[2];
                arr[0] = new SqlParameter("@Action", "DELETE");
                arr[1] = new SqlParameter("@ID", recordId);
                DataSet ds = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_ItemRequestMaster_CRUD", arr);
            }

            if (e.CommandName == "CheckStatus")
            {
                SqlParameter[] arr = new SqlParameter[2];
                arr[0] = new SqlParameter("@Action", "SELECT_ByID");
                arr[1] = new SqlParameter("@ID", recordId);
                DataSet   ds = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_ItemRequestMaster_CRUD", arr);
                DataTable dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["ReqStatus"].ToString() == "True")
                    {
                        SqlParameter[] arr1 = new SqlParameter[3];
                        arr1[0] = new SqlParameter("@Action", "UPDATE_Status");
                        arr1[1] = new SqlParameter("@ReqStatus", false);
                        arr1[2] = new SqlParameter("@ID", recordId);
                        int result = SqlHelper.ExecuteNonQuery(Connection.connect(), CommandType.StoredProcedure, "SP_ItemRequestMaster_CRUD", arr1);
                    }
                    if (dt.Rows[0]["ReqStatus"].ToString() == "False")
                    {
                        SqlParameter[] arr1 = new SqlParameter[3];
                        arr1[0] = new SqlParameter("@Action", "UPDATE_Status");
                        arr1[1] = new SqlParameter("@ReqStatus", true);
                        arr1[2] = new SqlParameter("@ID", recordId);
                        int result = SqlHelper.ExecuteNonQuery(Connection.connect(), CommandType.StoredProcedure, "SP_ItemRequestMaster_CRUD", arr1);
                    }
                }
            }

            BindGVDetail();
        }
        catch (Exception ex)
        {
            ShowMessage(ex.Message, MessageType.Error);
        }
    }