Ejemplo n.º 1
0
 // them cong
 #region them cong
 private void _insert()
 {
     if (kiemtra_them())
     {
         DMBangcong bc = new DMBangcong();
         bc.Ngay       = date_ngaycong.DateTime.Day;
         bc.Thang      = date_ngaycong.DateTime.Month;
         bc.Nam        = date_ngaycong.DateTime.Year;
         bc.Manv       = txtManv.Text;
         bc.Maloaicong = cmbLoaicong.Text;
         bc.Giovao     = int.Parse(txtGiovao.Text.ToString());
         bc.Giora      = int.Parse(txtGiora.Text.ToString());
         bc.Phutra     = int.Parse(txtphutra.Text.ToString());
         bc.Phutvao    = int.Parse(txtPhutvao.Text.ToString());
         if (BUS_Bangcong._insert(bc) == "true")
         {
             MessageBox.Show("Thêm công thành công cho nhân viên có mã là: " + txtManv.Text + "", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             if (flag == 1)
             {
                 reload();
             }
             this.Close();
         }
         else
         {
             MessageBox.Show("Lỗi từ hệ thống, hãy liên hệ với bộ phận kỹ thuật", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Ejemplo n.º 2
0
        private void loadCrystalRpt()
        {
            try
            {
                if (kiemtra())
                {
                    THANG = cmbThang.Text;
                    NAM   = cmbNam.Text;
                    Report.rptBangcong Rp = new rptBangcong();

                    DataTable ds = BUS_Bangcong.selectAllBC(cmbThang.Text, cmbNam.Text);
                    Rp.SetDataSource(ds);
                    Rp.SetParameterValue("nam", Int32.Parse(NAM));
                    Rp.SetParameterValue("@nam", Int32.Parse(NAM));
                    if (cmbThang.Text == "----Chọn tháng----")
                    {
                        THANG = "0";
                        Rp.SetParameterValue("thang_nam", "NĂM " + NAM + " ");
                        Rp.SetParameterValue("dau", "");
                    }
                    else
                    {
                        Rp.SetParameterValue("thang_nam", "THÁNG " + THANG + " - " + NAM + "  ");
                        Rp.SetParameterValue("dau", " - ");
                    }
                    Rp.SetParameterValue("thang", Int32.Parse(THANG));
                    Rp.SetParameterValue("@thang", Int32.Parse(THANG));
                    crystalReportViewer1.ReportSource = Rp;
                }
            }
            catch
            {
                MessageBox.Show("Kết nối với máy chủ thất bại", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 3
0
        public bool kt_Them()
        {
            bool kt = true;

            if (txtManv.Text == "" || date_ngaycong.Text == "" || txtSogio.Text == "")
            {
                kt = false;
                MessageBox.Show("Hãy điền đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (BUS_Nhanvien.KiemTraMaNV(txtManv.Text) == "true")
            {
                kt = false;
                MessageBox.Show("Mã nhân viên không tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (BUS_Bangcong.kiemtra_ngaycong_trung(txtManv.Text, date_ngaycong.DateTime))
            {
                kt = false;
                MessageBox.Show("Ngày " + date_ngaycong.Text + " nhân viên có mã " + txtManv.Text + " không đi làm, nên không được tăng ca", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (int.Parse(txtSogio.Text.ToString()) < 0 || int.Parse(txtSogio.Text.ToString()) > 12)
            {
                kt = false;
                MessageBox.Show("Số giờ quá giới hạn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (!BUS_Tangca.kt_tangca_trung(txtManv.Text, date_ngaycong.DateTime))
            {
                kt = false;
                MessageBox.Show("Nhân viên " + txtManv.Text + " đã tăng ca ngày " + date_ngaycong.Text + " rồi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return(kt);
        }
Ejemplo n.º 4
0
        // kiem tra toan bo truoc khi them
        #region kiem tra toan bo truoc khi them
        private bool kiemtra_update()
        {
            bool kt = true;

            if (txtManv.Text == "" || date_ngaycong.Text == "" || txtGiora.Text == "" || txtGiovao.Text == "" || txtphutra.Text == "" || txtPhutvao.Text == "")
            {
                kt = false;
                MessageBox.Show("Hãy nhập đầy đủ thông tin", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (date_ngaycong.DateTime > DateTime.Now)
            {
                kt = false;
                MessageBox.Show("Ngày công của nhân viên phải nhỏ hơn ngày hiện tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!BUS.BUS_Nhanvien.kiemtra_ngaycong_ngayvaolam(txtManv.Text, date_ngaycong.DateTime))
            {
                kt = false;
                MessageBox.Show("Ngày công của nhân viên phải lớn hơn ngày vào làm", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!BUS_Bangcong.kiemtra_ngaycong_trung_sua(txtManv.Text, date_ngaycong.DateTime, b.Ngay.ToString()))
            {
                kt = false;
                MessageBox.Show("Ngày công " + date_ngaycong.Text + " của nhân viên có mã " + txtManv.Text + " đã tồn tại ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!kiemtra_thoigian())
            {
                kt = false;
                MessageBox.Show("Thời gian giờ/ phút không hợp lệ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(kt);
        }
Ejemplo n.º 5
0
        public bool kt_Luu()
        {
            bool kt = true;

            if (date_ngaycong.Text == "" || txtSogio.Text == "")
            {
                kt = false;
                MessageBox.Show("Hãy điền đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            // kiem tra thay doi ngay cua thang
            else if (date_ngaycong.DateTime.Day.ToString() != tc.Ngay || date_ngaycong.DateTime.Month.ToString() != tc.Thang ||
                     date_ngaycong.DateTime.Year.ToString() != tc.Nam)
            {
                if (!BUS_Tangca.kt_tangca_trung(txtManv.Text, date_ngaycong.DateTime))
                {
                    kt = false;
                    MessageBox.Show("Nhân viên " + txtManv.Text + " đã tăng ca ngày " + date_ngaycong.Text + " rồi",
                                    "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else if (BUS_Bangcong.kiemtra_ngaycong_trung(txtManv.Text, date_ngaycong.DateTime))
            {
                kt = false;
                MessageBox.Show("Ngày " + date_ngaycong.Text + " nhân viên có mã " + txtManv.Text + " không đi làm, nên không được tăng ca", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (int.Parse(txtSogio.Text.ToString()) < 0 || int.Parse(txtSogio.Text.ToString()) > 12)
            {
                kt = false;
                MessageBox.Show("Số giờ quá giới hạn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return(kt);
        }
Ejemplo n.º 6
0
 private void _xoa()
 {
     if (gridBangcong.MainView.RowCount > 0)
     {
         if (MessageBox.Show("Bạn có chắc xoá toàn bộ ngày công của nhân viên có mã là " + lbManv.Text + " trong tháng " + cmbThang.Text + "/" + cmbNam.Text + " hay không", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
         {
             if (BUS_Bangcong._xoa(lbManv.Text, cmbThang.Text, cmbNam.Text) == "true")
             {
                 MessageBox.Show("Xoá thành công toàn bộ ngày công của nhân viên " + lbManv.Text + " trong tháng " + cmbThang.Text + "/" + cmbNam.Text + "", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 _xem();
             }
             else
             {
                 MessageBox.Show("Lỗi từ hệ thống, hãy liên hệ với bộ phận kỹ thuật", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         MessageBox.Show("Không có dữ liệu để xoá", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Stop);
     }
 }
Ejemplo n.º 7
0
 private void date_ngaycong_EditValueChanged(object sender, EventArgs e)
 {
     if (date_ngaycong.Text == "")
     {
         date_ngaycong.ForeColor = Color.Red;
     }
     else if (date_ngaycong.DateTime > DateTime.Now)
     {
         date_ngaycong.ForeColor = Color.Red;
     }
     else if (!BUS.BUS_Nhanvien.kiemtra_ngaycong_ngayvaolam(txtManv.Text, date_ngaycong.DateTime))
     {
         date_ngaycong.ForeColor = Color.Red;
     }
     else if (!BUS_Bangcong.kiemtra_ngaycong_trung(txtManv.Text, date_ngaycong.DateTime))
     {
         date_ngaycong.ForeColor = Color.Red;
     }
     else
     {
         date_ngaycong.ForeColor = Color.DodgerBlue;
     }
 }