//btn modify Insurance
        private void button7_Click(object sender, EventArgs e)
        {
            try
            {
                double TaxRate = Convert.ToDouble(this.txtbTaxRate.Text);
                if (TaxRate > 100)
                {
                    this.txtbTaxRate.Text = TaxRate.ToString("#,##0");
                }
                else if (TaxRate > 1)
                {
                    this.txtbTaxRate.Text = (TaxRate / 100).ToString();
                }
                int index = lstInsurance[(int)this.bunifuCustomDataGrid1.CurrentRow.Cells[0].Value - 1].ID;

                var itemModifyInsurance = data.BAOHIEM_THUE.Find(index);
                itemModifyInsurance.PhanTramBaoHiem = Convert.ToDouble(this.txtbTaxRate.Text);
                int res = data.SaveChanges();
                if (res != 0)
                {
                    MessageBox.Show("Cập nhật thành công");
                    this.lbNameInsurance.Text = "";
                    this.txtbTaxRate.Text     = "";
                    LoadData();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Thuế suất không hợp lệ !!");
                this.txtbTaxRate.Text = "";
            }
        }
 //nút xóa ngày nghỉ
 private void btnDelete_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < this.bunifuCustomDataGrid1.SelectedRows.Count; i++)
     {
         data.NHANVIEN_LOAINGAYNGHI.Remove(data.NHANVIEN_LOAINGAYNGHI.Find(this.listOFFStaff[(int)this.bunifuCustomDataGrid1.CurrentRow.Cells[0].Value - 1].ID));
         data.SaveChanges();
     }
     LoadData();
 }
Beispiel #3
0
 private void bunifuCustomDataGrid1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 4)
     {
         DialogResult dialogResult = MessageBox.Show("Bạn có muốn xóa ?", "Some Title", MessageBoxButtons.YesNo);
         if (dialogResult == DialogResult.Yes)
         {
             data.NHANVIEN_GIOCONG.Remove(data.NHANVIEN_GIOCONG.Find(Convert.ToInt32(lstWorkingDayOfAEmployee[Convert.ToInt32(this.bunifuCustomDataGrid1.SelectedRows[0].Cells[0].Value) - 1].ID)));
             data.SaveChanges();
         }
         else if (dialogResult == DialogResult.No)
         {
             //do something else
         }
         LoadData();
     }
 }
Beispiel #4
0
 //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();
 }
Beispiel #5
0
 //btn Add OT
 private void button1_Click_1(object sender, EventArgs e)
 {
     if (this.txtOTHours.Text == null)
     {
         MessageBox.Show("Cần nhập số giờ OT");
     }
     else
     {
         DialogResult confirm = MessageBox.Show("Do you want to save changes?", "Confirmation", MessageBoxButtons.YesNoCancel);
         if (confirm == DialogResult.Yes)
         {
             NHANVIEN_OT OTOfStaff = new NHANVIEN_OT();
             OTOfStaff.ID_NhanVien       = Convert.ToInt32(this.cbNameOfStaff.SelectedValue);
             OTOfStaff.DateDangKy        = this.DateCreateOT.Value;
             OTOfStaff.SoGioOT           = Convert.ToDouble(this.txtOTHours.Text);
             OTOfStaff.ID_Range_Hours_OT = Convert.ToInt32(this.cbRangeHoursOT.SelectedValue);
             data.NHANVIEN_OT.Add(OTOfStaff);
             int resultCreate = data.SaveChanges();
             if (resultCreate < 1)
             {
                 MessageBox.Show("Thêm thất bại !!!");
             }
             else
             {
                 MessageBox.Show("Thêm thành công");
                 this.lbUserName.Text = "";
                 this.cbRangeHoursOT.SelectedValue = -1;
                 this.cbNameOfStaff.SelectedValue  = -1;
                 this.txtOTHours.Text = "";
                 if (addDataSuccess != null)
                 {
                     addDataSuccess(this, null);
                 }
             }
         }
     }
 }
Beispiel #6
0
        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 ");
                    }
                }
            }
        }