Esempio n. 1
0
        private void butLogin_Click(object sender, EventArgs e)
        {
            try {
                IUserService userService = new UserService();
                string message = String.Empty;
                if (txtPassword.Text.Equals("Enter Password") || txtPassword.Text.Equals(String.Empty) || txtUsername.Text.Equals("Enter Username") || txtUsername.Text.Equals(String.Empty))
                {
                    MessageBox.Show(this, "Username and Password is Required", "Required Fields");
                }
                else
                {
                    if (userService.AuthenticateUser(txtUsername.Text, txtPassword.Text, ref message))
                    {
                        User u = new User();
                        u = userService.GetUser(txtUsername.Text);
                        LoggedUser lu = new LoggedUser();

                        lu.UserId = u.UserId;
                        lu.UserName = u.UserName;
                        lu.LastName = u.LastName;
                        lu.FirstName = u.FirstName;
                        lu.MiddleName = u.MiddleName;
                        lu.UserType = u.UserTypeCode;

                        GlobalClass.UserLoggedIn = true;
                        GlobalClass.user = lu;
                        GlobalClass.currentsy = userService.GetCurrentSy();
                        GlobalClass.userTypeCode = lu.UserType;

                        ILogService logService = new LogService();
                        string json = JsonConvert.SerializeObject(lu);
                        Log log = new Log
                        {
                            CLUD = "L",
                            LogDate = DateTime.Now,
                            TableName = "Users",
                            UserId = GlobalClass.user.UserId,
                            UserName = GlobalClass.user.UserName,
                            PassedData = json
                        };
                        logService.AddLogs(log);
                        Close();
                    }
                    else MessageBox.Show(this, message, "Login Failed");
                }
            }catch(Exception ex)
            {
                MessageBox.Show("Unable to Establish the network connection. Please check if network is connected.", "LogIn Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
    }
Esempio n. 2
0
 private void Log(string clud, string table, Object obj)
 {
     ILogService logService = new LogService();
     string json = JsonConvert.SerializeObject(obj);
     Log log = new Log
     {
         CLUD = clud,
         LogDate = DateTime.Now,
         TableName = table,
         UserId = GlobalClass.user.UserId,
         UserName = GlobalClass.user.UserName,
         PassedData = json
     };
     logService.AddLogs(log);
 }
Esempio n. 3
0
        private void btnPrint_Click(object sender, EventArgs e)
        {   
            calculate.Visible = false;
            IRegistrationService registrationService = new RegistrationService();
            ILogService logService = new LogService();
            var assessments = registrationService.AssessMe(StudentAssessed);
            if (assessments.Count > 0)
            {
                string json = JsonConvert.SerializeObject(StudentAssessed);
                Log log = new Log
                {
                    CLUD = "C",
                    LogDate = DateTime.Now,
                    TableName = "StudentAssessment",
                    UserId = GlobalClass.user.UserId,
                    UserName = GlobalClass.user.UserName,
                    PassedData = json
                };
                logService.AddLogs(log);

                PrintPane();
                if (listStudentAssessed.Count <= 0)
                    registrationService.UpdateStudentBalance(StudentAssessed.StudentSY, StudentAssessed.StudentId, float.Parse(Total.Text));
                calculate.Visible = true;
                labelVisibility(false);
                TuitionDet.Visible = true;

            }
        }
Esempio n. 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            IRegistrationService registrationService = new RegistrationService();
            ILogService logService = new LogService();
            if (ExistingSchedRemove.Count > 0)
            {
                if (registrationService.DeleteLoadedSubjects(controlStudentId, SY, ExistingSchedRemove))
                {

                    foreach (StudentSubject ss in ExistingSchedRemove)
                    {
                        string json = JsonConvert.SerializeObject(ss);
                        Log log = new Log
                        {
                            CLUD = "D",
                            LogDate = DateTime.Now,
                            TableName = "StudentSubject",
                            UserId = GlobalClass.user.UserId,
                            UserName = GlobalClass.user.UserName,
                            PassedData = json
                        };
                        logService.AddLogs(log);
                    }
                    MessageBox.Show(this, "Adding Student Subjects Successful .");
                    Close();
                }
                else
                {
                    MessageBox.Show(this, "Student Subjects Adding Failed.");
                    Close();
                }
            }
            if (subjects.Count > 0)
            {
                if (registrationService.ControlSubjects(controlStudentId, SY, subjects))
                {
                    foreach (StudentSubject ss in subjects)
                    {
                        string json = JsonConvert.SerializeObject(ss);
                        Log log = new Log
                        {
                            CLUD = "C",
                            LogDate = DateTime.Now,
                            TableName = "StudentSubject",
                            UserId = GlobalClass.user.UserId,
                            UserName = GlobalClass.user.UserName,
                            PassedData = json
                        };
                        logService.AddLogs(log);
                    }
                    MessageBox.Show(this, "Adding Student Subjects Successful .");
                    Close();
                }
                else
                {
                    MessageBox.Show(this, "Student Subjects Adding Failed.");
                    Close();
                }
            }
        }
Esempio n. 5
0
        private void Save()
        {
            string szGender = string.Empty;
            string szBloodType = string.Empty;
            bool acad = false;
            if (cmbGender.Text == "Female") szGender = "F";
            if (cmbGender.Text == "Male") szGender = "M";

            if (cmbBloodType.Text == "A") szBloodType = "A";
            if (cmbBloodType.Text == "O") szBloodType = "O";
            if (cmbBloodType.Text == "AB") szBloodType = "AB";
            if (cmbBloodType.Text == "A") szBloodType = "A";
            if (radioAcademic.Checked == true && radioNonAcad.Checked == false) acad = true;
            else if (radioAcademic.Checked == false && radioNonAcad.Checked == true) acad = false;
            else if (radioAcademic.Checked == false && radioNonAcad.Checked == false) acad = false;
            Boolean ret = false;
            string message = String.Empty;

            byte[] bImage = null;
            if (pbImage.BackgroundImage != null) bImage = imageToByteArray(pbImage.BackgroundImage, ImageFormat.Png);

            TeacherService teacherService = new TeacherService();

            String fName = txtFirstName.Text;
            String mName = txtMiddleName.Text;
            String lName = txtLastName.Text;

            String cName = fName.Trim() + mName.Trim() + lName.Trim();

            var teachers = teacherService.GetAllTeachers();

            teacherCompare = new List<Teacher>(teachers);

            Teacher teacher = new Teacher()
            {
                TeacherId = txtTeacherID.Text,
                BloodType = szBloodType,
                CivilStatus = cmbCivilState.Text,
                DOB = dtBirth.Value,
                DateOfAppointment = dtAppointment.Value,
                EmailAddress = txtEmailAdd.Text,
                EmploymentStatus = txtEmploymentState.Text,
                DialectSpoken = txtDialect.Text,
                FirstName = txtFirstName.Text,
                MiddleName = txtMiddleName.Text,
                LastName = txtLastName.Text,
                Gender = szGender,
                HeightCm = int.Parse(txtHeight.Text),
                WeightKg = double.Parse(txtWeight.Text),
                MobileNo = txtCellphone.Text,
                PAMunicipality = txtPA_Municipality.Text,
                PAProvince = txtPA_Province.Text,
                PARegion = cmbPA_Region.SelectedValue.ToString(),
                PAStreetName = txtPA_StreetName.Text,
                POBMunicipality = txtPOB_Municipality.Text,
                POBProvince = txtPOB_Province.Text,
                PagIBIGNo = txtPagIbig.Text,
                PhilHealthNo = txtPhilHealth.Text,
                PreviousSchool = txtSchoolReassigned.Text,
                RAMunicipality = txtRes_Municipality.Text,
                RAProvince = txtRes_Province.Text,
                RARegion = cmbRes_Region.SelectedValue.ToString(),
                RAStreetName = txtRes_StreetName.Text,
                ResTelephoneNo = txtRes_TelNo.Text,
                SSSNum = txtSSS.Text,
                SpouseBusinessAdd = txtSpouse_BusinessAdd.Text,
                SpouseEmployerName = txtSpouse_Employer.Text,
                SpouseFirstName = txtSpouse_FirstName.Text,
                SpouseLastName = txtSpouse_LastName.Text,
                SpouseMiddleName = txtSpouse_MiddleName.Text,
                SpouseOccupation = txtSpouse_Occupation.Text,
                SpouseTelephoneNo = txtSpouse_Contact.Text,
                TIN = txtTIN.Text,
                Image = bImage,
                PERAA = txtPERAA.Text,
                Academic = acad,
                Salary = double.Parse(txtSalary.Text),
                Department = txtDepartment.Text,

                TeacherChildrens = teachChild,
                TeacherEducationalBackgrounds = educBack,
                TeacherEligibilities = teachElig,
                WorkExperiences = workExp,
                TrainingSeminars=trainSem,
                
            };



            if (Op.Equals("edit"))
            {
                ret = teacherService.UpdateTeacher(ref teacher, ref message);
                ILogService logService = new LogService();
                teacher.TeacherChildrens = null;
                teacher.TeacherEducationalBackgrounds = null;
                teacher.TeacherEligibilities = null;
                teacher.TrainingSeminars = null;
                teacher.WorkExperiences = null;

                Log("U", "Teachers", teacher);
               
                foreach (TeacherChildren tc in teachChild)
                   Log("U", "TeacherChildren", tc);
                   
                foreach (TeacherEducationalBackground teb in educBack)
                   Log("U", "TeacherEducationalBackground", teb);
                 
                foreach (TeacherEligibility te in teachElig)
                    Log("U", "TeacherEligibilities", te);                

                foreach (WorkExperience we in workExp)
                    Log("U", "WorkExperiences", we);
                    
                
                foreach (TrainingSeminar ts in trainSem)
                   Log("U", "TrainingSeminars", ts);
                   
                
            }
            
            else
            {
                foreach (Teacher tc in teacherCompare)
                {
                    String compareString = tc.FirstName.Trim() + tc.MiddleName.Trim() + tc.LastName.Trim();
                    if (cName.Equals(compareString))
                    {
                        MessageBox.Show("Teacher already exist!");
                        break;
                    }
                    else
                    {
                        ret = teacherService.CreateTeacher(ref teacher, ref message);
                        Log("C", "Teachers", teacher);
                        
                    }
                }
            }

           // if (ret)
                MessageBox.Show("Saved Successfully");
            //else
            //    MessageBox.Show("Error Saving");

            Close();
        }
Esempio n. 6
0
        private void btnDelete_Click_1(object sender, EventArgs e)
        {
            if (gvStudent.CurrentRow == null)
                return;

            string message = String.Empty;
            IStudentService studentService = new StudentService();
            if (studentService.DismissStudent(studentSelected.StudentId, ref message)) {
                ILogService logService = new LogService();
                studentSelected.Dismissed = true;
                string json = JsonConvert.SerializeObject(studentSelected);
                Log log = new Log
                {
                    CLUD = "D",
                    LogDate = DateTime.Now,
                    TableName = "Students",
                    UserId = GlobalClass.user.UserId,
                    UserName = GlobalClass.user.UserName,
                    PassedData = json
                };
                logService.AddLogs(log);

            }

            MessageBox.Show(this, "Student Dismissed");
                        
        }