Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                ApplicationResult objResults    = new ApplicationResult();
                SectionBO         objSectionBO  = new SectionBO();
                SectionBL         objSectionBL  = new SectionBL();
                SectionTBO        objSectionTBO = new SectionTBO();

                objSectionBO.SectionName          = txtSectionName.Text;
                objSectionBO.SectionAvbbreviation = txtAbbreviation.Text;
                objSectionBO.Description          = txtSectionDesc.Text;
                objSectionBO.LastModifiedDate     = DateTime.UtcNow.AddHours(5.5).ToString();
                objSectionBO.LastModifiedUserID   = Convert.ToInt32(Session[ApplicationSession.USERID]);
                if (ValidateName() == true)
                {
                    ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Section Name or/and Section Abbrev " + txtSectionName.Text + "/" + txtAbbreviation.Text + " Already Exists.');</script>");
                    goto Exit;
                }
                #region RollBack Transaction Starts

                DatabaseTransaction.OpenConnectionTransation();
                if (ViewState["Mode"].ToString() == "Save")
                {
                    objResults = objSectionBL.Section_Insert(objSectionBO);
                    if (objResults != null)
                    {
                        if (objResults.resultDT.Rows.Count > 0)
                        {
                            ViewState["SectionMID"]          = Convert.ToInt32(objResults.resultDT.Rows[0][0].ToString());
                            objSectionTBO.SectionMID         = Convert.ToInt32(ViewState["SectionMID"].ToString());
                            objSectionTBO.SchoolMID          = Convert.ToInt32(Session[ApplicationSession.SCHOOLID]);
                            objSectionTBO.MediumMID          = 1;
                            objSectionTBO.LastModifiedDate   = DateTime.UtcNow.AddHours(5.5).ToString();
                            objSectionTBO.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]);
                            objResults = objSectionBL.SectionT_Insert(objSectionTBO);
                            if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS)
                            {
                            }
                        }
                    }

                    ClearAll();
                    ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Section Created Successfully.');</script>");
                    //GridDataBind();
                    PanelGrid_VisibilityMode(1);
                }
                else
                {
                    ApplicationResult objResultsUpdate = new ApplicationResult();
                    objSectionBO.SectionMID = Convert.ToInt32(ViewState["SectionMID"].ToString());
                    objResultsUpdate        = objSectionBL.Section_Update(objSectionBO);
                    if (objResultsUpdate.status == ApplicationResult.CommonStatusType.SUCCESS)
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('Section updated successfully.');</script>");

                        ClearAll();
                    }
                }
                DatabaseTransaction.CommitTransation();
                GridDataBind();
                #endregion
                Exit :;
            }
            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>");
            }
        }