Exemple #1
0
        private void loadInfo()
        {
            string configString = ProcessConfigXML.LoadData("ConnectiontString");
            Dictionary <string, object> dictionary = ProcessConfigXML.ConfigString2Dictionary(configString, new Dictionary <string, object>
            {
                {
                    "Data Source",
                    ""
                },
                {
                    "Database",
                    ""
                },
                {
                    "User ID",
                    ""
                },
                {
                    "Password",
                    ""
                }
            });

            this.txtServerName.Text   = dictionary["Data Source"].ToString();
            this.txtDatabasename.Text = dictionary["Database"].ToString();
            this.txtUsernameSQL.Text  = dictionary["User ID"].ToString();
            this.txtPasswordSQL.Text  = Util.Decrypt(dictionary["Password"].ToString());
            string configString2 = ProcessConfigXML.LoadData("Account");

            dictionary = ProcessConfigXML.ConfigString2Dictionary(configString2, new Dictionary <string, object>
            {
                {
                    "User",
                    ""
                },
                {
                    "Pass",
                    ""
                },
                {
                    "Remember",
                    "true"
                }
            });
            this.txtLISloginUserName.Text = dictionary["User"].ToString();
            this.txtLISloginPassword.Text = Util.Decrypt(dictionary["Pass"].ToString());
            bool flag = dictionary["Remember"].ToString() == "true";

            if (flag)
            {
                this.chkLoginRemember.Checked = true;
            }
            else
            {
                this.chkLoginRemember.Checked = false;
            }
        }
Exemple #2
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary.Add("Data Source", this.txtServerName.Text.Trim());
            dictionary.Add("Database", this.txtDatabasename.Text.Trim());
            dictionary.Add("User ID", this.txtUsernameSQL.Text.Trim());
            dictionary.Add("Password", this.txtPasswordSQL.Text.Trim());
            string text = ProcessConfigXML.Dictionary2ConfigString(dictionary);
            bool   flag = ManageBase.IsConnectDatabase(text);

            if (flag)
            {
                DataAccessAdapterManagerBase.SetCustomConnectString(text);
                string          text2           = Util.Encrypt(this.txtLISloginPassword.Text.Trim());
                NguoiDungEntity nguoiDungEntity = ManageBase.SelectNguoiDung(this.txtLISloginUserName.Text.Trim(), text2);
                bool            flag2           = nguoiDungEntity != null;
                if (flag2)
                {
                    Dictionary <string, object> dictionary2 = new Dictionary <string, object>();
                    bool @checked = this.chkLoginRemember.Checked;
                    if (@checked)
                    {
                        dictionary2.Add("User", this.txtLISloginUserName.Text.Trim());
                        dictionary2.Add("Pass", text2);
                        dictionary2.Add("Remember", this.chkLoginRemember.Checked ? "true" : "false");
                    }
                    else
                    {
                        dictionary2.Add("User", "");
                        dictionary2.Add("Pass", "");
                        dictionary2.Add("Remember", "false");
                    }
                    GlobalVariable.NguoiDungId      = nguoiDungEntity.NguoiDungId;
                    GlobalVariable.TenDangNhap      = nguoiDungEntity.TenDangNhap;
                    GlobalVariable.HoTenNguoiDung   = nguoiDungEntity.HoTenNguoiDung;
                    GlobalVariable.MatKhau          = nguoiDungEntity.MatKhau;
                    GlobalVariable.LaQuanTriHeThong = (nguoiDungEntity.VaiTro == 1);
                    dictionary["Password"]          = Util.Encrypt(this.txtPasswordSQL.Text.Trim());
                    text = ProcessConfigXML.Dictionary2ConfigString(dictionary);
                    string strValue = ProcessConfigXML.Dictionary2ConfigString(dictionary2);
                    ProcessConfigXML.SaveData("ConnectiontString", text);
                    ProcessConfigXML.SaveData("Account", strValue);
                    bool flag3 = GlobalVariable.CreateFTP();
                    if (flag3)
                    {
                        base.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        bool laQuanTriHeThong = GlobalVariable.LaQuanTriHeThong;
                        if (laQuanTriHeThong)
                        {
                            FormKetNoiFTP formKetNoiFTP = new FormKetNoiFTP();
                            formKetNoiFTP.ShowDialog();
                            bool flag4 = GlobalVariable.FTPLib != null;
                            if (flag4)
                            {
                                base.DialogResult = DialogResult.OK;
                                base.Close();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Hiện tại không thể kết nối tới FTP. Hãy liên hệ quản trị hệ thống thiết lập lại thông số kết nối.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.txtLISloginUserName.Focus();
                }
            }
            else
            {
                MessageBox.Show("Không kết nối được cơ sở dữ liệu. Kiểm tra lại thông số kết nối!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                this.txtServerName.Focus();
            }
            this.Cursor = Cursors.Default;
        }
Exemple #3
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            bool            flag            = false;
            int             num             = Convert.ToInt32(this.btnCapNhat.Tag.ToString());
            NguoiDungEntity nguoiDungEntity = null;
            bool            flag2           = !this.btnThemMoi.Enabled && num == 0;

            if (flag2)
            {
                nguoiDungEntity = new NguoiDungEntity();
                flag            = true;
            }
            else
            {
                bool flag3 = num > 0;
                if (flag3)
                {
                    nguoiDungEntity = ManageBase.SelectNguoiDungById(num);
                }
            }
            bool flag4 = nguoiDungEntity != null;

            if (flag4)
            {
                bool flag5 = this.txtUser.Text.Trim() == "" || this.txtPass.Text.Trim() == "";
                if (flag5)
                {
                    MessageBox.Show("Tên đăng nhập và mật khẩu không được để trống!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.txtUser.Focus();
                    this.Cursor = Cursors.Default;
                    return;
                }
                bool flag6 = ManageBase.NguoiDungExist(num, this.txtUser.Text.Trim());
                if (flag6)
                {
                    MessageBox.Show("Tên đăng nhập đã tồn tại. Hãy chọn tên đăng nhập khác!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.txtUser.Focus();
                    this.Cursor = Cursors.Default;
                    return;
                }
                nguoiDungEntity.TenDangNhap    = this.txtUser.Text.Trim();
                nguoiDungEntity.MatKhau        = Util.Encrypt(this.txtPass.Text.Trim());
                nguoiDungEntity.HoTenNguoiDung = this.txtHoTen.Text.Trim();
                nguoiDungEntity.SoDienThoai    = this.txtSoDienThoai.Text.Trim();
                nguoiDungEntity.DiaChiEmail    = this.txtEmail.Text.Trim();
                nguoiDungEntity.VaiTro         = (byte)this.cboVaiTro.SelectedIndex;
                bool flag7 = this.chkGioiTinh.CheckState == CheckState.Checked;
                if (flag7)
                {
                    nguoiDungEntity.GioiTinh = 1;
                }
                else
                {
                    bool flag8 = this.chkGioiTinh.CheckState == CheckState.Unchecked;
                    if (flag8)
                    {
                        nguoiDungEntity.GioiTinh = 0;
                    }
                    else
                    {
                        nguoiDungEntity.GioiTinh = 3;
                    }
                }
                bool flag9 = ManageBase.SaveNguoiDung(nguoiDungEntity);
                if (flag9)
                {
                    bool flag10 = nguoiDungEntity.NguoiDungId == GlobalVariable.NguoiDungId;
                    if (flag10)
                    {
                        GlobalVariable.TenDangNhap = nguoiDungEntity.TenDangNhap;
                        GlobalVariable.MatKhau     = nguoiDungEntity.MatKhau;
                        string text = ProcessConfigXML.LoadData("Account");
                        Dictionary <string, object> dictionary = ProcessConfigXML.ConfigString2Dictionary(text, new Dictionary <string, object>
                        {
                            {
                                "User",
                                "admin"
                            },
                            {
                                "Pass",
                                "123"
                            },
                            {
                                "Remember",
                                "true"
                            }
                        });
                        dictionary["User"] = nguoiDungEntity.TenDangNhap;
                        dictionary["Pass"] = nguoiDungEntity.MatKhau;
                        text = ProcessConfigXML.Dictionary2ConfigString(dictionary);
                        ProcessConfigXML.SaveData("Account", text);
                    }
                    bool flag11 = flag;
                    if (flag11)
                    {
                        DataTable dataTable = (DataTable)this._bindingTaiKhoan.DataSource;
                        DataRow   dataRow   = dataTable.NewRow();
                        dataRow["NguoiDungId"]    = nguoiDungEntity.NguoiDungId;
                        dataRow["TenDangNhap"]    = nguoiDungEntity.TenDangNhap;
                        dataRow["MatKhau"]        = nguoiDungEntity.MatKhau;
                        dataRow["HoTenNguoiDung"] = nguoiDungEntity.HoTenNguoiDung;
                        dataRow["GioiTinh"]       = nguoiDungEntity.GioiTinh;
                        dataRow["SoDienThoai"]    = nguoiDungEntity.SoDienThoai;
                        dataRow["DiaChiEmail"]    = nguoiDungEntity.DiaChiEmail;
                        dataRow["VaiTro"]         = nguoiDungEntity.VaiTro;
                        dataTable.Rows.Add(dataRow);
                        this.dgvTaiKhoan.Rows[this.dgvTaiKhoan.Rows.Count - 1].Selected = true;
                    }
                    this.btnThemMoi.Enabled  = true;
                    this.dgvTaiKhoan.Enabled = true;
                    this.btnXoa.Enabled      = true;
                    this.dgvTaiKhoan_SelectionChanged(null, null);
                    MessageBox.Show("Cập nhật tài khoản thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    MessageBox.Show("Cập nhật tài khoản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            this.Cursor = Cursors.Default;
        }
Exemple #4
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            bool flag = this.txtUser.Text.Trim() == "" || this.txtPassOld.Text.Trim() == "" || this.txtPassNew.Text.Trim() == "";

            if (flag)
            {
                MessageBox.Show("Tên đăng nhập và mật khẩu không được để trống!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                this.txtUser.Focus();
            }
            else
            {
                bool flag2 = this.txtPassOld.Text.Trim() != Util.Decrypt(GlobalVariable.MatKhau);
                if (flag2)
                {
                    MessageBox.Show("Mật khẩu hiện tại không đúng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.txtUser.Focus();
                }
                else
                {
                    bool flag3 = !ManageBase.NguoiDungExist(GlobalVariable.NguoiDungId, this.txtUser.Text.Trim());
                    if (flag3)
                    {
                        NguoiDungEntity nguoiDungEntity = ManageBase.SelectNguoiDungById(GlobalVariable.NguoiDungId);
                        nguoiDungEntity.TenDangNhap    = this.txtUser.Text.Trim();
                        nguoiDungEntity.MatKhau        = Util.Encrypt(this.txtPassNew.Text.Trim());
                        nguoiDungEntity.HoTenNguoiDung = this.txtHoTen.Text.Trim();
                        nguoiDungEntity.SoDienThoai    = this.txtSoDienThoai.Text.Trim();
                        nguoiDungEntity.DiaChiEmail    = this.txtEmail.Text.Trim();
                        bool flag4 = this.chkGioiTinh.CheckState == CheckState.Checked;
                        if (flag4)
                        {
                            nguoiDungEntity.GioiTinh = 1;
                        }
                        else
                        {
                            bool flag5 = this.chkGioiTinh.CheckState == CheckState.Unchecked;
                            if (flag5)
                            {
                                nguoiDungEntity.GioiTinh = 0;
                            }
                            else
                            {
                                nguoiDungEntity.GioiTinh = 3;
                            }
                        }
                        bool flag6 = ManageBase.SaveNguoiDung(nguoiDungEntity);
                        if (flag6)
                        {
                            GlobalVariable.TenDangNhap = nguoiDungEntity.TenDangNhap;
                            GlobalVariable.MatKhau     = nguoiDungEntity.MatKhau;
                            string text = ProcessConfigXML.LoadData("Account");
                            Dictionary <string, object> dictionary = ProcessConfigXML.ConfigString2Dictionary(text, new Dictionary <string, object>
                            {
                                {
                                    "User",
                                    ""
                                },
                                {
                                    "Pass",
                                    ""
                                },
                                {
                                    "Remember",
                                    "true"
                                }
                            });
                            dictionary["User"] = nguoiDungEntity.TenDangNhap;
                            dictionary["Pass"] = nguoiDungEntity.MatKhau;
                            text = ProcessConfigXML.Dictionary2ConfigString(dictionary);
                            ProcessConfigXML.SaveData("Account", text);
                            MessageBox.Show("Cập nhật tài khoản thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                        else
                        {
                            MessageBox.Show("Cập nhật tài khoản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Tên đăng nhập đã tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        this.txtUser.Focus();
                    }
                }
            }
        }