Ejemplo n.º 1
0
        private void bt_Tim_Click(object sender, EventArgs e)
        {
            //Clear GirdView
            if (grid_Luong.Rows.Count > 1)
            {
                int k = grid_Luong.Rows.Count;
                for (int i = 0; i < k; i++)
                {
                    grid_Luong.Rows.RemoveAt(0);
                    i = 0;
                    k--;
                }
            }
            //Tim nhan vien ung voi ten nhap vao
            NhanVienXL NhanVien      = new NhanVienXL();
            DataTable  DT_DSNhanVien = NhanVien.TraCuuNhanVien("", txt_Ten.Text);
            //Lay ve thang, nam
            int Thang = Convert.ToInt16(cb_Thang.Text);
            int Nam   = Convert.ToInt16(cb_Nam.Text);

            //
            for (int i = 0; i < DT_DSNhanVien.Rows.Count; i++)
            {
                //Lay ra ma nhan vien
                string MaNV = DT_DSNhanVien.Rows[i][0].ToString();
                //Lay ra bang cham cong ung voi nhan vien nay
                ChamCongXL ChamCong = new ChamCongXL();
                DataTable  dt       = ChamCong.LayRaChamCongThanhVien(MaNV, Thang, Nam);
                if (dt.Rows.Count > 0)
                {
                    //Them thong tin vao grid view
                    DataGridViewRow  row = new DataGridViewRow();
                    DataGridViewCell col = new DataGridViewTextBoxCell();
                    //Cot Ten Nhan Vien
                    col.Value = DT_DSNhanVien.Rows[i][1].ToString();
                    row.Cells.Add(col);
                    //Cot So Ngay Nghir
                    col       = new DataGridViewTextBoxCell();
                    col.Value = dt.Rows[0][4].ToString();
                    row.Cells.Add(col);
                    //Cot So Ngay Di Tre
                    col       = new DataGridViewTextBoxCell();
                    col.Value = dt.Rows[0][5].ToString();
                    row.Cells.Add(col);
                    //Cot luong co ban
                    //Lay ra ma loai nhan vien ung voi ma nhan vien
                    string MaLoaiNV = NhanVien.TimMaLoaiNV(MaNV);
                    //Lay ra Luong co ban
                    LoaiNhanVienXL LoaiNV   = new LoaiNhanVienXL();
                    DataTable      dt_Luong = LoaiNV.LayThongTinLoaiNV(MaLoaiNV);
                    //
                    col       = new DataGridViewTextBoxCell();
                    col.Value = dt_Luong.Rows[0][2].ToString();
                    row.Cells.Add(col);
                    //Cot tong luong
                    //Lay ra tham so
                    ThamSoXL  ThamSo    = new ThamSoXL();
                    DataTable dt_ThamSo = ThamSo.LayThamSo();
                    //Tinh luong
                    double TongLuong = Convert.ToDouble(dt_Luong.Rows[0][2].ToString()) - Convert.ToDouble(dt.Rows[0][4].ToString()) * Convert.ToDouble(dt_ThamSo.Rows[0][4].ToString()) - Convert.ToDouble(dt.Rows[0][5].ToString()) * Convert.ToDouble(dt_ThamSo.Rows[0][5].ToString());
                    col       = new DataGridViewTextBoxCell();
                    col.Value = TongLuong.ToString();
                    row.Cells.Add(col);

                    grid_Luong.Rows.Add(row);
                }
            }
        }
Ejemplo n.º 2
0
        private void bt_Tim_Click(object sender, EventArgs e)
        {
            NhanVienXL NhanVien = new NhanVienXL();
            DataTable  DT_DSNhanVien;

            if (cb_LoaiNV.Enabled == true)
            {
                DT_DSNhanVien = NhanVien.TraCuuNhanVien(cb_LoaiNV.SelectedValue.ToString(), txt_TheoTen.Text);
            }
            else
            {
                DT_DSNhanVien = NhanVien.TraCuuNhanVien("", txt_TheoTen.Text);
            }
            //DataTable DT_DSNhanVien = NhanVien.TraCuuNhanVien("", txt_TheoTen.Text);
            //Tim theo tuoi
            if (txt_TuoiTu.Text.CompareTo("") != 0 && txt_TuoiDen.Text.CompareTo("") != 0)
            {
                if (Convert.ToInt16(txt_TuoiTu.Text) > Convert.ToInt16(txt_TuoiDen.Text))
                {
                    MessageBox.Show("Giá trị tuổi không hợp lệ, Hệ thông sẽ loại bỏ giá trị tìm kiếm theo tuổi.");
                }
                else
                {
                    //Tinh tuoi => nam
                    String ToDay  = DateTime.Now.ToString();
                    int    NamTu  = TachNam(ToDay) - Convert.ToInt16(txt_TuoiTu.Text);
                    int    NamDen = TachNam(ToDay) - Convert.ToInt16(txt_TuoiDen.Text);
                    MessageBox.Show(NamTu.ToString() + ":" + NamDen.ToString());
                    //Xoa cac row co do tuoi khong nam trong khoang nay
                    int k = DT_DSNhanVien.Rows.Count;
                    for (int i = 0; i < k; i++)
                    {
                        if (TachNam(DT_DSNhanVien.Rows[i][2].ToString()) > NamTu || TachNam(DT_DSNhanVien.Rows[i][2].ToString()) < NamDen)
                        {
                            //MessageBox.Show(DT_DSNhanVien.Rows[i][2].ToString());
                            DT_DSNhanVien.Rows.RemoveAt(i);
                            i = 0;
                            k--;
                        }
                    }
                }
            }
            //Clear GirdView
            if (grid_KetQua.Rows.Count > 1)
            {
                int k = grid_KetQua.Rows.Count;
                for (int i = 0; i < k; i++)
                {
                    grid_KetQua.Rows.RemoveAt(0);
                    i = 0;
                    k--;
                }
            }
            for (int i = 0; i < DT_DSNhanVien.Rows.Count; i++)
            {
                DataGridViewRow row = new DataGridViewRow();
                for (int j = 0; j < DT_DSNhanVien.Columns.Count; j++)
                {
                    DataGridViewCell col = new DataGridViewTextBoxCell();
                    col.Value = DT_DSNhanVien.Rows[i][j].ToString();
                    row.Cells.Add(col);
                }
                grid_KetQua.Rows.Add(row);
            }
        }