//Thêm hệ số lương public bool ThemHeSoLuong(HeSoLuongPhuCap heSo) { try { entity.HeSoLuongPhuCaps.Add(heSo); entity.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
//Xoá hệ số lương public bool XoaHeSoLuong(string maXoa) { try { HeSoLuongPhuCap heSo = (HeSoLuongPhuCap)entity.HeSoLuongPhuCaps.Where(s => s.MaHeSo == maXoa).First(); entity.HeSoLuongPhuCaps.Remove(heSo); entity.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
private void btnLuu_Click(object sender, EventArgs e) { try { NgachLuong ngach = (NgachLuong)cbNgach.SelectedItem; string tenHeSo = txtTenHeSo.Text; double HeSo; if (txtTenHeSo.Text.Trim() == "") { MessageBox.Show("Bạn phải nhập tên hệ số"); } else if (txtHeSo.Text == "") { MessageBox.Show("Bạn phải nhập hệ số"); } else if (double.TryParse(txtHeSo.Text, out HeSo) == false && txtHeSo.Text != "") { MessageBox.Show("Hệ số là số thực!"); } else if (bizHeSo.BIZ_KiemTraTenHeSo(ngach.MaNgach, tenHeSo) == false) { MessageBox.Show("Tên hệ số đã tồn tại!"); } else { HeSoLuongPhuCap heSoLuong = new HeSoLuongPhuCap(); heSoLuong.MaHeSo = bizHeSo.BIZ_TaoMaHeSoLuong(); heSoLuong.TenHeSo = tenHeSo; heSoLuong.HeSo = HeSo; heSoLuong.MaNgach = ngach.MaNgach; if (bizHeSo.BIZ_ThemHeSoLuong(heSoLuong) == true) { MessageBox.Show("Thêm thành công!"); txtTenHeSo.Text = ""; txtHeSo.Text = ""; } else { MessageBox.Show("Thêm không được dzồi!"); } } } catch (Exception ex) { MessageBox.Show("Lỗi hệ thống"); } }
//Sửa hệ số lương public bool SuaHeSoLuong(HeSoLuongPhuCap heSoSua) { try { entity.HeSoLuongPhuCaps.Attach(heSoSua); var heSo = entity.Entry(heSoSua); heSo.Property(s => s.TenHeSo).IsModified = true; heSo.Property(s => s.HeSo).IsModified = true; entity.SaveChanges(); return(true); } catch (Exception ex) { throw; } }
//Sửa hệ số lương public bool SuaHeSoLuong(HeSoLuongPhuCap heSoSua) { try { entity.HeSoLuongPhuCaps.Attach(heSoSua); var heSo = entity.Entry(heSoSua); heSo.Property(s => s.TenHeSo).IsModified = true; heSo.Property(s => s.HeSo).IsModified = true; entity.SaveChanges(); return true; } catch (Exception ex) { throw; } }
//Load form private void frm_SuaHeSoLuong_Load(object sender, EventArgs e) { try { //Đổ DL ngạch lương vào combobox List <NgachLuong> ngach = bizHeSo.BIZ_LayDLNgach(); cbNgach.DataSource = ngach; cbNgach.ValueMember = "MaNgach"; cbNgach.DisplayMember = "TenNgach"; //Lấy thông tin sửa heSoLuong = bizHeSo.BIZ_TimHeSoTheoMa(maHeSoSua); txtMaHeSo.Text = heSoLuong.MaHeSo; cbNgach.SelectedItem = heSoLuong.NgachLuong; txtTenHeSo.Text = heSoLuong.TenHeSo; txtHeSo.Text = heSoLuong.HeSo.ToString(); } catch (Exception ex) { MessageBox.Show("Lỗi hệ thống!"); } }
//Tìm hệ số lương theo mã để đổ DL vào form sửa public HeSoLuongPhuCap TimHeSoTheoMa(string maHeSo) { try { var dsTim = (from heso in entity.HeSoLuongPhuCaps join ngach in entity.NgachLuongs on heso.MaNgach equals ngach.MaNgach where heso.MaHeSo == maHeSo select heso).ToList(); if (dsTim.Count > 0) { HeSoLuongPhuCap hs = dsTim[0]; return(hs); } else { return(null); } } catch (Exception ex) { throw; } }
public bool BIZ_SuaHeSoLuong(HeSoLuongPhuCap heSoSua) { return(dalHeSo.SuaHeSoLuong(heSoSua)); }
public bool BIZ_ThemHeSoLuong(HeSoLuongPhuCap heSo) { return(dalHeSo.ThemHeSoLuong(heSo)); }
//Thêm hệ số lương public bool ThemHeSoLuong(HeSoLuongPhuCap heSo) { try { entity.HeSoLuongPhuCaps.Add(heSo); entity.SaveChanges(); return true; } catch (Exception ex) { return false; } }