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 ChamCongNV getCCNV() { ChamCongNV ccnv = new ChamCongNV(); float i = 0; if (txtGioTru.Text == "") { ccnv.SoGioLam = 0; } else { i = float.Parse(txtGioTru.Text); ccnv.SoGioLam = 8 - i; } ccnv.CaLam = cbCaLam.Text; ccnv.MaNV = cbMaNV.SelectedValue.ToString(); ccnv.NgayLam = Convert.ToDateTime(dtNgay.Value.ToShortDateString()); ccnv.TenNV = txtTenNV.Text; return(ccnv); }
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(); }