Exemple #1
0
    protected void gvPreDeliveryInspection_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == null)
        {
            return;
        }
        switch (e.CommandName)
        {
        case "pdiEdit":
            ViewState["PreDeliveryInspectionID"] = e.CommandArgument.ToString();
            var dspdiedit = _predelinsp.GetPreDeliveryInspection();
            var drpdi     = dspdiedit.Tables[0].Select("PreDeliveryInspectionID=" + e.CommandArgument);
            ClearControls();
            ddlTRNo.Visible    = false;
            txtTRNo.Visible    = true;
            txtTRNo.Text       = drpdi[0][7].ToString();
            ViewState["VehId"] = Convert.ToInt16(drpdi[0][1].ToString());
            ddlVehicleReceived.Items.FindByValue(drpdi[0][2].ToString()).Selected = true;
            txtReceivedDate.Text = drpdi[0][3].ToString();
            txtOdometer.Text     = drpdi[0][4].ToString();
            txtPDIBy.Text        = drpdi[0][5].ToString();
            txtPDIDate.Text      = drpdi[0][6].ToString();
            var datesUpdt = _fmsGeneral.GetFabInspDate(int.Parse(ViewState["VehId"].ToString()));
            var dtUpdat   = Convert.ToDateTime(datesUpdt.Tables[0].Rows[0]["FVDInspectedDate"].ToString());
            vehicleFabInspDate.Value         = dtUpdat.ToString(CultureInfo.InvariantCulture);
            pnlPreDeliveryInspection.Visible = true;
            btSave.Text = "Update";
            break;

        case "pdiDelete":
            _predelinsp.PreDeliveryInspectionID = int.Parse(e.CommandArgument.ToString());
            var output = _predelinsp.ValidatePDIRegVehicle();
            switch (output)
            {
            case 0:
                _ret = _predelinsp.DelPreDeliveryInspection();
                GetPreDeliveryInspection();
                Show(_ret == 1 ? "Record Deleted Successfully" : "Error");
                break;

            default:
                Show("Vehicle Registation has been completed, can not delete");
                break;
            }

            ClearControls();
            btSave.Text = "Save";
            ViewState["PreDeliveryInspectionID"] = null;
            GetTrNo();
            break;
        }
    }