Exemple #1
0
    protected void btnAttach_Click(object sender, EventArgs e)
    {
        int incidentid = Convert.ToInt16(Session["incident"].ToString());

        foreach (GridViewRow gv in grdvwChange.Rows)
        {
            string gvIDs;
            // Declare local variable deleteChkBxItem of Checkbox type to get the Checkbox Instance of Grid Row
            CheckBox deleteChkBxItem = (CheckBox)gv.FindControl("deleteRec");
            // If deleteChkBxItem is Checked then ,mapped Current site to this user
            if (deleteChkBxItem.Checked)
            {
                int chanid;

                gvIDs  = ((Label)gv.FindControl("Changeid")).Text.ToString();
                chanid = Convert.ToInt16(gvIDs);
                // Check if gvIDs is not null
                if (gvIDs != "")
                {
                    ObjincidentToChange = ObjincidentToChange.Get_By_id(incidentid, chanid);
                    if (ObjincidentToChange.Changeid == 0)
                    {
                        ObjincidentToChange.Changeid   = chanid;
                        ObjincidentToChange.Incidentid = incidentid;

                        ObjincidentToChange.Insert();
                    }
                }
            }
        }


        lblErrorMsg.Text = "Change is Attached to Current Problems";
    }
Exemple #2
0
    protected void btnAttach_Click(object sender, EventArgs e)
    {//Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            int incidentid = Convert.ToInt32(Session["incident"].ToString());
            foreach (GridViewRow gv in grdvwChange.Rows)
            {
                string gvIDs;
                // Declare local variable deleteChkBxItem of Checkbox type to get the Checkbox Instance of Grid Row
                CheckBox deleteChkBxItem = (CheckBox)gv.FindControl("deleteRec");
                // If deleteChkBxItem is Checked then ,mapped Current site to this user
                if (deleteChkBxItem.Checked)
                {
                    int chanid;

                    gvIDs  = ((Label)gv.FindControl("Changeid")).Text.ToString();
                    chanid = Convert.ToInt32(gvIDs);
                    // Check if gvIDs is not null
                    if (gvIDs != "")
                    {
                        ObjincidentToChange = ObjincidentToChange.Get_By_id(incidentid, chanid);
                        if (ObjincidentToChange.Changeid == 0)
                        {
                            ObjincidentToChange.Changeid   = chanid;
                            ObjincidentToChange.Incidentid = incidentid;

                            ObjincidentToChange.Insert();
                        }
                    }
                }
            }


            lblErrorMsg.Text = "Change is Attached to Current Problems";
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }