Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ViewState["ClassMID"]     = Convert.ToInt32(Request.Form[ddlClass.UniqueID]);
            ViewState["DivisionName"] = Convert.ToInt32(Request.Form[ddlDivision.UniqueID]);
            ViewState["AcademicYear"] = ddlAcademicYear.SelectedItem.ToString();

            StudentAttendenceBL objStudentAttendenceBL = new StudentAttendenceBL();
            StudentAttendenceBO objStudentAttendenceBO = new StudentAttendenceBO();
            ApplicationResult   objResults             = new ApplicationResult();

            try
            {
                string PresentIds = string.Empty;
                string AbsentIds  = string.Empty;
                int    Count      = 0;
                foreach (GridViewRow row in gvStudent.Rows)
                {
                    ViewState["StudentMID"] = Convert.ToInt32(row.Cells[0].Text);

                    if (((CheckBox)row.FindControl("chkChild")).Checked)
                    {
                        PresentIds += ViewState["StudentMID"].ToString() + ",";
                        Count       = Count + 1;
                    }
                    else
                    {
                        AbsentIds += ViewState["StudentMID"].ToString() + ",";
                    }
                }
                objStudentAttendenceBO.PresentStudentIDs = PresentIds.TrimEnd(',');
                objStudentAttendenceBO.AbsentStudentIds  = AbsentIds.TrimEnd(',');
                objStudentAttendenceBO.TrustMID          = Convert.ToInt32(Session[ApplicationSession.TRUSTID]);
                objStudentAttendenceBO.SchoolMID         = Convert.ToInt32(Session[ApplicationSession.SCHOOLID]);
                objStudentAttendenceBO.EmployeeMID       = Convert.ToInt32(Session[ApplicationSession.USERID]);
                objStudentAttendenceBO.ClassMID          = Convert.ToInt32(ViewState["ClassMID"].ToString());
                objStudentAttendenceBO.DivisionTID       = Convert.ToInt32(ViewState["DivisionName"].ToString());
                objStudentAttendenceBO.AcademicYear      = ViewState["AcademicYear"].ToString();
                objStudentAttendenceBO.Date               = txtdate.Text;
                objStudentAttendenceBO.LastModifiedDate   = DateTime.UtcNow.AddHours(5.5).ToString();
                objStudentAttendenceBO.Time               = System.DateTime.Now.ToShortTimeString();
                objStudentAttendenceBO.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]);
                if (Count > 0)
                {
                    if (ViewState["Mode"].ToString() == "Save")
                    {
                        objResults = objStudentAttendenceBL.StudentAttendence_Insert(objStudentAttendenceBO);
                        if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS)
                        {
                            ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Student Attendence Done Successfully.');</script>");
                        }
                    }
                    else
                    {
                        objStudentAttendenceBO.StudentAttendenceMID = Convert.ToInt32(ViewState["StudentAttendenceMID"].ToString());
                        objResults = objStudentAttendenceBL.StudentAttendence_Update(objStudentAttendenceBO);
                        if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS)
                        {
                            ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Student Attendence Updated Successfully.');</script>");
                            ViewState["Mode"] = "Save";
                        }
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Select Any One Checkbox For Attendence.');</script>");
                    ViewState["ClassMID"]     = Convert.ToInt32(Request.Form[ddlClass.UniqueID]);
                    ViewState["DivisionName"] = Convert.ToInt32(Request.Form[ddlDivision.UniqueID]);
                    ViewState["AcademicYear"] = ddlAcademicYear.SelectedItem.ToString();
                    hfCLassMID.Value          = ViewState["ClassMID"].ToString();
                    hfDivisionTID.Value       = ViewState["DivisionName"].ToString();
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "BindDorpdownOnButtonClick();", true);
                }
                BindStudentGrid();
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "BindSection();", true);
            }
            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>");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// To Update details of StudentAttendence in tbl_StudentAttendence_M table
        /// Created By : Nafisa, 27-10-2014
        /// Modified By :
        /// </summary>
        /// <param name="objStudentAttendenceBO"></param>
        /// <returns></returns>
        public ApplicationResult StudentAttendence_Update(StudentAttendenceBO objStudentAttendenceBO)
        {
            try
            {
                pSqlParameter = new SqlParameter[14];


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

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

                pSqlParameter[2]           = new SqlParameter("@SchoolMID", SqlDbType.Int);
                pSqlParameter[2].Direction = ParameterDirection.Input;
                pSqlParameter[2].Value     = objStudentAttendenceBO.SchoolMID;

                pSqlParameter[3]           = new SqlParameter("@EmployeeMID", SqlDbType.Int);
                pSqlParameter[3].Direction = ParameterDirection.Input;
                pSqlParameter[3].Value     = objStudentAttendenceBO.EmployeeMID;

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

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

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

                pSqlParameter[7]           = new SqlParameter("@PresentStudentIDs", SqlDbType.VarChar);
                pSqlParameter[7].Direction = ParameterDirection.Input;
                pSqlParameter[7].Value     = objStudentAttendenceBO.PresentStudentIDs;

                pSqlParameter[8]           = new SqlParameter("@AbsentStudentIds", SqlDbType.VarChar);
                pSqlParameter[8].Direction = ParameterDirection.Input;
                pSqlParameter[8].Value     = objStudentAttendenceBO.AbsentStudentIds;

                pSqlParameter[9]           = new SqlParameter("@Date", SqlDbType.VarChar);
                pSqlParameter[9].Direction = ParameterDirection.Input;
                pSqlParameter[9].Value     = objStudentAttendenceBO.Date;

                pSqlParameter[10]           = new SqlParameter("@Time", SqlDbType.VarChar);
                pSqlParameter[10].Direction = ParameterDirection.Input;
                pSqlParameter[10].Value     = objStudentAttendenceBO.Time;

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

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

                pSqlParameter[13]           = new SqlParameter("@IsDeleted", SqlDbType.Int);
                pSqlParameter[13].Direction = ParameterDirection.Input;
                pSqlParameter[13].Value     = objStudentAttendenceBO.IsDeleted;


                sSql = "usp_tbl_StudentAttendence_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
            {
                objStudentAttendenceBO = null;
            }
        }