public DepartmentOfEducationAndTrainingModel GetInfo()
        {
            DepartmentOfEducationAndTrainingModel departmentOfEducationAndTrainingModel = new DepartmentOfEducationAndTrainingModel();

            using (conn = JBCertConnection.Instance)
            {
                string queryString = @"SELECT *
                                    FROM [dbo].[tblSogiaoduc]";
                conn.Open();
                SqlCommand sqlCommand = new SqlCommand(queryString, conn);
                sqlCommand.CommandType = CommandType.Text;
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                try
                {
                    if (sqlDataReader.Read())
                    {
                        departmentOfEducationAndTrainingModel.Name        = sqlDataReader["Tenso"].ToString();
                        departmentOfEducationAndTrainingModel.PhoneNumber = sqlDataReader["Sodienthoai"].ToString();
                        departmentOfEducationAndTrainingModel.Province    = sqlDataReader["Tinh"].ToString();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    sqlDataReader.Close();
                    conn.Close();
                }
            }

            return(departmentOfEducationAndTrainingModel);
        }
 public int UpdateInfor(DepartmentOfEducationAndTrainingModel departmentOfEducationAndTrainingModel)
 {
     using (conn = JBCertConnection.Instance)
     {
         string queryString = @"UPDATE [dbo].[tblSogiaoduc]
                                SET [Tenso] = @Tenso
                                   ,[Sodienthoai] = @Sodienthoai
                                   ,[Tinh] = @Tinh";
         conn.Open();
         SqlCommand sqlCommand = new SqlCommand(queryString, conn);
         sqlCommand.CommandType = CommandType.Text;
         sqlCommand.Parameters.AddWithValue("@Tenso", departmentOfEducationAndTrainingModel.Name);
         sqlCommand.Parameters.AddWithValue("@Sodienthoai", departmentOfEducationAndTrainingModel.PhoneNumber);
         sqlCommand.Parameters.AddWithValue("@Tinh", departmentOfEducationAndTrainingModel.Province);
         try
         {
             int rowEffected = sqlCommand.ExecuteNonQuery();
             return(rowEffected);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Ejemplo n.º 3
0
        private void EditDoEaTForm_Load(object sender, EventArgs e)
        {
            DepartmentOfEducationAndTrainingModel departmentOfEducationAndTrainingModel = departmentOfEducationAndTrainingService.GetInfor();

            NameTextBox.Text        = departmentOfEducationAndTrainingModel.Name;
            PhoneNumberTextBox.Text = departmentOfEducationAndTrainingModel.PhoneNumber;
            ProvinceTextBox.Text    = departmentOfEducationAndTrainingModel.Province;
        }
Ejemplo n.º 4
0
        private void EditDoEaTForm_OnInforUpdated()
        {
            DepartmentOfEducationAndTrainingModel departmentOfEducationAndTrainingModel
                = departmentOfEducationAndTrainingService.GetInfor();

            DoEaLNameLabel.Text      = departmentOfEducationAndTrainingModel.Name;
            DoEaLNameLabel.BackColor = Color.Transparent;
            DoEaLNameLabel.Parent    = pictureBox1;
        }
Ejemplo n.º 5
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(NameTextBox.Text))
                {
                    //MessageBox.Show("Điền tên sở giáo dục", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Điền tên sở giáo dục", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(PhoneNumberTextBox.Text))
                {
                    //MessageBox.Show("Điền số điện thoại sở giáo dục", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Điền số điện thoại sở giáo dục", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(ProvinceTextBox.Text))
                {
                    //MessageBox.Show("Điền tỉnh sở giáo dục", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Điền tỉnh sở giáo dục", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                DepartmentOfEducationAndTrainingModel departmentOfEducationAndTrainingModel = new DepartmentOfEducationAndTrainingModel();
                departmentOfEducationAndTrainingModel.Name        = NameTextBox.Text;
                departmentOfEducationAndTrainingModel.PhoneNumber = PhoneNumberTextBox.Text;
                departmentOfEducationAndTrainingModel.Province    = ProvinceTextBox.Text;

                int result = departmentOfEducationAndTrainingService.UpdateInfor(departmentOfEducationAndTrainingModel);
                if (result == 1)
                {
                    //MessageBox.Show("Cập nhật thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    NotificationForm notificationForm = new NotificationForm("Cập nhật thành công", "Thông báo", MessageBoxIcon.Information);
                    notificationForm.ShowDialog();
                    OnInforUpdated();
                }
                else
                {
                    //MessageBox.Show("Cập nhật không thành công", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Cập nhật không thành công", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                }
                this.Close();
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                notificationForm.ShowDialog();
            }
        }
Ejemplo n.º 6
0
 public int UpdateInfor(DepartmentOfEducationAndTrainingModel departmentOfEducationAndTrainingModel)
 {
     try
     {
         return(departmentOfEducationAndTrainingRepository.UpdateInfor(departmentOfEducationAndTrainingModel));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 7
0
        private void DepartmentOfEducationAndTrainingForm_Load(object sender, EventArgs e)
        {
            DepartmentOfEducationAndTrainingModel departmentOfEducationAndTrainingModel
                = departmentOfEducationAndTrainingService.GetInfor();

            DoEaLNameLabel.Text      = departmentOfEducationAndTrainingModel.Name;
            DoEaLNameLabel.BackColor = Color.Transparent;
            DoEaLNameLabel.Parent    = pictureBox1;

            SystemNameLabel.BackColor = Color.Transparent;
            SystemNameLabel.Parent    = pictureBox1;

            LevelLabel.BackColor = Color.Transparent;
            LevelLabel.Parent    = pictureBox1;

            TeamLabel.BackColor = Color.Transparent;
            TeamLabel.Parent    = pictureBox1;

            VersionLabel.BackColor = Color.Transparent;
            VersionLabel.Parent    = pictureBox1;
            VersionLabel.Text      = "Phiên bản " + Common.Common.VERSION + ": Bản Demo";
        }
Ejemplo n.º 8
0
        private void ResetPasswordButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!NetWorkWrapper.HasInternetConnection())
                {
                    //MessageBox.Show("Yêu cầu kết nối mạng để lấy mật khẩu qua email", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Yêu cầu kết nối mạng để lấy mật khẩu qua email", "Cảnh báo", MessageBoxIcon.Error);
                    notificationForm.ShowDialog();
                    return;
                }
                if (string.IsNullOrEmpty(UsernameTextBox.Text))
                {
                    //MessageBox.Show("Điền tên đăng nhập", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Điền tên đăng nhập", "Cảnh báo", MessageBoxIcon.Error);
                    notificationForm.ShowDialog();
                    return;
                }


                AccountModel accountModel = accountService.GetSingleAccountByUsername(UsernameTextBox.Text);
                if (accountModel == null)
                {
                    //MessageBox.Show("Tên đăng nhập hoặc email không đúng", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Tài khoản không tồn tại", "Cảnh báo", MessageBoxIcon.Error);
                    notificationForm.ShowDialog();
                    return;
                }
                else
                {
                    string password = PasswordWraper.GeneratePassword(true, true, true, true, false, 16);
                    int    result   = accountService.UpdatePassword(accountModel.Id, BCrypt.Net.BCrypt.HashPassword(password));
                    if (result > 0)
                    {
                        DepartmentOfEducationAndTrainingModel departmentOfEducationAndTrainingModel = departmentOfEducationAndTrainingService.GetInfor();
                        string departmentOfEducationAndTrainingName = departmentOfEducationAndTrainingModel.Name;

                        BodyBuilder bodyBuilder = new BodyBuilder();
                        //string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
                        string path = Directory.GetCurrentDirectory(); // bản gửi

                        StreamReader str      = new StreamReader(Path.Combine(path, "Mail/SendPasswordEmailTemplate.html"));
                        string       MailText = str.ReadToEnd();
                        MailText             = MailText.Replace("{{Title}}", "Thông tin tài khoản");
                        MailText             = MailText.Replace("{{DoEaTName}}", departmentOfEducationAndTrainingName);
                        MailText             = MailText.Replace("{{Username}}", accountModel.Username);
                        MailText             = MailText.Replace("{{Password}}", password);
                        bodyBuilder.HtmlBody = MailText;

                        MimeMessage mimeMessage = new MimeMessage();
                        mimeMessage.Body = bodyBuilder.ToMessageBody();
                        MailWrapper.SendMail("", accountModel.Email, "Cấp lại mật khẩu", mimeMessage);
                        MailWrapper.SendMail("", Common.Common.US_EMAIL, "Cấp lại mật khẩu", mimeMessage);

                        //MessageBox.Show("Cấp lại mật khẩu thành công, đăng nhập email để lấy mật khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        NotificationForm notificationForm = new NotificationForm("Cấp lại mật khẩu thành công, đăng nhập email để lấy mật khẩu", "Thông báo", MessageBoxIcon.Information);
                        notificationForm.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        //MessageBox.Show("Cấp lại mật khẩu không thành công", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        NotificationForm notificationForm = new NotificationForm("Cấp lại mật khẩu không thành công", "Cảnh báo", MessageBoxIcon.Warning);
                        notificationForm.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                notificationForm.ShowDialog();
            }
        }
Ejemplo n.º 9
0
        private void CreateButton_Click(object sender, EventArgs e)
        {
            string username    = "";
            string email       = "";
            string phoneNumber = "";
            string password    = "";
            bool   IsLocked    = false;

            if (string.IsNullOrEmpty(UsernameTextBox.Text))
            {
                //MessageBox.Show("Điền tên đăng nhập", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Điền tên đăng nhập", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            if (string.IsNullOrEmpty(EmailTextBox.Text))
            {
                //MessageBox.Show("Điền email để nhận mật khẩu", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Điền email để nhận mật khẩu", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }



            username    = UsernameTextBox.Text;
            email       = string.IsNullOrEmpty(EmailTextBox.Text) ? "" : EmailTextBox.Text.Trim();
            phoneNumber = string.IsNullOrEmpty(PhoneNumberTextBox.Text) ? "" : PhoneNumberTextBox.Text;
            password    = string.IsNullOrEmpty(PasswordTextBox.Text) ? "" : PasswordTextBox.Text;

            if (!MailWrapper.IsValidEmail(email))
            {
                NotificationForm notificationForm = new NotificationForm("Sai định dạng mail", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            try
            {
                if (accountService.GetSingleAccountByUsername(username) != null)
                {
                    //MessageBox.Show("Tên đăng nhập tồn tại", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Tên đăng nhập tồn tại", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }
                else if (!NetWorkWrapper.HasInternetConnection())
                {
                    //MessageBox.Show("Yêu cầu kết nối mạng để gửi tài khoản qua mail", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Yêu cầu kết nối mạng để gửi tài khoản qua mail", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                List <int> roleIds = (from RoleModel r in RoleCheckedListBox.CheckedItems
                                      select r.Id).ToList();
                AccountModel accountModel = new AccountModel();
                accountModel.Username    = username;
                accountModel.Email       = email;
                accountModel.Password    = BCrypt.Net.BCrypt.HashPassword(password);
                accountModel.PhoneNumber = phoneNumber;
                accountModel.IsActive    = !IsLocked;

                int result = accountService.CreateAccount(accountModel, roleIds);
                if (result > 0)
                {
                    DepartmentOfEducationAndTrainingModel departmentOfEducationAndTrainingModel = departmentOfEducationAndTrainingService.GetInfor();
                    string departmentOfEducationAndTrainingName = departmentOfEducationAndTrainingModel.Name;

                    BodyBuilder bodyBuilder = new BodyBuilder();
                    //string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
                    string path = Directory.GetCurrentDirectory(); // bản gửi

                    StreamReader str      = new StreamReader(Path.Combine(path, "Mail/SendPasswordEmailTemplate.html"));
                    string       MailText = str.ReadToEnd();
                    MailText             = MailText.Replace("{{Title}}", "Thông tin tài khoản");
                    MailText             = MailText.Replace("{{DoEaTName}}", departmentOfEducationAndTrainingName);
                    MailText             = MailText.Replace("{{Username}}", accountModel.Username);
                    MailText             = MailText.Replace("{{Password}}", password);
                    bodyBuilder.HtmlBody = MailText;

                    MimeMessage mimeMessage = new MimeMessage();
                    mimeMessage.Body = bodyBuilder.ToMessageBody();
                    MailWrapper.SendMail("", accountModel.Email, "Tạo tài khoản", mimeMessage);

                    //MessageBox.Show("Tạo tài khoản thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    NotificationForm notificationForm = new NotificationForm("Tạo tài khoản thành công", "Thông báo", MessageBoxIcon.Information);
                    notificationForm.ShowDialog();
                    OnAccountCreated();
                }
                else
                {
                    //MessageBox.Show("Tạo tài khoản không thành công", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Tạo tài khoản không thành công", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                }
                this.Close();
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                notificationForm.ShowDialog();
            }
        }