Example #1
0
        private bool CheckValidation()
        {
            var  objCon  = new lib.DatabaseConnection();
            bool isValid = true;

            if (txtCourseName.Text == string.Empty)
            {
                MessageBox.Show("Course name is required.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtCourseName.Focus();
                isValid = false;
            }
            else
            if (cmbSemester.Text == string.Empty)
            {
                MessageBox.Show("Semester is not selected.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cmbSemester.Focus();
                isValid = false;
            }
            else
            if (!string.IsNullOrEmpty(objCon.GetSqlData("Select Semester from Course Where CourseName='" + txtCourseName.Text.Trim() + "' AND Semester='" + cmbSemester.Text.Trim() + "'")))
            {
                MessageBox.Show("A duplicate semester in course.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtCourseName.Focus();
                txtCourseName.SelectAll();
                isValid = false;
            }
            return(isValid);
        }
Example #2
0
        private bool CheckValidation()
        {
            var  objCon  = new lib.DatabaseConnection();
            bool isValid = true;

            if (txtCourseName.Text == string.Empty)
            {
                MessageBox.Show("Tên khóa học bắt buộc.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtCourseName.Focus();
                isValid = false;
            }
            else
            if (cmbSemester.Text == string.Empty)
            {
                MessageBox.Show("Học kỳ không được chọn.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cmbSemester.Focus();
                isValid = false;
            }
            else
            if (!string.IsNullOrEmpty(objCon.GetSqlData("Select Semester from Course Where CourseName='" + txtCourseName.Text.Trim() + "' AND Semester='" + cmbSemester.Text.Trim() + "'")))
            {
                MessageBox.Show("Đã có học kỳ trong khóa học.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtCourseName.Focus();
                txtCourseName.SelectAll();
                isValid = false;
            }
            return(isValid);
        }
Example #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var objCon = new lib.DatabaseConnection();

            if (this.txtCategory.Text == string.Empty)
            {
                MessageBox.Show("Category name is required.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtCategory.Focus();
                return;
            }
            else
            if (txtAmount.Text == string.Empty)
            {
                MessageBox.Show("Amount is required.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtAmount.Focus();
                return;
            }
            else
            {
                try
                {
                    ObjFeeManage.CategoryId   = Convert.ToInt32(FeeCategoryId.ToString());
                    ObjFeeManage.CategoryName = txtCategory.Text;
                    ObjFeeManage.TotalAmount  = Convert.ToInt32(txtAmount.Text);
                    if (this.btnSave.Text == "&Save")
                    {
                        if (!string.IsNullOrEmpty(objCon.GetSqlData("Select Category from FeeManage Where Category= '" + txtCategory.Text.Trim() + "'")))
                        {
                            MessageBox.Show("A duplicate category can not be applied.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            txtCategory.Focus();
                            txtCategory.SelectAll();
                            return;
                        }
                        ObjFeeManage.AddFeeManage();
                        MessageBox.Show("Saved Successfully.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    if (this.btnSave.Text == "&Update")
                    {
                        ObjFeeManage.UpdateFeeManage();
                        MessageBox.Show("Update Successfully.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.btnSave.Text      = "&Save";
                        this.btnDelete.Enabled = false;
                    }
                    ClearAll();
                    dataGridFeeManage.Rows.Clear();
                    BindData();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var objCon = new lib.DatabaseConnection();

            if (this.txtCategory.Text == string.Empty)
            {
                MessageBox.Show("Tên danh mục là bắt buộc.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtCategory.Focus();
                return;
            }
            else
            if (txtAmount.Text == string.Empty)
            {
                MessageBox.Show("Số tiền yêu cầu.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtAmount.Focus();
                return;
            }
            else
            {
                try
                {
                    ObjFeeManage.CategoryId   = Convert.ToInt32(FeeCategoryId.ToString());
                    ObjFeeManage.CategoryName = txtCategory.Text;
                    ObjFeeManage.TotalAmount  = Convert.ToInt32(txtAmount.Text);
                    if (this.btnSave.Text == "&Lưu")
                    {
                        if (!string.IsNullOrEmpty(objCon.GetSqlData("Select Category from FeeManage Where Category= '" + txtCategory.Text.Trim() + "'")))
                        {
                            MessageBox.Show("Trùng lặp.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            txtCategory.Focus();
                            txtCategory.SelectAll();
                            return;
                        }
                        ObjFeeManage.AddFeeManage();
                        MessageBox.Show("Lưu thành công.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    if (this.btnSave.Text == "&Cập nhật")
                    {
                        ObjFeeManage.UpdateFeeManage();
                        MessageBox.Show("Cập nhật thành công.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.btnSave.Text      = "&Lưu";
                        this.btnDelete.Enabled = false;
                    }
                    ClearAll();
                    dataGridFeeManage.Rows.Clear();
                    BindData();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!isValidation())
                {
                    return;
                }
                else
                if (!string.IsNullOrEmpty(objCon.GetSqlData("Select PhoneNo From Regstudent Where PhoneNo='" + txtPhoneNo.Text + "'")))
                {
                    MessageBox.Show("A duplicate phone no can not accepted.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtPhoneNo.Focus();
                    txtPhoneNo.SelectAll();
                    return;
                }

                objStudentDetails.SId         = StudentId.ToString();
                objStudentDetails.StudentName = txtStudentName.Text;
                objStudentDetails.RollNo      = txtRollNo.Text;
                if (this.rdMale.Checked == true)
                {
                    objStudentDetails.Gender = rdMale.Text;
                }
                else
                if (this.rdFemale.Checked == true)
                {
                    objStudentDetails.Gender = rdFemale.Text;
                }
                objStudentDetails.Address        = txtAddress.Text;
                objStudentDetails.DateOfBirth    = mtxtDOB.Text;
                objStudentDetails.AdmissionDate  = mtxtAdmissionDate.Text;
                objStudentDetails.PhoneNumber    = txtPhoneNo.Text;
                objStudentDetails.EmailId        = txtEmail.Text;
                objStudentDetails.StudentPicture = picStudent;
                objStudentDetails.Country        = cmbCountry.Text;
                objStudentDetails.Shift          = cmbShift.Text;
                objStudentDetails.Course         = cmbCourse.Text;
                objStudentDetails.Semester       = cmbSemester.Text;
                objStudentDetails.AddStuAdmission();
                MessageBox.Show("Lưu thành công.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearAll();
                dataStudentView.Rows.Clear();
                BindData();
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message, Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtRollNo.Focus();
            }
        }
Example #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckValidation())
                {
                    return;
                }
                else
                if (!string.IsNullOrEmpty(objCon.GetSqlData("Select PhoneNo From TeacherRegister Where PhoneNo='" + txtPhoneNo.Text + "'")))
                {
                    MessageBox.Show("A duplicate phone no can not accepted.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtPhoneNo.Focus();
                    txtPhoneNo.SelectAll();
                    return;
                }

                ObjTeacher.TeacherId    = _TeacherId;
                ObjTeacher.RegisterDate = mtxtRegisterDate.Text;
                ObjTeacher.TeacherName  = txtTeacherName.Text;
                if (this.rdMale.Checked == true)
                {
                    ObjTeacher.Gender = rdMale.Text;
                }
                else
                if (this.rdFemale.Checked == true)
                {
                    ObjTeacher.Gender = rdFemale.Text;
                }
                ObjTeacher.Address      = txtAddress.Text;
                ObjTeacher.PhoneNo      = txtPhoneNo.Text;
                ObjTeacher.Email        = txtEmail.Text;
                ObjTeacher.Experience   = cmbExperience.Text;
                ObjTeacher.TeacherPhoto = picTeacher;
                ObjTeacher.InsertTeacher();
                MessageBox.Show("Saved Successfully.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearAll();
                dataStaffView.Rows.Clear();
                BindData();
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message, Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #7
0
        private bool CheckValidation()
        {
            var  objCon  = new lib.DatabaseConnection();
            bool isValid = true;

            if (cmbCourse.Text == string.Empty)
            {
                MessageBox.Show("Course name is required.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cmbCourse.Focus();
                isValid = false;
            }
            else
            if (cmbSemester.Text == string.Empty)
            {
                MessageBox.Show("Semester is required.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cmbSemester.Focus();
                isValid = false;
            }
            else
            if (txtSubjectName.Text == string.Empty)
            {
                MessageBox.Show("Subject name is required.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cmbSemester.Focus();
                isValid = false;
            }
            else
            if (!string.IsNullOrEmpty(objCon.GetSqlData("Select SubjectName From SubjectDetails Where CourseName='" + cmbCourse.Text.Trim() + "' and Semester='" + cmbSemester.Text.Trim() + "' and SubjectName='" + txtSubjectName.Text.Trim() + "'")))
            {
                MessageBox.Show("A duplicate subject can not accepted in semester", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtSubjectName.Focus();
                txtSubjectName.SelectAll();
                isValid = false;
            }
            else
            if (txtCredits.Text == string.Empty)
            {
                MessageBox.Show("Credits is required.", Global.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cmbSemester.Focus();
                isValid = false;
            }
            return(isValid);
        }
Example #8
0
        private bool Validation()
        {
            bool isValid = true;

            if (txtUserName.Text == string.Empty)
            {
                this.lblMessageBox.ForeColor = Color.Red;
                this.lblMessageBox.Text      = "User name is required.";
                txtUserName.Focus();
                isValid = false;
            }
            if (!string.IsNullOrEmpty(objCon.GetSqlData("Select UserName From ULogin Where UserName='******'")))
            {
                this.lblMessageBox.ForeColor = Color.Red;
                this.lblMessageBox.Text      = "A duplicate user name can not accepted.";
                txtUserName.Focus();
                txtUserName.SelectAll();
                isValid = false;;
            }
            if (objGlobal.IsAllDigits(txtUserName.Text))
            {
                this.lblMessageBox.Text = "User name can not accepted digits";
                txtUserName.Focus();
                txtUserName.SelectAll();
                isValid = false;
            }
            //if (!objGlobal.getInvalidInput(txtUserName.Text, Global.PatternA, "Invalid negative number",Global.Caption))
            //{
            //    txtUserName.Focus();
            //    txtUserName.SelectAll();
            //    isValid = false;
            //}
            if (txtLoginName.Text == string.Empty)
            {
                this.lblMessageBox.ForeColor = Color.Red;
                this.lblMessageBox.Text      = "Login name is required.";
                txtLoginName.Focus();
                isValid = false;;
            }
            if (txtPassword.Text == string.Empty)
            {
                this.lblMessageBox.ForeColor = Color.Red;
                this.lblMessageBox.Text      = "Password is required.";
                txtPassword.Focus();
                isValid = false;;
            }
            if (txtPassword.Text.Trim().Length > 15 || txtPassword.Text.Trim().Length < 6)
            {
                this.lblMessageBox.Text = "Password length must be between 6 to 15 digits accept.";
                txtPassword.SelectAll();
                txtPassword.Focus();
                isValid = false;
            }
            if (txtConfirmPSW.Text == string.Empty)
            {
                this.lblMessageBox.ForeColor = Color.Red;
                this.lblMessageBox.Text      = "Confirm password is empty.";
                txtConfirmPSW.Focus();
                isValid = false;;
            }
            if (txtConfirmPSW.Text.Trim().Length > 15 || txtConfirmPSW.Text.Trim().Length < 6)
            {
                this.lblMessageBox.Text = "Confirm password length must be between 6 to 15 digits accept.";
                txtPassword.SelectAll();
                txtPassword.Focus();
                isValid = false;
            }
            if (txtPassword.Text != txtConfirmPSW.Text)
            {
                this.lblMessageBox.ForeColor = Color.Red;
                this.lblMessageBox.Text      = "Password or confirm password is not matched.";
                txtConfirmPSW.Clear();
                txtPassword.Focus();
                txtPassword.SelectAll();
                isValid = false;;
            }
            if (cmbRole.Text == string.Empty)
            {
                this.lblMessageBox.ForeColor = Color.Red;
                this.lblMessageBox.Text      = "Select role.";
                cmbRole.Focus();
                isValid = false;;
            }
            return(isValid);
        }
        private bool Validation()
        {
            bool isValid = true;

            if (txtUserName.Text == string.Empty)
            {
                this.lblMessageBox.ForeColor = Color.Red;
                this.lblMessageBox.Text      = "Tên là bắt buộc.";
                txtUserName.Focus();
                isValid = false;
            }
            if (!string.IsNullOrEmpty(objCon.GetSqlData("Select UserName From ULogin Where UserName='******'")))
            {
                this.lblMessageBox.ForeColor = Color.Red;
                this.lblMessageBox.Text      = "Tên người dùng tồn tại.";
                txtUserName.Focus();
                txtUserName.SelectAll();
                isValid = false;;
            }
            if (objGlobal.IsAllDigits(txtUserName.Text))
            {
                this.lblMessageBox.Text = "Tên người dùng không thể toàn số";
                txtUserName.Focus();
                txtUserName.SelectAll();
                isValid = false;
            }
            //if (!objGlobal.getInvalidInput(txtUserName.Text, Global.PatternA, "Invalid negative number",Global.Caption))
            //{
            //    txtUserName.Focus();
            //    txtUserName.SelectAll();
            //    isValid = false;
            //}
            if (txtLoginName.Text == string.Empty)
            {
                this.lblMessageBox.ForeColor = Color.Red;
                this.lblMessageBox.Text      = "Tên đăng nhập bắt buộc.";
                txtLoginName.Focus();
                isValid = false;;
            }
            if (txtPassword.Text == string.Empty)
            {
                this.lblMessageBox.ForeColor = Color.Red;
                this.lblMessageBox.Text      = "Mật khẩu bắt buộc.";
                txtPassword.Focus();
                isValid = false;;
            }
            if (txtPassword.Text.Trim().Length > 15 || txtPassword.Text.Trim().Length < 6)
            {
                this.lblMessageBox.Text = "Mật khẩu từ 6 đến 15 kí tự.";
                txtPassword.SelectAll();
                txtPassword.Focus();
                isValid = false;
            }
            if (txtConfirmPSW.Text == string.Empty)
            {
                this.lblMessageBox.ForeColor = Color.Red;
                this.lblMessageBox.Text      = "Mật khẩu nhập lại bỏ trống.";
                txtConfirmPSW.Focus();
                isValid = false;;
            }
            if (txtConfirmPSW.Text.Trim().Length > 15 || txtConfirmPSW.Text.Trim().Length < 6)
            {
                this.lblMessageBox.Text = "Độ dài mật khẩu nhập lại từ 6 đến 15 kí tự.";
                txtPassword.SelectAll();
                txtPassword.Focus();
                isValid = false;
            }
            if (txtPassword.Text != txtConfirmPSW.Text)
            {
                this.lblMessageBox.ForeColor = Color.Red;
                this.lblMessageBox.Text      = "Mật khẩu nhập lại không trùng khớp.";
                txtConfirmPSW.Clear();
                txtPassword.Focus();
                txtPassword.SelectAll();
                isValid = false;;
            }
            if (cmbRole.Text == string.Empty)
            {
                this.lblMessageBox.ForeColor = Color.Red;
                this.lblMessageBox.Text      = "Select role.";
                cmbRole.Focus();
                isValid = false;;
            }
            return(isValid);
        }