Example #1
0
 protected void btnSaveClass_OnClick(object sender, EventArgs e)
 {
     try
     {
         ApplicationResult objResult   = new ApplicationResult();
         PeriodBO          objPeriodBo = new PeriodBO();
         PeriodBL          objPeriodBl = new PeriodBL();
         objPeriodBo.DayName   = ddlDay.SelectedItem.ToString();
         objPeriodBo.DayNo     = Convert.ToInt32(ddlDay.SelectedValue);
         objPeriodBo.ClassMID  = Convert.ToInt32(ddlClass.SelectedValue);
         objPeriodBo.SchoolMID = Convert.ToInt32(Session[ApplicationSession.SCHOOLID].ToString());
         int intCount = Convert.ToInt32(hfNoOfPeriod.Value);
         if (ViewState["Mode"].ToString() == "Save")
         {
             for (int i = 1; i <= intCount; i++)
             {
                 objPeriodBo.PeriodNo = i;
                 TextBox txt1 =
                     Page.Master.FindControl("ContentPlaceHolder1").FindControl("txtFromHH" + i.ToString()) as
                     TextBox;
                 TextBox txt2 =
                     Page.Master.FindControl("ContentPlaceHolder1").FindControl("txtFromMM" + i.ToString()) as
                     TextBox;
                 string a, b, c, d;
                 a = txt1.Text;
                 b = txt2.Text;
                 if (txt1.Text == "")
                 {
                     a = "--";
                 }
                 if (txt2.Text == "")
                 {
                     b = "--";
                 }
                 objPeriodBo.FromTime = a + ":" + b;
                 TextBox txt3 =
                     Page.Master.FindControl("ContentPlaceHolder1").FindControl("txtToHH" + i.ToString()) as
                     TextBox;
                 TextBox txt4 =
                     Page.Master.FindControl("ContentPlaceHolder1").FindControl("txtToMM" + i.ToString()) as
                     TextBox;
                 c = txt3.Text;
                 d = txt4.Text;
                 if (c == "")
                 {
                     c = "--";
                 }
                 if (d == "")
                 {
                     d = "--";
                 }
                 objPeriodBo.ToTime        = c + ":" + d;
                 objPeriodBo.CreatedUserID = Convert.ToInt32(Session[ApplicationSession.USERID].ToString());
                 objPeriodBo.CreatedDate   = DateTime.UtcNow.AddHours(5.5).ToString();
                 objResult = objPeriodBl.Period_Insert(objPeriodBo);
             }
             ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                                                "<script>alert('Record saved successfully.');</script>");
         }
         else if (ViewState["Mode"].ToString() == "Edit")
         {
             for (int i = 1; i <= intCount; i++)
             {
                 objPeriodBo.PeriodNo = i;
                 TextBox txt1 =
                     Page.Master.FindControl("ContentPlaceHolder1").FindControl("txtFromHH" + i.ToString()) as
                     TextBox;
                 TextBox txt2 =
                     Page.Master.FindControl("ContentPlaceHolder1").FindControl("txtFromMM" + i.ToString()) as
                     TextBox;
                 string a, b, c, d;
                 a = txt1.Text;
                 b = txt2.Text;
                 if (txt1.Text == "")
                 {
                     a = "--";
                 }
                 if (txt2.Text == "")
                 {
                     b = "--";
                 }
                 objPeriodBo.FromTime = a + ":" + b;
                 TextBox txt3 =
                     Page.Master.FindControl("ContentPlaceHolder1").FindControl("txtToHH" + i.ToString()) as
                     TextBox;
                 TextBox txt4 =
                     Page.Master.FindControl("ContentPlaceHolder1").FindControl("txtToMM" + i.ToString()) as
                     TextBox;
                 c = txt3.Text;
                 d = txt4.Text;
                 if (c == "")
                 {
                     c = "--";
                 }
                 if (d == "")
                 {
                     d = "--";
                 }
                 objPeriodBo.ToTime             = c + ":" + d;
                 objPeriodBo.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID].ToString());
                 objPeriodBo.LastModifiedDate   = DateTime.UtcNow.AddHours(5.5).ToString();
                 objResult = objPeriodBl.Period_Update(objPeriodBo);
             }
             ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                                                "<script>alert('Record updated successfully.');</script>");
         }
         ClearAll();
         BindPeriod();
         PanelVisibility(1);
     }
     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>");
     }
 }
Example #2
0
        /// <summary>
        /// To Update details of Period in tbl_Period_M table
        /// Created By : Darshan, 09/04/2014
        /// Modified By :
        /// </summary>
        /// <param name="objPeriodBO"></param>
        /// <returns></returns>
        public ApplicationResult Period_Update(PeriodBO objPeriodBO)
        {
            try
            {
                pSqlParameter = new SqlParameter[7];


                pSqlParameter[0]           = new SqlParameter("@DayNo", SqlDbType.Int);
                pSqlParameter[0].Direction = ParameterDirection.Input;
                pSqlParameter[0].Value     = objPeriodBO.DayNo;

                pSqlParameter[1]           = new SqlParameter("@PeriodNo", SqlDbType.Int);
                pSqlParameter[1].Direction = ParameterDirection.Input;
                pSqlParameter[1].Value     = objPeriodBO.PeriodNo;

                pSqlParameter[2]           = new SqlParameter("@FromTime", SqlDbType.VarChar);
                pSqlParameter[2].Direction = ParameterDirection.Input;
                pSqlParameter[2].Value     = objPeriodBO.FromTime;

                pSqlParameter[3]           = new SqlParameter("@ToTime", SqlDbType.VarChar);
                pSqlParameter[3].Direction = ParameterDirection.Input;
                pSqlParameter[3].Value     = objPeriodBO.ToTime;

                pSqlParameter[4]           = new SqlParameter("@ClassMID", SqlDbType.Int);
                pSqlParameter[4].Direction = ParameterDirection.Input;
                pSqlParameter[4].Value     = objPeriodBO.ClassMID;

                pSqlParameter[5]           = new SqlParameter("@LastModifiedUserID", SqlDbType.Int);
                pSqlParameter[5].Direction = ParameterDirection.Input;
                pSqlParameter[5].Value     = objPeriodBO.LastModifiedUserID;

                pSqlParameter[6]           = new SqlParameter("@LastModifiedDate", SqlDbType.VarChar);
                pSqlParameter[6].Direction = ParameterDirection.Input;
                pSqlParameter[6].Value     = objPeriodBO.LastModifiedDate;


                sSql = "usp_tbl_Period_M_Update";
                int iResult = Database.ExecuteNonQuery(CommandType.StoredProcedure, sSql, pSqlParameter);

                if (iResult > 0)
                {
                    ApplicationResult objResults = new ApplicationResult();
                    objResults.status = ApplicationResult.CommonStatusType.SUCCESS;
                    return(objResults);
                }
                else
                {
                    ApplicationResult objResults = new ApplicationResult();
                    objResults.status = ApplicationResult.CommonStatusType.FAILURE;
                    return(objResults);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objPeriodBO = null;
            }
        }