コード例 #1
0
        protected void GvData_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                int         SaveStatus = 0;
                DataTable   dtInfo     = new DataTable();
                GridViewRow gvrow      = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
                hdUniqueId.Value = GvData.DataKeys[gvrow.RowIndex].Value.ToString();
                // fill the Location information for edit
                if (e.CommandName == "EditEntry")
                {
                    objValidateData.ClearAllInputField(pnlDataEntry);
                    dtInfo = objLtmsService.GetRequisitionDtlById(Convert.ToInt64(hdUniqueId.Value));
                    if (dtInfo.Rows.Count > 0)
                    {
                        SaveStatus           = Convert.ToInt16(dtInfo.Rows[0]["SaveStatus"].ToString().ToUpper());
                        txtReqCode.Text      = dtInfo.Rows[0]["ReqCode"].ToString();
                        txtReqDate.Text      = Convert.ToDateTime(dtInfo.Rows[0]["ReqDate"]).ToString("dd-MMM-yyyy");
                        txtDrawDate.Text     = Convert.ToDateTime(dtInfo.Rows[0]["DrawDate"]).ToString("dd-MMM-yyyy");
                        txtDelivaryDate.Text = Convert.ToDateTime(dtInfo.Rows[0]["PressDeliveryDate"]).ToString("dd-MMM-yyyy");

                        ddlLotteryType.SelectedValue = dtInfo.Rows[0]["LotteryTypeId"].ToString();
                        txtQty.MaxLength             = Convert.ToInt16(dtInfo.Rows[0]["NoOfDigit"].ToString());

                        ddlLotteryType_SelectedIndexChanged(ddlLotteryType, null);
                        if (ddlLotteryName.Items.Count > 0)
                        {
                            txtSizeOfTicket.Text = dtInfo.Rows[0]["SizeOfTicket"].ToString();
                            txtPaperQuality.Text = dtInfo.Rows[0]["PaperQuality"].ToString();

                            ddlLotteryName.SelectedValue = dtInfo.Rows[0]["GovermentOrderId"].ToString();
                            if (SaveStatus == 0)
                            {
                                ddlLotteryName_SelectedIndexChanged(ddlLotteryName, null);
                            }
                        }
                        ddlLotteryType.Enabled = false;
                        ddlLotteryName.Enabled = false;
                        txtDrawNo.ReadOnly     = true;
                        txtDrawNo.Text         = dtInfo.Rows[0]["DrawNo"].ToString();
                        txtQty.Text            = dtInfo.Rows[0]["Qty"].ToString();
                        txtGovermentOrder.Text = dtInfo.Rows[0]["GovermentOrder"].ToString();
                        txtSlabLimit.Text      = dtInfo.Rows[0]["SlabLimit"].ToString();
                        btnSave.Visible        = true;
                        btnSubmit.Visible      = true;
                        if (SaveStatus == 1 || SaveStatus == 2 || SaveStatus == 4 || SaveStatus == 6 || SaveStatus > 7)
                        {
                            btnSave.Visible   = false;
                            btnSubmit.Visible = false;
                        }
                    }
                    dtInfo.Dispose();
                    pnlDataEntry.Visible   = true;
                    pnlDataDisplay.Visible = false;
                    btnSave.Text           = "Update";
                    // lblSubHead.Text = "Update Location Information";
                    ddlLotteryType.Focus();
                }
                //Delete the location information
                if (e.CommandName == "DeleteEntry")
                {
                    if (objMenuOptions.AllowDelete == false)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('You do not have proper privilege for deleting a record.');", true);
                        return;
                    }

                    bool isDeleted = objLtmsService.DeleteInRequisition(Convert.ToInt64(hdUniqueId.Value));
                    if (isDeleted == true)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Requisition information deleted.');", true);
                        BindGvData();
                    }
                }
                dtInfo.Dispose();
            }
            catch (Exception Ex)
            {
                objValidateData.SaveSystemErrorLog(Ex, Request.UserHostAddress);
                var message = new JavaScriptSerializer().Serialize("Some Error has occurred while performing your activity. Please contact the System Administrator for further assistance.");
                var script  = string.Format("alert({0});", message);
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "", script, true);
            }
        }