Пример #1
0
 protected void gvTeacher_OnRowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "DeleteTeacher")
         {
             if (ViewState["Mode"].ToString() == "Save")
             {
                 GridViewRow row       = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
                 DataTable   dtTeacher = (DataTable)ViewState["Teacher"];
                 dtTeacher.Rows.RemoveAt(row.RowIndex);
                 dtTeacher.AcceptChanges();
                 ViewState["Teacher"] = dtTeacher;
                 gvTeacher.DataSource = (DataTable)ViewState["Teacher"];
                 gvTeacher.DataBind();
             }
             else if (ViewState["Mode"].ToString() == "Edit")
             {
                 ApplicationResult objResult     = new ApplicationResult();
                 SubjectTBL        objSubjectTbl = new SubjectTBL();
                 SubjectTBO        objSubjectTbo = new SubjectTBO();
                 objSubjectTbo.ClassMID    = Convert.ToInt32(ddlClass.SelectedValue);
                 objSubjectTbo.DivisionTID = Convert.ToInt32(ddlDivision.SelectedValue);
                 objSubjectTbo.SubjectMID  = Convert.ToInt32(ddlSubject.SelectedValue);
                 objSubjectTbo.EmployeeMID = Convert.ToInt32(e.CommandArgument.ToString());
                 objResult = objSubjectTbl.SubjectT_Delete_Association(objSubjectTbo);
                 if (objResult.status == ApplicationResult.CommonStatusType.SUCCESS)
                 {
                     objResult            = objSubjectTbl.SubjectT_Select(objSubjectTbo);
                     ViewState["Teacher"] = objResult.resutlDS.Tables[1];
                     gvTeacher.DataSource = (DataTable)ViewState["Teacher"];
                     gvTeacher.DataBind();
                     ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                                                        "<script>alert('Record deleted successfully.');</script>");
                 }
                 else
                 {
                     ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                                                        "<script>alert('You cannot delete this record because it is in used.');</script>");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error("Error", ex);
         ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                                            "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>");
     }
 }
Пример #2
0
 protected void gvSubjectAssociation_OnRowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         ApplicationResult objResult     = new ApplicationResult();
         SubjectTBL        objSubjectTbl = new SubjectTBL();
         SubjectTBO        objSubjectTbo = new SubjectTBO();
         objSubjectTbo.ClassMID    = Convert.ToInt32(ddlClass.SelectedValue);
         objSubjectTbo.DivisionTID = Convert.ToInt32(ddlDivision.SelectedValue);
         objSubjectTbo.SubjectMID  = Convert.ToInt32(e.CommandArgument.ToString());
         if (e.CommandName == "Edit1")
         {
             BindSubject(1);
             ViewState["Mode"]        = "Edit";
             objResult                = objSubjectTbl.SubjectT_Select(objSubjectTbo);
             ddlSubject.SelectedValue =
                 objResult.resutlDS.Tables[0].Rows[0][SubjectTBO.SUBJECTT_SUBJECTMID].ToString();
             ViewState["Teacher"] = objResult.resutlDS.Tables[1];
             gvTeacher.DataSource = (DataTable)ViewState["Teacher"];
             gvTeacher.DataBind();
             PanelVisibility(2);
         }
         else if (e.CommandName == "Delete1")
         {
             objResult = objSubjectTbl.SubjectT_Delete(objSubjectTbo);
             if (objResult.status == ApplicationResult.CommonStatusType.SUCCESS)
             {
                 ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                                                    "<script>alert('Record deleted successfully.');</script>");
                 BindSubjectAssociation();
             }
             else
             {
                 ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                                                    "<script>alert('You cannot delete this record because it is in used.');</script>");
             }
             ClearAll();
         }
     }
     catch (Exception ex)
     {
         logger.Error("Error", ex);
         ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                                            "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>");
     }
 }