protected void FindProblemToChangeAttach()
    {
        int problemid = Convert.ToInt32(Session["problemid"].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

            int chanid;

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

                if (ObjProblemToChange.Problemid != 0)
                {
                    deleteChkBxItem.Checked = true;
                }
            }
        }
    }
    protected void btnAttach_Click(object sender, EventArgs e)
    {
        int problemid = Convert.ToInt16(Session["problemid"].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 != "")
                {
                    ObjProblemToChange = ObjProblemToChange.Get_By_id(chanid, problemid);
                    if (ObjProblemToChange.Problemid == 0)
                    {
                        ObjProblemToChange.Changeid  = chanid;
                        ObjProblemToChange.Problemid = problemid;
                        ObjProblemToChange.Insert();
                    }
                }
            }
        }


        lblErrorMsg.Text = "Change is Attached to Current Problems";
    }
    protected void btnAttach_Click(object sender, EventArgs e)
    {
        int problemid = Convert.ToInt16(Session["problemid"].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 != "")
                {

                    ObjProblemToChange = ObjProblemToChange.Get_By_id(chanid, problemid);
                    if (ObjProblemToChange.Problemid == 0)
                    {
                        ObjProblemToChange.Changeid = chanid;
                        ObjProblemToChange.Problemid = problemid;
                        ObjProblemToChange.Insert();
                    }

                }

            }
        }

        lblErrorMsg.Text = "Change is Attached to Current Problems";
    }
    protected void btnAttach_Click(object sender, EventArgs e)
    {
        ///Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            int problemid = Convert.ToInt32(Session["problemid"].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 != "")
                    {

                        ObjProblemToChange = ObjProblemToChange.Get_By_id(chanid, problemid);
                        if (ObjProblemToChange.Problemid == 0)
                        {
                            ObjProblemToChange.Changeid = chanid;
                            ObjProblemToChange.Problemid = problemid;
                            ObjProblemToChange.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;
        }
    }
    protected void btnAttach_Click(object sender, EventArgs e)
    {///Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            int problemid = Convert.ToInt32(Session["problemid"].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 != "")
                    {
                        ObjProblemToChange = ObjProblemToChange.Get_By_id(chanid, problemid);
                        if (ObjProblemToChange.Problemid == 0)
                        {
                            ObjProblemToChange.Changeid  = chanid;
                            ObjProblemToChange.Problemid = problemid;
                            ObjProblemToChange.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;
        }
    }
 public int Update_Problem_To_Change_By_id(Problem_To_Change objProblem_To_Change)
 {
     return (int)ExecuteNonQuery(Sp_Problem_To_Change_Update, new object[] { objProblem_To_Change.Changeid, objProblem_To_Change.Problemid });
 }
 public int Insert_Problem_To_Change(Problem_To_Change ObjProblem_To_Change)
 {
     return (int)ExecuteNonQuery(Sp_Problem_To_Change_Insert, new object[] { ObjProblem_To_Change.Changeid, ObjProblem_To_Change.Problemid });
 }
    public object GenerateProblem_To_Change_mstObject(ref IDataReader returnData)
    {
        Problem_To_Change obj = new Problem_To_Change();

        while (returnData.Read())
        {
            obj.Problemid = (int)returnData["Changeid"];
            obj.Changeid = (int)returnData["Problemid"];

        }
        returnData.Close();
        returnData.Dispose();
        return obj;
    }
    public CollectionBase GenerateProblem_To_Change_mstCollection(ref IDataReader returnData)
    {
        BLLCollection<Problem_To_Change> col = new BLLCollection<Problem_To_Change>();
        while (returnData.Read())
        {

            Problem_To_Change obj = new Problem_To_Change();
            obj.Problemid = (int)returnData["ProblemId"];
            obj.Changeid = (int)returnData["ChangeId"];

            col.Add(obj);
        }
        returnData.Close();
        returnData.Dispose();
        return col;
    }
    protected void FindProblemToChangeAttach()
    {
        int problemid = Convert.ToInt16(Session["problemid"].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

            int chanid;

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

                if (ObjProblemToChange.Problemid != 0)
                {
                    deleteChkBxItem.Checked = true;
                }

            }

        }
    }