예제 #1
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "Dlt")
            {
                DataTable dt = new DataTable();
                StateCode = Session["StateCd"].ToString();
                UserName  = Session["UsrName"].ToString();
                GridViewRow gvrow = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                DELETE = "D";
                Label lblDCode = (Label)gvrow.FindControl("lblDCode");
                Label lblDName = (Label)gvrow.FindControl("lblDName");
                dt = objDist.DeleteDiseaseBAL(lblDCode.Text, lblDName.Text, DELETE, ConnKey);
                if (dt.Rows.Count > 0)
                {
                    objCommon.ShowAlertMessage(dt.Rows[0][0].ToString());
                    txtDiseaseTCode.Text = "";
                    txtDiseaseName.Text  = "";
                    btn_Save.Visible     = true;
                    btn_Update.Visible   = false;
                    Viewdata();
                }
                else
                {
                    txtDiseaseTCode.Text = "";
                    txtDiseaseName.Text  = "";
                    btn_Save.Visible     = true;
                    btn_Update.Visible   = false;
                    objCommon.ShowAlertMessage(dt.Rows[0][0].ToString());
                }
            }

            if (e.CommandName == "Edt")
            {
                GridViewRow gvrow = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                DELETE = "D";
                txtDiseaseTCode.Text    = ((Label)(gvrow.FindControl("lblDCode"))).Text;
                txtDiseaseName.Text     = ((Label)(gvrow.FindControl("lblDName"))).Text;
                txtDiseaseTCode.Enabled = false;
                btn_Update.Visible      = true;
                btn_Save.Visible        = false;
            }
            Viewdata();
        }
        catch (Exception ex)
        {
            ExceptionLogging.SendExcepToDB(ex, Session["UsrName"].ToString(), Request.ServerVariables["REMOTE_ADDR"].ToString());
            Response.Redirect("~/Error.aspx");
        }
    }