private void btnXoa_Click(object sender, EventArgs e) { ChamCongNV ccnv = getCCNV(); BangLuong bl = getBangLuong(); if (MessageBox.Show("Bạn có muốn xóa không?", "Xác nhận", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { if (ccsr.XoaCC(ccnv)) { float soGioLamDaCham = 0; float.TryParse(txtSoGioLam.Text, out soGioLamDaCham); float tgl = 0; string tggiolam = blsr.layGioLam(bl.MaNV, bl.Thang); float.TryParse(tggiolam, out tgl); float giolam = tgl - soGioLamDaCham; bl.TongGioLam = giolam; bl.TienLuong = bl.TongGioLam * bl.MucLuong; blsr.SuaBangLuong(bl); MessageBox.Show("Xóa thành công"); } else { MessageBox.Show("Không thể xóa"); } binData(); } }
private BangLuong getBangLuong() { BangLuong bl = new BangLuong(); int thang = dtNgay.Value.Month; bl.Thang = thang; bl.MaNV = cbMaNV.SelectedValue.ToString(); bl.TenNV = txtTenNV.Text; float mucluong = 0; string chucvu = blsr.layChucVu(cbMaNV.SelectedValue.ToString()); if (chucvu == "Quản Lý") { mucluong = 12000; } if (chucvu == "Phục Vụ" || chucvu == "Giữ Xe") { mucluong = 7000; } if (chucvu == "Thu Ngân" || chucvu == "Pha Chế") { mucluong = 10000; } if (chucvu == "Tạp Vụ") { mucluong = 8000; } bl.MucLuong = (float)mucluong; float tienluong = 0; tienluong = bl.TongGioLam; bl.TienLuong = tienluong; return(bl); }
private void btnLuu_Click(object sender, EventArgs e) { ChamCongNV ccnv = getCCNV(); BangLuong bl = getBangLuong(); ccnv.CaLam = cbCaLam.Text; int thang = dtNgay.Value.Month; DateTime ngaylam = Convert.ToDateTime(dtNgay.Value.ToShortDateString()); string calam = cbCaLam.Text; string manv = cbMaNV.SelectedValue.ToString(); if (ccsr.kiemtraCCNV(manv, ngaylam, calam)) { if (ccsr.SuaCC(ccnv)) { float soGioLamDaCham = 0; float.TryParse(txtSoGioLam.Text, out soGioLamDaCham); float tgl = 0; string tggiolam = blsr.layGioLam(bl.MaNV, bl.Thang); float.TryParse(tggiolam, out tgl); string sogiotru = txtGioTru.Text; float giotru = 0; float.TryParse(sogiotru, out giotru); float sogiolamdung = 8 - giotru; float giolam = (tgl + sogiolamdung) - soGioLamDaCham; bl.TongGioLam = giolam; bl.TienLuong = bl.TongGioLam * bl.MucLuong; blsr.SuaBangLuong(bl); MessageBox.Show("Sửa thành công"); } else { MessageBox.Show("Không thể sửa"); } } else { if (ccsr.ThemCC(ccnv)) { if (blsr.kiemTraBangLuong(thang, manv) == false) { blsr.ThemBangLuong(bl); } float giotru = 0; string sogiotru = txtGioTru.Text; float.TryParse(sogiotru, out giotru); float sogiolamdung = 8 - giotru; float tgl = 0; string tggiolam = blsr.layGioLam(bl.MaNV, bl.Thang); float.TryParse(tggiolam, out tgl); float giolam = tgl + sogiolamdung; bl.TongGioLam = giolam; bl.TienLuong = bl.TongGioLam * bl.MucLuong; blsr.SuaBangLuong(bl); MessageBox.Show("Thêm thành công"); } else { MessageBox.Show("Không thể thêm"); } } binData(); }