Beispiel #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.dataSalary.SelectedRows.Count <= 0)
            {
                return;
            }
            string            message = "Bạn chắc chắn muốn xóa ?";
            string            title   = "Delete salary";
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            DialogResult      result  = MessageBox.Show(message, title, buttons);

            if (result == DialogResult.Yes)
            {
                Salary salary = SalaryController.getSalary(Convert.ToInt32(this.dataSalary.SelectedRows[0].Cells[0].Value), Convert.ToDateTime(this.dataSalary.SelectedRows[0].Cells[8].Value));
                SalaryController.DeleteSalary(salary);
                dataSalary.AutoGenerateColumns = false;
                source                = new BindingSource();
                source.DataSource     = SalaryController.getListSalary();
                dataSalary.DataSource = source;
            }
            else
            {
                return;
            }
        }
Beispiel #2
0
        private void cLocDuLieu_Click(object sender, EventArgs e)
        {
            DateTime month = Convert.ToDateTime(dtpLocDulieu.Value.ToString());

            dataSalary.AutoGenerateColumns = false;
            source                = new BindingSource();
            source.DataSource     = SalaryController.getSalary(month);
            dataSalary.DataSource = source;
        }
Beispiel #3
0
        private void dataSalary_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            Salary          salary   = new Salary();
            List <Employee> employee = SalaryController.GetIDEmployee(Convert.ToInt32(this.dataSalary.CurrentRow.Cells[0].Value));

            if (employee == null)
            {
                MessageBox.Show("Không tồn tại ID này ! Yêu cầu nhập lại ", "Lỗi");
                this.dataSalary.CurrentRow.Cells[0].Value = 0;
                return;
            }
            else
            {
                salary.IDEmployee = Convert.ToInt32(this.dataSalary.CurrentRow.Cells[0].Value);
            }
            DateTime t = Convert.ToDateTime(this.dataSalary.CurrentRow.Cells[8].Value);

            if (t.Year == 1)
            {
                MessageBox.Show("Bạn chưa nhập Tháng Năm", "Thông báo");
                return;
            }
            else
            {
                salary.Month = Convert.ToDateTime(this.dataSalary.CurrentRow.Cells[8].Value.ToString());
            }
            Salary salarys = SalaryController.getSalary(Convert.ToInt32(this.dataSalary.CurrentRow.Cells[0].Value), Convert.ToDateTime(this.dataSalary.CurrentRow.Cells[8].Value));

            if (e.ColumnIndex == 8 || e.ColumnIndex == 0)
            {
                if (salarys != null)
                {
                    MessageBox.Show("Trùng dữ liệu", "Lỗi");
                    source.DataSource = SalaryController.getListSalary();
                    return;
                }
            }
            salary.UserName = employee[0].UserName.ToString();
            if (this.dataSalary.CurrentRow.Cells[2].Value is null)
            {
                salary.LuongCoBan = 0;
            }
            else
            {
                salary.LuongCoBan = Convert.ToInt32(this.dataSalary.CurrentRow.Cells[2].Value);
            }
            if (this.dataSalary.CurrentRow.Cells[3].Value is null)
            {
                salary.Phat = 0;
            }
            else
            {
                salary.Phat = Convert.ToInt32(this.dataSalary.CurrentRow.Cells[3].Value);
            }
            if (this.dataSalary.CurrentRow.Cells[4].Value is null)
            {
                salary.Thuong = 0;
            }
            else
            {
                salary.Thuong = Convert.ToInt32(this.dataSalary.CurrentRow.Cells[4].Value);
            }
            if (this.dataSalary.CurrentRow.Cells[6].Value is null)
            {
                salary.LuongDaNhan = 0;
            }
            else
            {
                salary.LuongDaNhan = Convert.ToInt32(this.dataSalary.CurrentRow.Cells[6].Value);
            }
            this.dataSalary.AutoGenerateColumns = false;
            SalaryController.UpdateSalary(salary);
            source.DataSource = SalaryController.getListSalary();
        }