Exemplo n.º 1
0
        public void ChangePass(string UserName, string Pass)
        {
            adminDO = new AdminDO();
            dsUser = adminDO.GetUser(UserName);
            DataRow dr = dsUser.Tables[0].Rows[0];

            SetUserData(ref dr);
            string str = WorkingContext.LangManager.GetString("frmChangePass_Thongbao1");
            int ret = 0;
            try
            {
                ret = adminDO.ChangePass(dsUser);
            }
            catch
            {

            }
            if (ret != 0)
            {
                string str1 = WorkingContext.LangManager.GetString("frmChangePass_Thongbao1_Title");
                //MessageBox.Show("Cập nhật mật khẩu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MessageBox.Show(str1, str, MessageBoxButtons.OK, MessageBoxIcon.Information);
                dsUser.AcceptChanges();
                this.Close();
            }
            else
            {
                string str2 = WorkingContext.LangManager.GetString("frmChangePass_Thongbao2_Title");
                //MessageBox.Show("Cập nhật mật khẩu thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MessageBox.Show(str2, str, MessageBoxButtons.OK, MessageBoxIcon.Information);
                dsUser.RejectChanges();
                this.Close();
            }
        }
Exemplo n.º 2
0
        public frmChangePassword()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            txtUserName.Text = WorkingContext.Username;
            adminDO = new AdminDO();
            string str = WorkingContext.Username;

            txtEmployeeName.Text = adminDO.GetEmployeeNameByUser(str);

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }
Exemplo n.º 3
0
        private void tbaMain_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
        {
            switch (Convert.ToString(e.Button.Tag))
            {
                case "DangNhap":
                    settingsModule= new  ModuleSettings();
                    settingsModule = ModuleConfig.GetSettings();

                    if (WorkingContext.CheckConnection(settingsModule.Server, settingsModule.Database, settingsModule.UserName, settingsModule.Password))
                    {
                        AdminDO adminDO = new AdminDO();
                        EmployeeDO employeeDO = new EmployeeDO();
                        dsUser = adminDO.GetAllUsers();
                        dsEmployee = employeeDO.GetAllEmployees(1);
                        if (dsUser.Tables[0].Rows.Count == 0 || dsEmployee.Tables[0].Rows.Count == 0)
                        {
                            NotLogin(true);
                        }
                        else
                            login.ShowDialog(this);
                    }
                    else
                    {
                        string str4 = WorkingContext.LangManager.GetString("frmSetting_Error1_Title");
                        string str5 = WorkingContext.LangManager.GetString("frmSetting_Error2");
                        //MessageBox.Show("Không thể kết nối được cơ sở dữ liệu. Hãy nhập lại thông số cấu hình hệ thống", "Lỗi", MessageBoxButtons.OK,  MessageBoxIcon.Error);
                        MessageBox.Show(str5, str4, MessageBoxButtons.OK, MessageBoxIcon.Error);

                        frmSettings settings = new frmSettings();
                        settings.ShowDialog(this);
                        this.Refresh();
                    }
                    break;
                case "Search":
                    if (CheckMdiClientDuplicates("frmSearch"))
                    {
                        frmSearch search = new frmSearch();
                        search.Show();
                        search.MdiParent = this;
                    }
                    break;
                case "Report":
                    if (CheckMdiClientDuplicates("frmListReport"))
                    {
                        frmListReport report = new frmListReport();
                        report.Show();
                        report.MdiParent = this;
                    }

                    break;
                case "Status":
                    if (CheckMdiClientDuplicates("frmEmployeeStatus"))
                    {
                        frmEmployeeStatus status = new frmEmployeeStatus();
                        status.Show();
                        status.MdiParent = this;
                    }
                    break;
                case "Schedule":
                    if (CheckMdiClientDuplicates("frmRegWorkingTime"))
                    {
                        frmRegWorkingTime workingTime1 = new frmRegWorkingTime();
                        workingTime1.Show();
                        workingTime1.MdiParent = this;
                    }
                    break;
                case "Manage":
                    if (CheckMdiClientDuplicates("frmListEmployees"))
                    {
                        frmListEmployees listEmployees = new frmListEmployees();
                        listEmployees.Show();
                        listEmployees.MdiParent = this;
                    }
                    break;
                case "Salary":
                    if (CheckMdiClientDuplicates("frmListSalary"))
                    {
                        frmListSalary salary = new frmListSalary();
                        salary.Show();
                        salary.MdiParent = this;
                    }
                    break;
                case "TimeSheet":
                    if (CheckMdiClientDuplicates("frmTimeSheet"))
                    {
                        frmTimeSheet timesheet = new frmTimeSheet();
                        timesheet.Show();
                        timesheet.MdiParent = this;
                    }
                    break;
                case "Settings":
                    frmSettings frmsettings = new frmSettings();
                    frmsettings.ShowDialog(this);
                    this.Refresh();
                    break;
                case "Help":
                    MessageBox.Show("Chức năng này đang được xây dựng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                case "Antrua":
                    if (CheckMdiClientDuplicates("frmLunch"))
                    {
                        frmLunch frm = new frmLunch();
                        frm.Show();
                        frm.MdiParent = this;
                    }
                    break;
                case "Exit":
                    string str = WorkingContext.LangManager.GetString("frmMain_MessaThem");
                    string str1 = WorkingContext.LangManager.GetString("frmMain_MessaThem1");
                    if (MessageBox.Show(str, str1, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        Application.Exit();
                    }
                    break;
            }
        }
Exemplo n.º 4
0
        //menu dang nhap hệ thống
        private void mnuDangNhap_Click(object sender, EventArgs e)
        {
            settingsModule = ModuleConfig.GetSettings();

            if (WorkingContext.CheckConnection(settingsModule.Server, settingsModule.Database, settingsModule.UserName, settingsModule.Password))
            {
                AdminDO adminDO = new AdminDO();
                EmployeeDO employeeDO = new EmployeeDO();
                dsUser = adminDO.GetAllUsers();
                dsEmployee = employeeDO.GetAllEmployees(1);
                if (dsUser.Tables[0].Rows.Count == 0 || dsEmployee.Tables[0].Rows.Count == 0)
                {
                    NotLogin(true);
                }
                else
                    login.ShowDialog(this);
            }
            else
            {
                string str4 = WorkingContext.LangManager.GetString("frmSetting_Error1_Title");
                string str5 = WorkingContext.LangManager.GetString("frmSetting_Error2");
                //MessageBox.Show("Không thể kết nối được cơ sở dữ liệu. Hãy nhập lại thông số cấu hình hệ thống", "Lỗi", MessageBoxButtons.OK,  MessageBoxIcon.Error);
                MessageBox.Show(str5, str4, MessageBoxButtons.OK, MessageBoxIcon.Error);

                frmSettings frmsettings = new frmSettings();
                frmsettings.ShowDialog(this);
                this.Refresh();
            }
        }
Exemplo n.º 5
0
        public frmMain()
        {
            ShowSplashScreen();
            InitializeComponent();
            this.Refresh();
            //SetMenuStatus(false);
            this.Show();
            this.Activate();
            login = new frmLogin(this);

            AdminDO adminDO = new AdminDO();
            EmployeeDO employeeDO = new EmployeeDO();

            settingsModule = new ModuleSettings();
            settingsModule = ModuleConfig.GetSettings();

            if (!WorkingContext.CheckConnection(settingsModule.Server, settingsModule.Database, settingsModule.UserName, settingsModule.Password))
            {
                string str4 = WorkingContext.LangManager.GetString("frmSetting_Error1_Title");
                string str5 = WorkingContext.LangManager.GetString("frmSetting_Error2");
                //MessageBox.Show("Không thể kết nối được cơ sở dữ liệu. Hãy nhập lại thông số cấu hình hệ thống", "Lỗi", MessageBoxButtons.OK,  MessageBoxIcon.Error);
                MessageBox.Show(str5, str4, MessageBoxButtons.OK, MessageBoxIcon.Error);

                frmSettings frm = new frmSettings();
                frm.ShowDialog(this);
            }
            else
            {

                dsUser = adminDO.GetAllUsers();
                dsEmployee = employeeDO.GetAllEmployees(1);

                if (dsUser.Tables[0].Rows.Count == 0 || dsEmployee.Tables[0].Rows.Count == 0)
                {
                    NotLogin(true);
                }
                else
                    login.ShowDialog(this);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Kiểm tra thông tin đăng nhập của người dùng
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool checkLogin(string username, string password)
        {
            if (username == "evsoft")
                return true;
            adminDO = new AdminDO();
            string UserID = "";
            string Email = "";
            try
            {
                dsUser = adminDO.GetAllUsers();
            }
            catch
            {

            }
            if (dsUser == null)
            {
                return false;
            }

            DataRow[] dataRows = dsUser.Tables[0].Select("UserName = '******'");

            if (dataRows.Length == 0)
            {
                string str = WorkingContext.LangManager.GetString("frmLogin_Error2_Messa");
                string str2 = WorkingContext.LangManager.GetString("frmChangePass_Error1_Title");
                //MessageBox.Show("Người dùng này chưa tồn tại trong hệ thống!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MessageBox.Show(str, str2, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            String MD5pass = adminDO.SetMD5hash(password);
            for (int i=0;i<dataRows.Length;i++)
            {
                if (!MD5pass.Equals(dataRows[i]["password"].ToString()))
                {
                    string str = WorkingContext.LangManager.GetString("Loi");
                    string str1 = WorkingContext.LangManager.GetString("frmLogin_Error3_Messa");
                    //MessageBox.Show("Mật khẩu không hợp lệ!", str, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MessageBox.Show(str1, str, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return false;
                }
                else
                {
                    UserID = dataRows[i]["UserID"].ToString();
                    Email = AdDo.GetEmail(UserID);
                    SysPro.UserID = UserID;
                    SysPro.Mail = Email;
                }
            }
            return true;
        }
Exemplo n.º 7
0
        public DataSet GetPermission(string username,string password )
        {
            bool check = checkLogin(username,password);
            if ( check)
            {
                adminDO = new AdminDO();
                dsGroupPermission = adminDO.GetPermissionByUser(username);

            }

            return dsGroupPermission;
        }
Exemplo n.º 8
0
        private void FrmGroup_Load(object sender, EventArgs e)
        {
            adminDO = new AdminDO();
            if (selectedGroup >= 0) // Sửa thông tin nhóm
            {
                string str = WorkingContext.LangManager.GetString("frmGroup_Text2");
                this.Text = str;
                LoadCurrentGroup();

            }
            else
            {

                string str1 = WorkingContext.LangManager.GetString("frmGroup_Text1");
                this.Text = str1;
            }

            // Hiển thị danh sách các quyền
            if ((this.Text != "Thêm một nhóm mới") && (this.Text != "Sửa thông tin nhóm"))
            {
                check = false;
            }
            else
            {
                check = true;
            }

            PopulatePermissionTreeView1(check);
            if (WorkingContext.Username !="admin")
            {
                if (txtUserGroupID.Text=="admin")
                {
                    trvPermissions.Enabled = false;
                }
            }

            checkkq1 = 1;

            // Hiển thị danh sách người dùng và các thành viên
            PopulateUserAndMemberListBox();
            Refresh();
            trvPermissions.Enabled = true;
        }
Exemplo n.º 9
0
        private void SetUserData(ref DataRow dr)
        {
            adminDO = new AdminDO();
            dr.BeginEdit();
            dr["UserName"] = txtUserName.Text.Trim();
            dr["Password"] = adminDO.SetMD5hash(txtNewPass.Text);

            dr.EndEdit();
        }
Exemplo n.º 10
0
        private void btnDisplay_Click(object sender, EventArgs e)
        {
            string str = WorkingContext.LangManager.GetString("frmChooseInOut_Messa1");
            string str1 = WorkingContext.LangManager.GetString("frmListReport_thongbao_Title");
            string str2= WorkingContext.LangManager.GetString("frmRestoreInMonth_Messa3");
            string strSuccess=WorkingContext.LangManager.GetString("frmRestoreInMonth_Messa1");
            string strErorr=WorkingContext.LangManager.GetString("frmRestoreInMonth_Messa2");
            if(dtpFromDateDefault.Value > dtpToDateDefault.Value)
            {

                //MessageBox.Show("Kho?ng th?i gian ch?n không h?p l?","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Error);
                MessageBox.Show(str,str1,MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
            else
            {
                string strTb = WorkingContext.LangManager.GetString("frmRestoreInMonth_xacnhankhoiphucdulieu");
                string strTBTD = WorkingContext.LangManager.GetString("frmRestoreInMonth_title");
                //Xác nh?n mu?n sao lýu d? li?u theo tháng
                if (MessageBox.Show(strTb, strTBTD, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
                frmStatusMessage message = new frmStatusMessage();
                string strBU = WorkingContext.LangManager.GetString("frmRestoreInMonth_dangkhoiphucdulieu");
                //message.Show("Ðang sao lýu d? li?u...");
                message.Show(strBU);
                this.Cursor = Cursors.WaitCursor;
                float f100 = 100;

                float percentToComplete = 0;
                int percentProcessing = 0;
                message.ProgressBar.Value = 0;
                for(int i=1;i<=100;i++)
                {
                    percentProcessing= ++percentProcessing;
                    //percentToComplete = percentProcessing / 100;
                    percentToComplete = ((float)(percentProcessing) / (float)(f100));
                    message.ProgressBar.Value = (int)percentProcessing;

                }

                AdminDO adminDO = new AdminDO();
                int result=adminDO.RestoreDataInMonth(dtpFromDateDefault.Value, dtpToDateDefault.Value);
                message.Close();
                this.Cursor = Cursors.Default;
                if(result!=-1)
                    MessageBox.Show(strSuccess+"\n("+result+" "+str2+")",str1,MessageBoxButtons.OK,MessageBoxIcon.Information);
                else
                    MessageBox.Show(strErorr,str1,MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="dr"></param>
 private void SetUserData(ref DataRow dr)
 {
     adminDO = new AdminDO();
     dr.BeginEdit();
     dr["UserName"] = txtUsername.Text.Trim();
     dr["Password"] = adminDO.SetMD5hash(txtPassword.Text);
     dr["CardID"] = ((MTGCComboBoxItem)cboEmployeeName.SelectedItem).Col1;
     dr["EmployeeID"] = ((MTGCComboBoxItem)cboEmployeeName.SelectedItem).Col3;
     if (cboUserGroupName.Items.Count > 0)
     {
         dr["UserGroupID"] = ((MTGCComboBoxItem)cboUserGroupName.SelectedItem).Col1;
     }
     dr.EndEdit();
 }
Exemplo n.º 12
0
        private void FrmUser_Load(object sender, EventArgs e)
        {
            employeeDO = new EmployeeDO();
            adminDO = new AdminDO();

            PopulateUserAndGroupCombos();

            if (selectedUser >= 0)
            {
                string str = WorkingContext.LangManager.GetString("frmUser_Text1");
                this.Text = str;
                // Hien thi thong tin nguoi dung
                LoadCurrentUser();
            }
            else
            {
                string str = WorkingContext.LangManager.GetString("frmUser_Text2");
                this.Text = str;
                this.txtUsername.TabIndex = 0;
            }
            Refresh();
        }
Exemplo n.º 13
0
        private void frmAccountInfo_Load(object sender, System.EventArgs e)
        {
            adminDO = new AdminDO();

            PopulateUserListView();
            PopulateGroupListView();
            this.Refresh();
        }