Example #1
0
        private void Load_Data_From_Database()
        {
            DataTable dt = ManagerForm.ReadData_slr("SELECT ID, MONTH, YEAR, TOTALTIME, BS, ADDS, SALARYLV, SLR FROM SALARY");

            if (dt != null)
            {
                dgv_slr.DataSource = dt;
            }
        }
Example #2
0
        private void dgv_slr_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            int numrow;

            numrow = e.RowIndex;
            if (numrow >= 0)
            {
                tb_slr_id.Text        = dgv_slr.Rows[numrow].Cells[0].Value.ToString();
                tb_slr_name.Text      = ManagerForm.ReadDataa("SELECT STAFF.FULLNAME FROM STAFF WHERE STAFF.ID = '" + dgv_slr.Rows[numrow].Cells[0].Value.ToString() + "'").ToString();
                tb_slr_payrate.Text   = dgv_slr.Rows[numrow].Cells[3].Value.ToString();
                tb_slr_allowence.Text = dgv_slr.Rows[numrow].Cells[5].Value.ToString();
                tb_slr_basicrate.Text = dgv_slr.Rows[numrow].Cells[4].Value.ToString();
                tb_slr_tl.Text        = dgv_slr.Rows[numrow].Cells[6].Value.ToString();
            }
        }
        // Sự kiện khi người dùnng ấn nút log out tk
        private void LogoutButton_Click(object sender, EventArgs e)
        {
            logouttime = DateTime.Now.ToString();
            if (LoginAccountForm.who == 0)
            {
                ManagerForm.EXECUTEDATAA("INSERT INTO STAFFLOG VALUES ('" + lb_st_id.Text + "','" + LoginAccountForm.logintime + "','" + logouttime + "','0','" + data.user + "','')");
                ManagerForm.EXECUTEDATAA("UPDATE STAFFLOG SET WTIME = DATEDIFF(SECOND,STAFFLOG.LOGINTIME,STAFFLOG.LOGOUTTIME) WHERE STAFFLOG.LOGINTIME = '" + LoginAccountForm.logintime + "'");
            }
            else if (LoginAccountForm.who == 1)
            {
                ManagerForm.EXECUTEDATAA("INSERT INTO STAFFLOG VALUES ('" + lb_st_id.Text + "','" + LoginAccountForm.logintime + "','" + logouttime + "','1','" + data.user + "','')");
                ManagerForm.EXECUTEDATAA("UPDATE STAFFLOG SET WTIME = DATEDIFF(SECOND,STAFFLOG.LOGINTIME,STAFFLOG.LOGOUTTIME) WHERE STAFFLOG.LOGINTIME = '" + LoginAccountForm.logintime + "'");
            }
            LoginAccountForm loginForm = new LoginAccountForm(); // Khai báo form đăng nhập để xuất khi người dùng đăng xuất tk

            this.Dispose();                                      // Tắt form đang thao tác

            loginForm.Show();                                    // Xuất form đăng nhập
        }
Example #4
0
        private void Calslr()
        {
            if (ManagerForm.EXECUTEDATA("INSERT INTO SALARY(ID, MONTH, YEAR, TOTALTIME, BS, ADDS, SALARYLV) SELECT STAFFLOG.ID, MONTH(LOGINTIME), YEAR(LOGINTIME), SUM(WTIME), STAFF.BASICRATE, STAFF.ALLOWENCE, STAFF.PAYRATE FROM STAFF, STAFFLOG WHERE MONTH(LOGINTIME) = '" + cbb_slr_m.SelectedItem.ToString() + "' AND YEAR(LOGINTIME) = '" + cbb_slr_y.SelectedItem.ToString() + "' AND STAFF.ID = STAFFLOG.ID GROUP BY STAFFLOG.ID, MONTH(LOGINTIME), YEAR(LOGINTIME), STAFF.BASICRATE, STAFF.ALLOWENCE, STAFF.PAYRATE"))
            {
                ManagerForm.EXECUTEDATAA("UPDATE SALARY SET SLR = [BS]*[TOTALTIME]*[SALARYLV]+[ADDS]");
                DataTable dt = ManagerForm.ReadData_slr("SELECT ID, MONTH, YEAR, TOTALTIME, BS, ADDS, SALARYLV, SLR FROM SALARY WHERE MONTH = '" + cbb_slr_m.SelectedItem.ToString() + "' AND YEAR = '" + cbb_slr_y.SelectedItem.ToString() + "'");
                if (dt != null)
                {
                    dgv_slr.Columns[0].HeaderText = ("Mã nhân viên");
                    dgv_slr.Columns[1].HeaderText = ("Tháng");
                    dgv_slr.Columns[2].HeaderText = ("Năm");
                    dgv_slr.Columns[3].HeaderText = ("Tổng giờ làm");
                    dgv_slr.Columns[4].HeaderText = ("Lương cơ bản");
                    dgv_slr.Columns[5].HeaderText = ("Phụ cấp");
                    dgv_slr.Columns[6].HeaderText = ("Bậc lương");
                    dgv_slr.Columns[7].HeaderText = ("Tổng lương");
                }
            }
            else
            {
                //ManagerForm.EXECUTEDATAA("UPDATE SALARY SET SLR = [BS]*[TOTALTIME]*[SALARYLV]+[ADDS]");
                DataTable dt = ManagerForm.ReadData_slr("SELECT ID, MONTH, YEAR, TOTALTIME, BS, ADDS, SALARYLV, SLR FROM SALARY WHERE MONTH = '" + cbb_slr_m.SelectedItem.ToString() + "' AND YEAR = '" + cbb_slr_y.SelectedItem.ToString() + "'");
                if (dt != null)
                {
                    dgv_slr.DataSource = dt;

                    dgv_slr.Columns[0].HeaderText = ("Mã nhân viên");
                    dgv_slr.Columns[1].HeaderText = ("Tháng");
                    dgv_slr.Columns[2].HeaderText = ("Năm");
                    dgv_slr.Columns[3].HeaderText = ("Tổng giờ làm");
                    dgv_slr.Columns[4].HeaderText = ("Lương cơ bản");
                    dgv_slr.Columns[5].HeaderText = ("Phụ cấp");
                    dgv_slr.Columns[6].HeaderText = ("Bậc lương");
                    dgv_slr.Columns[7].HeaderText = ("Tổng lương");
                }
            }
        }
 private void EmployeeForm_Load(object sender, EventArgs e)
 {
     lb_st_fn.Text = ManagerForm.ReadDataa("SELECT STAFF.FULLNAME FROM STAFF JOIN PASSWORD ON STAFF.ID = PASSWORD.ID WHERE PASSWORD.USERNAME = '******'").ToString();
     lb_st_id.Text = ManagerForm.ReadDataa("SELECT ID FROM PASSWORD WHERE PASSWORD.USERNAME = '******'").ToString();
 }