Beispiel #1
0
        protected void GvBranchReceivedMaster_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "Deletea")
                {
                    #region DELETE
                    //     clear();

                    int id = int.Parse(e.CommandArgument.ToString());

                    Control ctrl = e.CommandSource as Control;
                    if (ctrl != null)
                    {
                        GridViewRow row = ctrl.Parent.NamingContainer as GridViewRow;

                        HiddenField HfTranDateGrid = (row.FindControl("HfTranDateGrid")) as HiddenField;


                        DataSet   ds           = BRANCH_RECMASLogicLayer.GetAllIDWiseBRANCH_REC_MASDetials(e.CommandArgument.ToString(), Convert.ToDateTime(HfTranDateGrid.Value.ToString()));
                        DataTable dt           = ds.Tables[0];
                        DataTable DtDetails    = ds.Tables[1];
                        DataTable DtBarcode    = ds.Tables[2];
                        DataTable DtNewBarcode = ds.Tables[3];

                        if (dt.Rows.Count > 0)
                        {
                            DivEntry.Visible = true;
                            DivView.Visible  = false;

                            HfCompCode.Value   = dt.Rows[0]["COMP_CODE"].ToString();
                            HfBranchCode.Value = dt.Rows[0]["BRANCH_CODE"].ToString();
                            FillToBranchOnUpdate(dt.Rows[0]["TO_BRANCH_CODE"].ToString());
                            HfTranDate.Value              = dt.Rows[0]["TRAN_DATE"].ToString();
                            HfTranNo.Value                = dt.Rows[0]["TRAN_NO"].ToString();
                            HfRef_TranDate.Value          = dt.Rows[0]["REF_TRAN_DATE"].ToString();
                            HfRef_TranNo.Value            = dt.Rows[0]["REF_TRAN_NO"].ToString();
                            HfTranType.Value              = dt.Rows[0]["TRAN_TYPE"].ToString();
                            TxtChallanNo.Text             = dt.Rows[0]["CHA_NO"].ToString();
                            TxtChallanDate.Text           = Convert.ToDateTime(dt.Rows[0]["CHA_DT"].ToString()).ToString("dd-MM-yyyy");
                            TxtSrNo.Text                  = dt.Rows[0]["SERIALNO"].ToString();
                            TxtTransportName.Text         = dt.Rows[0]["TRANSPORT"].ToString();
                            TxtVehclieNo.Text             = dt.Rows[0]["VEHICLE_NO"].ToString();
                            TxtDriverName.Text            = dt.Rows[0]["DRIVER_NAME"].ToString();
                            TxtDriverAddress.Text         = dt.Rows[0]["DRIVER_ADD"].ToString();
                            TxtMDLNo.Text                 = dt.Rows[0]["MDLNO"].ToString();
                            TxtMDLState.Text              = dt.Rows[0]["MDLSTATE"].ToString();
                            TxtLRDate.Text                = dt.Rows[0]["LR_DATE"].ToString();//Convert.ToDateTime(dt.Rows[0]["LR_DATE"].ToString()).ToString("dd-MM-yyyy");
                            TxtLRNumber.Text              = dt.Rows[0]["LR_NO"].ToString();
                            DdlReceivedFlag.SelectedValue = dt.Rows[0]["REC_FLAG"].ToString();
                            TxtReceivedDate.Text          = dt.Rows[0]["REC_DATE"].ToString();
                            TxtReceivedBy.Text            = dt.Rows[0]["REC_USERID"].ToString();


                            if (DtDetails.Rows.Count > 0)
                            {
                                GvBranchReceivedDetails.DataSource = DtDetails;
                                GvBranchReceivedDetails.DataBind();
                                GvBranchReceivedDetails.Enabled = false;
                            }

                            if (DdlReceivedFlag.SelectedValue == "N")
                            {
                                if (DtBarcode.Rows.Count > 0)
                                {
                                    GvBranchReceivedBarcodeGrid.DataSource = DtBarcode;
                                    GvBranchReceivedBarcodeGrid.DataBind();
                                    GvBranchReceivedBarcodeGrid.Enabled = false;
                                }
                            }
                            else
                            if (DdlReceivedFlag.SelectedValue == "Y")
                            {
                                GvBranchReceivedBarcodeGrid.DataSource = DtNewBarcode;
                                GvBranchReceivedBarcodeGrid.DataBind();
                                GvBranchReceivedBarcodeGrid.Enabled = false;
                            }

                            btnSave.Visible    = false;
                            btnDelete.Visible  = true;
                            Btncalldel.Visible = true;
                            BtncallUpd.Visible = false;
                            ControllerDisable();
                        }
                    }
                }

                #endregion


                if (e.CommandName == "Edita")
                {
                    #region EDIT
                    //     clear();

                    int id = int.Parse(e.CommandArgument.ToString());

                    Control ctrl = e.CommandSource as Control;
                    if (ctrl != null)
                    {
                        GridViewRow row = ctrl.Parent.NamingContainer as GridViewRow;

                        HiddenField HfTranDateGrid = (row.FindControl("HfTranDateGrid")) as HiddenField;


                        DataSet   ds           = BRANCH_RECMASLogicLayer.GetAllIDWiseBRANCH_REC_MASDetials(e.CommandArgument.ToString(), Convert.ToDateTime(HfTranDateGrid.Value.ToString()));
                        DataTable dt           = ds.Tables[0];
                        DataTable DtDetails    = ds.Tables[1];
                        DataTable DtBarcode    = ds.Tables[2];
                        DataTable DtNewBarcode = ds.Tables[3];

                        if (dt.Rows.Count > 0)
                        {
                            DivEntry.Visible = true;
                            DivView.Visible  = false;

                            HfCompCode.Value   = dt.Rows[0]["COMP_CODE"].ToString();
                            HfBranchCode.Value = dt.Rows[0]["BRANCH_CODE"].ToString();
                            FillToBranchOnUpdate(dt.Rows[0]["TO_BRANCH_CODE"].ToString());
                            HfTranDate.Value              = dt.Rows[0]["TRAN_DATE"].ToString();
                            HfTranNo.Value                = dt.Rows[0]["TRAN_NO"].ToString();
                            HfRef_TranDate.Value          = dt.Rows[0]["REF_TRAN_DATE"].ToString();
                            HfRef_TranNo.Value            = dt.Rows[0]["REF_TRAN_NO"].ToString();
                            HfTranType.Value              = dt.Rows[0]["TRAN_TYPE"].ToString();
                            TxtChallanNo.Text             = dt.Rows[0]["CHA_NO"].ToString();
                            TxtChallanDate.Text           = Convert.ToDateTime(dt.Rows[0]["CHA_DT"].ToString()).ToString("dd-MM-yyyy");
                            TxtSrNo.Text                  = dt.Rows[0]["SERIALNO"].ToString();
                            TxtTransportName.Text         = dt.Rows[0]["TRANSPORT"].ToString();
                            TxtVehclieNo.Text             = dt.Rows[0]["VEHICLE_NO"].ToString();
                            TxtDriverName.Text            = dt.Rows[0]["DRIVER_NAME"].ToString();
                            TxtDriverAddress.Text         = dt.Rows[0]["DRIVER_ADD"].ToString();
                            TxtMDLNo.Text                 = dt.Rows[0]["MDLNO"].ToString();
                            TxtMDLState.Text              = dt.Rows[0]["MDLSTATE"].ToString();
                            TxtLRDate.Text                = dt.Rows[0]["LR_DATE"].ToString();//Convert.ToDateTime(dt.Rows[0]["LR_DATE"].ToString()).ToString("dd-MM-yyyy");
                            TxtLRNumber.Text              = dt.Rows[0]["LR_NO"].ToString();
                            DdlReceivedFlag.SelectedValue = dt.Rows[0]["REC_FLAG"].ToString();
                            TxtReceivedDate.Text          = dt.Rows[0]["REC_DATE"].ToString();
                            TxtReceivedBy.Text            = dt.Rows[0]["REC_USERID"].ToString();


                            if (DtDetails.Rows.Count > 0)
                            {
                                GvBranchReceivedDetails.DataSource = DtDetails;
                                GvBranchReceivedDetails.DataBind();
                                GvBranchReceivedDetails.Enabled = false;
                            }


                            if (DdlReceivedFlag.SelectedValue == "N")
                            {
                                if (DtBarcode.Rows.Count > 0)
                                {
                                    GvBranchReceivedBarcodeGrid.DataSource = DtBarcode;
                                    GvBranchReceivedBarcodeGrid.DataBind();
                                    GvBranchReceivedBarcodeGrid.Enabled = false;
                                }
                            }
                            else
                            if (DdlReceivedFlag.SelectedValue == "Y")
                            {
                                GvBranchReceivedBarcodeGrid.DataSource = DtNewBarcode;
                                GvBranchReceivedBarcodeGrid.DataBind();
                                GvBranchReceivedBarcodeGrid.Enabled = false;
                            }

                            BtncallUpd.Text = "UPDATE";

                            #endregion
                        }
                    }
                    #region CHECK UPDATE RIGHTS
                    if (Session["UPDATE"] != null)
                    {
                        if (Session["UPDATE"].ToString() == "Y")
                        {
                            ControllerEnable();
                        }
                        else
                        {
                            ControllerDisable();
                        }
                    }
                    #endregion
                    Btncalldel.Visible = false;
                    BtncallUpd.Visible = true;
                    btnSave.Visible    = true;
                    UserRights();
                }


                if (e.CommandName == "Viewa")
                {
                    #region SET TEXT ON VIEW
                    //     clear();

                    int id = int.Parse(e.CommandArgument.ToString());

                    Control ctrl = e.CommandSource as Control;
                    if (ctrl != null)
                    {
                        GridViewRow row = ctrl.Parent.NamingContainer as GridViewRow;

                        HiddenField HfTranDateGrid = (row.FindControl("HfTranDateGrid")) as HiddenField;


                        DataSet   ds           = BRANCH_RECMASLogicLayer.GetAllIDWiseBRANCH_REC_MASDetials(e.CommandArgument.ToString(), Convert.ToDateTime(HfTranDateGrid.Value.ToString()));
                        DataTable dt           = ds.Tables[0];
                        DataTable DtDetails    = ds.Tables[1];
                        DataTable DtBarcode    = ds.Tables[2];
                        DataTable DtNewBarcode = ds.Tables[3];

                        if (dt.Rows.Count > 0)
                        {
                            DivEntry.Visible = true;
                            DivView.Visible  = false;

                            HfCompCode.Value   = dt.Rows[0]["COMP_CODE"].ToString();
                            HfBranchCode.Value = dt.Rows[0]["BRANCH_CODE"].ToString();
                            FillToBranchOnUpdate(dt.Rows[0]["TO_BRANCH_CODE"].ToString());
                            HfTranDate.Value              = dt.Rows[0]["TRAN_DATE"].ToString();
                            HfTranNo.Value                = dt.Rows[0]["TRAN_NO"].ToString();
                            HfRef_TranDate.Value          = dt.Rows[0]["REF_TRAN_DATE"].ToString();
                            HfRef_TranNo.Value            = dt.Rows[0]["REF_TRAN_NO"].ToString();
                            HfTranType.Value              = dt.Rows[0]["TRAN_TYPE"].ToString();
                            TxtChallanNo.Text             = dt.Rows[0]["CHA_NO"].ToString();
                            TxtChallanDate.Text           = Convert.ToDateTime(dt.Rows[0]["CHA_DT"].ToString()).ToString("dd-MM-yyyy");
                            TxtSrNo.Text                  = dt.Rows[0]["SERIALNO"].ToString();
                            TxtTransportName.Text         = dt.Rows[0]["TRANSPORT"].ToString();
                            TxtVehclieNo.Text             = dt.Rows[0]["VEHICLE_NO"].ToString();
                            TxtDriverName.Text            = dt.Rows[0]["DRIVER_NAME"].ToString();
                            TxtDriverAddress.Text         = dt.Rows[0]["DRIVER_ADD"].ToString();
                            TxtMDLNo.Text                 = dt.Rows[0]["MDLNO"].ToString();
                            TxtMDLState.Text              = dt.Rows[0]["MDLSTATE"].ToString();
                            TxtLRDate.Text                = dt.Rows[0]["LR_DATE"].ToString();//Convert.ToDateTime(dt.Rows[0]["LR_DATE"].ToString()).ToString("dd-MM-yyyy");
                            TxtLRNumber.Text              = dt.Rows[0]["LR_NO"].ToString();
                            DdlReceivedFlag.SelectedValue = dt.Rows[0]["REC_FLAG"].ToString();
                            TxtReceivedDate.Text          = dt.Rows[0]["REC_DATE"].ToString();
                            TxtReceivedBy.Text            = dt.Rows[0]["REC_USERID"].ToString();


                            if (DtDetails.Rows.Count > 0)
                            {
                                GvBranchReceivedDetails.DataSource = DtDetails;
                                GvBranchReceivedDetails.DataBind();
                                GvBranchReceivedDetails.Enabled = false;
                            }

                            if (DdlReceivedFlag.SelectedValue == "N")
                            {
                                if (DtBarcode.Rows.Count > 0)
                                {
                                    GvBranchReceivedBarcodeGrid.DataSource = DtBarcode;
                                    GvBranchReceivedBarcodeGrid.DataBind();
                                    GvBranchReceivedBarcodeGrid.Enabled = false;
                                }
                            }
                            else
                            if (DdlReceivedFlag.SelectedValue == "Y")
                            {
                                GvBranchReceivedBarcodeGrid.DataSource = DtNewBarcode;
                                GvBranchReceivedBarcodeGrid.DataBind();
                                GvBranchReceivedBarcodeGrid.Enabled = false;
                            }
                        }
                    }

                    #endregion
                    ControllerDisable();
                    btnSave.Visible    = false;
                    Btncalldel.Visible = false;
                    BtncallUpd.Visible = false;
                    UserRights();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #2
0
        private void SetInitialRow()
        {
            DataTable table = new DataTable();
            DataRow   dr    = null;

            table.Columns.Add("COMP_CODE", typeof(string));
            table.Columns.Add("TRAN_DATE", typeof(string));
            table.Columns.Add("TRAN_NO", typeof(string));
            table.Columns.Add("SRNO", typeof(string));
            table.Columns.Add("REF_TRAN_DATE", typeof(string));
            table.Columns.Add("REF_TRAN_NO", typeof(string));
            table.Columns.Add("REF_SRNO", typeof(string));
            table.Columns.Add("SCODE", typeof(string));
            table.Columns.Add("QTY", typeof(string));
            table.Columns.Add("RATE", typeof(string));
            table.Columns.Add("AMT", typeof(string));
            table.Columns.Add("DIS_PER", typeof(string));
            table.Columns.Add("DIS_AMT", typeof(string));
            table.Columns.Add("G_AMT", typeof(string));
            table.Columns.Add("GST_RATE", typeof(string));
            table.Columns.Add("GST_AMT", typeof(string));
            table.Columns.Add("CGST_RATE", typeof(string));
            table.Columns.Add("CGST_AMT", typeof(string));
            table.Columns.Add("SGST_RATE", typeof(string));
            table.Columns.Add("SGST_AMT", typeof(string));
            table.Columns.Add("IGST_RATE", typeof(string));
            table.Columns.Add("IGST_AMT", typeof(string));
            table.Columns.Add("T_AMT", typeof(string));
            table.Columns.Add("STATUS", typeof(string));

            dr = table.NewRow();
            dr["COMP_CODE"]     = string.Empty;
            dr["TRAN_DATE"]     = string.Empty;
            dr["TRAN_NO"]       = string.Empty;
            dr["SRNO"]          = string.Empty;
            dr["REF_TRAN_DATE"] = string.Empty;
            dr["REF_TRAN_NO"]   = string.Empty;
            dr["REF_SRNO"]      = string.Empty;
            dr["SCODE"]         = "0";
            dr["QTY"]           = "0";
            dr["RATE"]          = string.Empty;
            dr["AMT"]           = string.Empty;
            dr["DIS_PER"]       = string.Empty;
            dr["DIS_AMT"]       = string.Empty;
            dr["G_AMT"]         = string.Empty;
            dr["GST_RATE"]      = string.Empty;
            dr["GST_AMT"]       = string.Empty;
            dr["CGST_RATE"]     = string.Empty;
            dr["CGST_AMT"]      = string.Empty;
            dr["SGST_RATE"]     = string.Empty;
            dr["SGST_AMT"]      = string.Empty;
            dr["IGST_RATE"]     = string.Empty;
            dr["IGST_AMT"]      = string.Empty;
            dr["T_AMT"]         = string.Empty;
            dr["STATUS"]        = string.Empty;

            table.Rows.Add(dr);

            ViewState["CurrentTable"] = table;

            GvBranchReceivedDetails.DataSource = table;
            GvBranchReceivedDetails.DataBind();
        }