private void btnAddInfoEmployee_Click(object sender, EventArgs e) { //Kiem tra tuoi cua nhan vien moi da 18 tuoi chưa if (DateTime.Today.Year - this.txtBirth.Value.Year < 18) { MessageBox.Show("Ngày sinh không hợp lệ !!!!!"); } else { bool flag; flag = (this.txtName.Text == "" || this.txtName.Text == null) || (this.txtUserID.Text == "" || this.txtUserID.Text == null) || (this.txtUserName.Text == "" || this.txtUserName == null); if (flag) { MessageBox.Show("Họ tên , UserID, User Name không được bỏ trống !!!!!!"); } else { DialogResult confirm = MessageBox.Show("Do you want to save changes?", "Confirmation", MessageBoxButtons.YesNoCancel); if (confirm == DialogResult.Yes) { NHANSU temp = LoadDataForms(); data.NHANSUs.Add(temp); data.SaveChanges(); Close(); MessageBox.Show("Thêm thành công "); } } } }
public THONGTINNHANVIEN(int id) { this.id = id; InitializeComponent(); this.ManPicture.Visible = false; this.pictureBox2.Visible = false; this.btnAddInfoEmployee.Hide(); this.btnRepairInfoEmployee.Show(); ShowOption(); //fnDisplayStaffFollowID_Result temp = data.NHANSUs.Find(id).; NHANSU temp = data.NHANSUs.Find(id); DisplayData(temp); }
private NHANSU LoadDataForms() { NHANSU a = new NHANSU(); //Đọc thông tin nhân viên từ forms a.HoVaTen = this.txtName.Text; a.UserID = this.txtUserID.Text; a.UserName = this.txtUserName.Text; a.EmailCongTy = this.txtEmailCo.Text == "" || this.txtEmailCo.Text == null ? null : this.txtEmailCo.Text; a.DiaChiThuongTru = (this.txtAddressPermanent.Text == "" || this.txtAddressPermanent == null) ? null : this.txtAddressPermanent.Text; a.DiaChiTamTru = this.txtAddressTemp.Text == "" || this.txtAddressTemp == null ? null : this.txtAddressTemp.Text; a.CMND = this.txtIdentify.Text == "" || this.txtIdentify.Text == null ? null : this.txtIdentify.Text; a.SoDT = this.txtPhonePer.Text == "" || this.txtPhonePer.Text == null ? null : this.txtPhonePer.Text; a.TinhTrangHonNhan = this.ComboBoxStateMarie.SelectedIndex == -1 ? null : this.ComboBoxStateMarie.SelectedItem.ToString(); a.NgaySinh = this.txtBirth.Value; //***** a.GioiTinh = this.txtSex.SelectedIndex == -1 || this.txtSex.SelectedIndex == 2 ? null : this.txtSex.SelectedItem.ToString(); a.MaSoThue = this.textTaxCode.Text == "" || this.textTaxCode.Text == null ? null : this.textTaxCode.Text; a.SoTKNganHang = this.txtNumBank.Text == "" || this.txtNumBank.Text == null ? null : this.txtNumBank.Text; a.HoTenNguoiLienQuan = this.txtNamePerRela.Text == "" || this.txtNamePerRela.Text == null ? null : this.txtNamePerRela.Text; a.DiaChiNguoiLienQuan = this.txtAddPerRela.Text == "" || this.txtAddPerRela.Text == null ? null : this.txtAddPerRela.Text; a.MoiQuanHe = this.txtRelationship.SelectedIndex == -1 ? null : this.txtRelationship.SelectedItem.ToString(); a.SDTNguoiLienQuan = this.txtPhonePer.Text == "" || this.txtPhonePer.Text == null ? null : this.txtPhonePer.Text; a.GioiTinhNguoiLienQuan = this.checkSexPerRela.SelectedIndex == -1 || this.checkSexPerRela.SelectedIndex == 2 ? null : this.checkSexPerRela.SelectedItem.ToString(); a.NgaySinhNguoiLienQuan = this.birthPerRela.Value == DateTime.Now ? new DateTime(1800, 01, 01) : this.birthPerRela.Value; //***** a.TrinhDo = this.txtLevel.Text == "" || this.txtLevel == null ? null : this.txtLevel.Text; //Đọc thông tin công việc từ forms a.ChucDanh = Convert.ToInt32(this.lstBoxTitle.SelectedValue) == 0 ? 6 : Convert.ToInt32(this.lstBoxTitle.SelectedValue); a.NoiLamViec = this.txtAddCo.Text == "" || this.txtAddCo.Text == null ? null : this.txtAddCo.Text; a.NguoiPhuTrach = Convert.ToInt32(this.lstBoxSupervisor.SelectedValue) == 0 ? -1 : Convert.ToInt32(this.lstBoxSupervisor.SelectedValue); a.TrangThaiLamViec = Convert.ToInt32(this.lstBoxStateWorking.SelectedValue); a.LuongCB = this.txtSalary.Text == "" || this.txtSalary.Text == null ? 0 : decimal.Parse(this.txtSalary.Text.Replace(",", "")); a.LoaiHDLD = this.txtTitleLabourContract.Text == "" || this.txtTitleLabourContract.Text == null ? null : this.txtTitleLabourContract.Text; a.SoHDLD = this.txtNumLarbourContract.Text == "" || this.txtNumLarbourContract.Text == null ? null : this.txtNumLarbourContract.Text; a.ThoiHanHDLD = this.txtDateLimit.Text == "" || this.txtDateLimit.Text == null ? 0 : Convert.ToInt32(this.txtDateLimit.Text.Replace(" Tháng", "")); a.NgayBatDau = this.dateStartWorking.Value > new DateTime(1970, 01, 01) ? DateTime.Now : this.dateStartWorking.Value; //***** return(a); }
public Payroll(int IDNhanVien, DateTime ThangNam) { this.data = new TinhTienLuongEntities(); this.ID_NhanVien = IDNhanVien; this.ThangNam = ThangNam; NHANSU staff = data.NHANSUs.Find(this.ID_NhanVien); if (staff != null && staff.ID <= 10) { Calculate val = new Calculate(); this.Wfh = val.CALCULATE(("OTH_33").Split(' '), ID_NhanVien, ThangNam); this.AtWork = val.CALCULATE(("OTH_32").Split(' '), ID_NhanVien, ThangNam); this.LeaveHours = val.CALCULATE(("OTH_32").Split(' '), ID_NhanVien, ThangNam); this.Km = val.CALCULATE(("OTH_37").Split(' '), ID_NhanVien, ThangNam); this.SalaryBasic = val.CALCULATE(("OTH_34").Split(' '), ID_NhanVien, ThangNam); this.OTSalary = val.CALCULATE(("OTH_13").Split(' '), ID_NhanVien, ThangNam); this.Responsi_Japanese = val.CALCULATE(("OTH_3").Split(' '), ID_NhanVien, ThangNam); this.Parking_Gasoline = val.CALCULATE(("OTH_2").Split(' '), ID_NhanVien, ThangNam); this.BenefitWFH = val.CALCULATE(("OTH_1").Split(' '), ID_NhanVien, ThangNam); this.SalaryDeduction = val.CALCULATE(("OTH_5").Split(' '), ID_NhanVien, ThangNam); this.TotalAmount = val.CALCULATE(("OTH_6").Split(' '), ID_NhanVien, ThangNam); this.TotalAmountInVND = val.CALCULATE(("OTH_7").Split(' '), ID_NhanVien, ThangNam); this.SalaryForInsurance = val.CALCULATE(("OTH_17").Split(' '), ID_NhanVien, ThangNam); this.SalaryForUnemployted = val.CALCULATE(("OTH_18").Split(' '), ID_NhanVien, ThangNam); this.HealthyInsuranceStaff = val.CALCULATE(("OTH_19").Split(' '), ID_NhanVien, ThangNam); this.SocialInsuranceStaff = val.CALCULATE(("OTH_20").Split(' '), ID_NhanVien, ThangNam); this.UnemploytedInsuranceStaff = val.CALCULATE(("OTH_21").Split(' '), ID_NhanVien, ThangNam); this.UnemploytedInsuranceEnterprise = val.CALCULATE(("OTH_22").Split(' '), ID_NhanVien, ThangNam); this.HealthyInsuranceEnterprise = val.CALCULATE(("OTH_23").Split(' '), ID_NhanVien, ThangNam); this.SocialInsuranceEnterprise = val.CALCULATE(("OTH_24").Split(' '), ID_NhanVien, ThangNam); this.OTDeduction = val.CALCULATE(("OTH_16").Split(' '), ID_NhanVien, ThangNam); this.PersonalDeduction = val.CALCULATE(("OTH_27").Split(' '), ID_NhanVien, ThangNam); this.AmountDependentPersonalDeduction = val.CALCULATE(("OTH_28").Split(' '), ID_NhanVien, ThangNam); this.TaxableIncome = val.CALCULATE(("OTH_29").Split(' '), ID_NhanVien, ThangNam); this.PITPayment = val.CALCULATE(("OTH_30").Split(' '), ID_NhanVien, ThangNam); } }
//multi selected được lưu theo nguyên tắc LIFO - button delete user private void button2_Click(object sender, EventArgs e) { try { for (int i = 0; i < this.bunifuCustomDataGrid1.SelectedRows.Count; i++) { int index = this.lstStaff[(int)this.bunifuCustomDataGrid1.SelectedRows[i].Cells[0].Value - 1].ID; NHANSU temp = data.NHANSUs.SingleOrDefault(id => id.ID == index); int j = 1; if (temp != null) { temp.TrangThaiLamViec = 1; data.SaveChanges(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } LoadData(); }
public void DisplayData(NHANSU a) { //điền các trường vào form //thông tin nhân viên this.txtName.Text = a.HoVaTen; //** this.txtIdentify.Text = a.CMND; this.txtAddressTemp.Text = a.DiaChiTamTru; this.txtAddressPermanent.Text = a.DiaChiThuongTru; this.txtLevel.Text = a.TrinhDo; this.txtNumBank.Text = a.SoTKNganHang; this.txtBirth.Value = (DateTime)a.NgaySinh; this.txtPhonePer.Text = a.SoDT; if (a.TinhTrangHonNhan == "Đã kết hôn") { this.ComboBoxStateMarie.SelectedIndex = 1; } else { this.ComboBoxStateMarie.SelectedIndex = 0; } //thông tin người liên quan this.txtNamePerRela.Text = a.HoTenNguoiLienQuan; this.txtAddPerRela.Text = a.DiaChiNguoiLienQuan; this.txtPhonePerRela.Text = a.SDTNguoiLienQuan; this.birthPerRela.Value = (DateTime.Compare(new DateTime(1800, 01, 01), (DateTime)a.NgaySinhNguoiLienQuan) < 0) ? (DateTime)a.NgaySinhNguoiLienQuan : new DateTime(9998, 12, 31); if (a.GioiTinhNguoiLienQuan == "Nam") { this.checkSexPerRela.SelectedIndex = 0; } else if (String.Compare(a.GioiTinhNguoiLienQuan, "Nữ", true) == 0) { this.checkSexPerRela.SelectedIndex = 1; } else { this.checkSexPerRela.SelectedIndex = 2; } if (a.GioiTinh == null) { this.txtSex.SelectedIndex = 2; } else { if (a.GioiTinh.Replace(" ", "") == "Nam") { this.txtSex.SelectedIndex = 0; this.ManPicture.Show(); this.pictureBox2.Hide(); } else { this.txtSex.SelectedIndex = 1; this.ManPicture.Hide(); this.pictureBox2.Show(); } } this.txtRelationship.Text = a.MoiQuanHe; //thông tin công việc this.txtUserID.Text = a.UserID; this.txtUserID.Enabled = false; this.txtUserName.Text = a.UserName; this.lstBoxSupervisor.SelectedValue = a.NguoiPhuTrach == null ? -1 : a.NguoiPhuTrach; this.lstBoxTitle.SelectedValue = a.ChucDanh == null ? -1 : Convert.ToInt32(a.ChucDanh); this.lstBoxStateWorking.SelectedValue = a.TrangThaiLamViec == null ? -1 : a.TrangThaiLamViec; this.txtEmailCo.Text = a.EmailCongTy; this.txtAddCo.Text = a.NoiLamViec; this.txtSalary.Text = ((decimal)a.LuongCB).ToString("#,##0.###"); this.txtNumLarbourContract.Text = a.SoHDLD; this.txtTitleLabourContract.Text = a.LoaiHDLD; this.txtDateLimit.Text = a.ThoiHanHDLD + " Tháng"; }
private void btnRepairInfoEmployee_Click(object sender, EventArgs e) { if (DateTime.Today.Year - this.txtBirth.Value.Year < 18) { MessageBox.Show("Ngày sinh không hợp lệ !!!!!"); } else { bool flag; flag = (this.txtName.Text == "" || this.txtName.Text == null) || (this.txtUserID.Text == "" || this.txtUserID.Text == null) || (this.txtUserName.Text == "" || this.txtUserName == null); if (flag) { MessageBox.Show("Họ tên , UserID, User Name không được bỏ trống !!!!!!"); } else { DialogResult confirm = MessageBox.Show("Do you want to save changes?", "Confirmation", MessageBoxButtons.YesNoCancel); if (confirm == DialogResult.Yes) { NHANSU temp = data.NHANSUs.SingleOrDefault(id => id.ID == this.id); if (temp != null) { temp.HoVaTen = LoadDataForms().HoVaTen; temp.UserID = LoadDataForms().UserID; temp.UserName = LoadDataForms().UserName; temp.EmailCongTy = LoadDataForms().EmailCongTy; temp.DiaChiThuongTru = LoadDataForms().DiaChiThuongTru; temp.DiaChiTamTru = LoadDataForms().DiaChiTamTru; temp.CMND = LoadDataForms().CMND; temp.SoDT = LoadDataForms().SoDT; temp.TinhTrangHonNhan = LoadDataForms().TinhTrangHonNhan; temp.NgaySinh = LoadDataForms().NgaySinh; temp.GioiTinh = LoadDataForms().GioiTinh; temp.MaSoThue = LoadDataForms().MaSoThue; temp.SoTKNganHang = LoadDataForms().SoTKNganHang; temp.HoTenNguoiLienQuan = LoadDataForms().HoTenNguoiLienQuan; temp.DiaChiNguoiLienQuan = LoadDataForms().DiaChiNguoiLienQuan; temp.MoiQuanHe = LoadDataForms().MoiQuanHe; temp.SDTNguoiLienQuan = LoadDataForms().SDTNguoiLienQuan; temp.GioiTinhNguoiLienQuan = LoadDataForms().GioiTinhNguoiLienQuan; temp.NgaySinhNguoiLienQuan = LoadDataForms().NgaySinhNguoiLienQuan; temp.TrinhDo = LoadDataForms().TrinhDo; //Đọc thông tin công việc từ forms temp.ChucDanh = LoadDataForms().ChucDanh; temp.NoiLamViec = LoadDataForms().NoiLamViec; temp.NguoiPhuTrach = LoadDataForms().NguoiPhuTrach; temp.TrangThaiLamViec = LoadDataForms().TrangThaiLamViec; temp.LuongCB = LoadDataForms().LuongCB; temp.LoaiHDLD = LoadDataForms().LoaiHDLD; temp.SoHDLD = LoadDataForms().SoHDLD; temp.ThoiHanHDLD = LoadDataForms().ThoiHanHDLD; temp.NgayBatDau = LoadDataForms().NgayBatDau; data.SaveChanges(); } Close(); MessageBox.Show("Cập nhật thành công "); } } } }