Ejemplo n.º 1
0
        private void treePhongBan_AfterSelect(object sender, TreeViewEventArgs e)
        {
            #region mỗi lần chọn node thì lấy ID node hiện tại và tất cả node con

            m_listIDPhongBan.Clear();
            if (e.Node.FirstNode != null)
            {
                XL.GetIDNodeAndChildNode(e.Node, ref m_listIDPhongBan);
            }
            else
            {
                var temp = ((cPhongBan)e.Node.Tag);
                if (temp.ChoPhep)
                {
                    m_listIDPhongBan.Add(temp.ID);
                }
            }
            e.Node.Expand();

            #endregion

            #region kiểm tra kết nối csdl , nếu mất kết nối thì đóng

            if (SqlDataAccessHelper.TestConnection(SqlDataAccessHelper.ConnectionString) == false)
            {
                ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 4000);
                Close();
                return;
            }

            #endregion


            XL.KhoiTaoDSNV_ChamCong(m_DSNV, m_listIDPhongBan, this.m_DSPhg);

            XL.TaoTableDSNV(m_DSNV, m_Bang_DSNV);

            #region tạo datasourcr cho autocomplete

            var Source = new AutoCompleteStringCollection();
            Source.AddRange((from nv in m_DSNV select nv.TenNV.ToUpperInvariant()).ToArray());
            tbSearch.AutoCompleteSource       = AutoCompleteSource.CustomSource;
            tbSearch.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
            tbSearch.AutoCompleteCustomSource = Source;

            #endregion

            var dataView = dgrdDSNVTrgPhg.DataSource as DataView;
            if (dataView != null)
            {
                dataView.RowFilter = string.Empty;
            }

            m_Bang_TongHopXemCong.Rows.Clear();
            m_Bang_GioKDQD.Rows.Clear();
            m_Bang_GioThieuCheck.Rows.Clear();
            m_Bang_ThK_TreSom.Rows.Clear();

            checkAll_GridDSNV.Checked = false;
        }
Ejemplo n.º 2
0
        private void treePhongBan_AfterSelect(object sender, TreeViewEventArgs e)
        {
            #region kiểm tra kết nối csdl , nếu mất kết nối thì đóng

            if (SqlDataAccessHelper.TestConnection(SqlDataAccessHelper.ConnectionString) == false)
            {
                ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 4000);
                Close();
                return;
            }

            #endregion
            // if topnode thì lấy tất cả nhân viên, nếu  1 node khác thì lấy theo ID
            DataTable table;
            if (e.Node == treePhongBan.TopNode)
            {
                table = XL.LayDSNVChuaSX(null);
            }
            else
            {
                #region mỗi lần chọn node thì lấy ID node hiện tại và tất cả node con
                m_listIDPhongBan.Clear();
                if (e.Node.FirstNode != null)
                {
                    XL.GetIDNodeAndChildNode(e.Node, ref m_listIDPhongBan);
                }
                else
                {
                    var temp = ((cPhongBan)e.Node.Tag);
                    if (temp.ChoPhep)
                    {
                        m_listIDPhongBan.Add(temp.ID);
                    }
                }
                e.Node.Expand();
                #endregion
                table = XL.LayDSNV(null, m_listIDPhongBan.ToArray());
            }
            table.Columns.Add("check", typeof(bool));             // thêm cột check để chọn nv
            m_Bang_DSNV = table.Copy();
            var dataView = new DataView(m_Bang_DSNV);
            dgrdDSNVTrgPhg.DataSource = dataView;
            dataView.RowFilter        = string.Empty;

            #region tạo datasource cho autocomplete

            var Source = new AutoCompleteStringCollection();
            Source.AddRange((from DataRow row in m_Bang_DSNV.Rows select row["UserFullName"].ToString().ToUpperInvariant()).ToArray());
            tbSearch.AutoCompleteSource       = AutoCompleteSource.CustomSource;
            tbSearch.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
            tbSearch.AutoCompleteCustomSource = Source;

            #endregion


            checkAll_GridDSNV.Checked = false;
        }
        private void treePhongBan_AfterSelect(object sender, TreeViewEventArgs e)
        {
            #region lấy id ds phòng ban và phòng ban con được chọn

            m_listIDPhongBan.Clear();
            if (e.Node.FirstNode != null)
            {
                XL.GetIDNodeAndChildNode(e.Node, ref m_listIDPhongBan);
            }
            else
            {
                var temp = ((cPhongBan)e.Node.Tag);
                if (temp.ChoPhep)
                {
                    m_listIDPhongBan.Add(temp.ID);
                }
            }
            e.Node.Expand();

            #endregion

            #region kiểm tra kết nối csdl, mất kết nối thì thoát

            if (SqlDataAccessHelper.TestConnection(SqlDataAccessHelper.ConnectionString) == false)
            {
                ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 2000);
                Close();
                return;
            }

            #endregion

            XL.KhoiTaoDSNV_ChamCong(m_DSNV, m_listIDPhongBan, m_DSPhg);

            XL.TaoTableDSNV(m_DSNV, m_Bang_DSNV);

            #region set datasource for autocomplete

            var Source = new AutoCompleteStringCollection();
            Source.AddRange((from nv in m_DSNV select nv.TenNV.ToUpperInvariant()).ToArray());
            tbSearch.AutoCompleteSource       = AutoCompleteSource.CustomSource;
            tbSearch.AutoCompleteMode         = AutoCompleteMode.Suggest;
            tbSearch.AutoCompleteCustomSource = Source;

            #endregion

            var dataView = dgrdDSNVTrgPhg.DataSource as DataView;
            if (dataView != null)
            {
                dataView.RowFilter = string.Empty;
            }

            checkAll_GridDSNV.Checked = false;
        }
        private void treePhongBan_AfterSelect(object sender, TreeViewEventArgs e)
        {
            #region kiểm tra kết nối csdl , nếu mất kết nối thì đóng

            if (SqlDataAccessHelper.TestConnection(SqlDataAccessHelper.ConnectionString) == false)
            {
                ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 3000);
                Close();
                return;
            }

            #endregion

            #region mỗi lần chọn node thì lấy ID node hiện tại và tất cả node con

            m_listIDPhongBan.Clear();
            if (e.Node.FirstNode != null)
            {
                XL.GetIDNodeAndChildNode(e.Node, ref m_listIDPhongBan);
            }
            else
            {
                var temp = ((cPhongBan)e.Node.Tag);
                if (temp.ChoPhep)
                {
                    m_listIDPhongBan.Add(temp.ID);
                }
            }
            e.Node.Expand();

            #endregion

            XL.KhoiTaoDSNV_ChamCong(m_DSNV, m_listIDPhongBan, m_DSPhg);

            XL.TaoTableDSNV(m_DSNV, m_Bang_DSNV);

            var dataView = dgrdDSNVTrgPhg.DataSource as DataView;
            if (dataView != null)
            {
                dataView.RowFilter = string.Empty;
            }

            checkAll_GridDSNV.Checked = false;
        }
Ejemplo n.º 5
0
        // hàm xử lý -----------------------------------------------------------------------------
        private void treePhongBan_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try              //general try catch
            {
                #region get ID node hiện tại và các node con
                m_listIDPhongBan.Clear();
                if (e.Node.FirstNode != null)
                {
                    XL.GetIDNodeAndChildNode(e.Node, ref m_listIDPhongBan);
                }
                else
                {
                    var temp = ((cPhongBan)e.Node.Tag);
                    if (temp.ChoPhep)
                    {
                        m_listIDPhongBan.Add(temp.ID);
                    }
                }
                e.Node.Expand();
                #endregion

                #region mất kết nối csdl thì thoát form
                if (SqlDataAccessHelper.TestConnection(SqlDataAccessHelper.ConnectionString) == false)
                {
                    ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 4000);
                    Close();
                    return;
                }
                #endregion

                #region lấy ngày BD và kết thúc, ngày điểm danh và update lại Ngày BD = 1 ngày trước 31/08 12:00 AM, ngày KT là 1 ngày sau ngay 1 23:59:59
                dtpNgay.Update();
                DateTime ngaydiemdanh = dtpNgay.Value.Date;
                DateTime ngayBD_bef2D = ngaydiemdanh.AddDays(-2d);
                DateTime ngayKT_Aft2D = ngaydiemdanh.AddDays(2d);
                #endregion

                // lấy dsnv tất cả nv thuộc các phòng ban được chọn
                XL.KhoiTaoDSNV_ChamCong(m_DSNV, m_listIDPhongBan, m_DSPhg);

                //3. lấy dữ liệu chấm công của các nhân viên
                //[CHÚ Ý] ngày bắt đầu và kết thúc đã cộng trừ thêm 1 ngày trước sau ở bở trên

                int SoNVDangLamViec, SoNVDaRaVe, SoNVKoHienDien, SoNVVang_LyDo, SoNVNghi;
                try {
                    //logic điểm danh ngày được input, truyền thêm datetime.Now để xác định nếu trong vòng 24h kể từ hiện tại trở về trước, nếu vào ko ra thì vẫn còn làm việc
                    // nếu vào ko ra trên 24h nghĩa là ngày đó quên chấm công
                    XL.DiemDanh_v08(m_DSNV, ngayBD_bef2D, ngayKT_Aft2D, ngaydiemdanh, DateTime.Now);
                    m_BangCTDiemDanh.Rows.Clear();
                    XL.TaoTableDiemDanh(m_DSNV, m_BangCTDiemDanh, ngaydiemdanh, out SoNVDangLamViec, out SoNVDaRaVe, out SoNVKoHienDien, out SoNVVang_LyDo, out SoNVNghi);
                } catch (Exception exception) {
                    lg.Error(string.Format("[{0}]_[{1}]\n", this.Name, System.Reflection.MethodBase.GetCurrentMethod().Name), exception);
                    MessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi);
                    GC.Collect();
                    return;
                }

                //4. xử lý dữ liệu để đưa lên lưới tổng hợp
                tbTongSoNV.Text        = m_DSNV.Count.ToString();
                tbSoNVDangLamViec.Text = SoNVDangLamViec.ToString();
                tbSoNVDaRaVe.Text      = SoNVDaRaVe.ToString();
                tbSoNVVang.Text        = SoNVKoHienDien.ToString();
                tbVangLyDo.Text        = SoNVVang_LyDo.ToString();
                tbVangNghi.Text        = SoNVNghi.ToString();
                dgrdTongHop.DataSource = m_BangCTDiemDanh;
            } catch (Exception ex)              //general try catch
            {
                lg.Error(string.Format("[{0}]_[{1}]\n", this.Name, System.Reflection.MethodBase.GetCurrentMethod().Name), ex);
                MessageBox.Show(Resources.Text_CoLoi, Resources.Caption_Loi);
            }
        }