Exemplo n.º 1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            //hiển thị form và nhận kết quả trả về
            frmNhapThongTinPhong frm = new frmNhapThongTinPhong();

            frm.m_CurrentDataRow = (DataRow)treePhongBan.SelectedNode.Tag;
            frm.m_Mode           = ModeType.Them;
            frm.ShowDialog();
            if (frm.m_Mode == ModeType.Cancel)
            {
                return;
            }

            //sử dụng kết quả trả về thêm vào CSDL
            if (SqlDataAccessHelper.TestConnection(SqlDataAccessHelper.ConnectionString) == false)
            {
                ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 3000);
                return;
            }
            #region test
            ACMessageBox.Show(string.Format("{0};RID {1};LID {2};VT {3};E {4}",
                                            frm.m_TenPhong,
                                            (int)frm.m_ParentDataRow["RelationID"],
                                            (int)frm.m_ParentDataRow["LevelID"] + 1,
                                            frm.m_VitriPhong, frm.m_Enable), "", 5000);
            loadTreePhgBan(treePhongBan);
            //return;
            #endregion

            if (SqlDataAccessHelper.ExecSPNoneQuery(SPName6.RelationDept_ThemPhongV6.ToString(),
                                                    new SqlParameter("@Description", frm.m_TenPhong),
                                                    new SqlParameter("@RelationID", (int)frm.m_ParentDataRow["ID"]),
                                                    new SqlParameter("@LevelID", (int)frm.m_ParentDataRow["LevelID"] + 1),//+1 vì là con của phòng trực thuộc
                                                    new SqlParameter("@ViTri", frm.m_VitriPhong),
                                                    new SqlParameter("@Enable", frm.m_Enable)) == 0)
            {
                ACMessageBox.Show(Resources.Text_CoLoi, Resources.Caption_Loi, 2000);
                return;
            }
            else             //thêm thành công load lại tree
            {
                loadTreePhgBan(treePhongBan);
                treePhongBan.ExpandAll();
            }
        }
        private void frm_32_XemLichSu_Load(object sender, EventArgs e)
        {
            if (SqlDataAccessHelper.TestConnection(SqlDataAccessHelper.ConnectionString) == false)
            {
                ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 3000);
                this.Close();
                return;
            }

            var table = SqlDataAccessHelper.ExecuteQueryString("select UserID,UserAccount from NewUserAccount");

            cbTaiKhoanThucHien.ValueMember   = "UserID";
            cbTaiKhoanThucHien.DisplayMember = "UserAccount";
            cbTaiKhoanThucHien.DataSource    = table;

            dtpStartThoiDiemSua.Value = DateTime.Today;
            dtpEndddThoiDiemSua.Value = DateTime.Now;
        }
        private void fmXemCong4_Load(object sender, EventArgs 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

            /* 1. load tree phòng ( datasource cho checkComboEdit chọn nv do hàm treeAfterselect tạo
             * 2.
             * 3. set tháng khi load lần đầu
             */
            XL.loadTreePhgBan(treePhongBan);
            treePhongBan.AfterSelect += treePhongBan_AfterSelect;
        }
Exemplo n.º 4
0
 private void XuLyXoaLichTrinh(List <int> ListIDLichTrinh)
 {
     if (SqlDataAccessHelper.TestConnection(SqlDataAccessHelper.ConnectionString) == false)
     {
         ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 3000);
         return;
     }
     // thực hiện xóa lịch trình => LOGIC xóa lịch trình cũng đồng nghĩa xóa luôn các ca làm việc theo lịch trình này.
     foreach (int id in ListIDLichTrinh)
     {
         int kq = SqlDataAccessHelper.ExecSPNoneQuery(SPName6.Other_XoaLichTrinhV6.ToString(), new SqlParameter("@SchID", id));
         if (kq == 0)
         {
             ACMessageBox.Show(Resources.Text_CoLoi, Resources.Caption_Loi, 2000);
             return;
         }
     }
 }
        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;
        }
        private void btnXem_Click(object sender, EventArgs e)
        {
            if (XL2.KiemtraKetnoiCSDL() == false)
            {
                return;
            }
            //1. lấy dữ liệu từ form

            #region lấy ngày BD và kết thúc nếu quá 62 ngày thì báo

            dtpNgayBD.Update();
            dtpNgayKT.Update();
            var ngayBD = dtpNgayBD.Value.Date;
            var ngayKT = dtpNgayKT.Value.Date;
            #endregion


            BindingContext[dgrdDSNVTrgPhg.DataSource].EndCurrentEdit();
            #region             //2. lấy danh sách nhân viên check, nếu chưa có nv nào check thì thông báo

            var listNV = (from DataGridViewRow dataGridViewRow in dgrdDSNVTrgPhg.Rows
                          let rowView = dataGridViewRow.DataBoundItem as DataRowView
                                        where (rowView["check"] != DBNull.Value && (bool)rowView["check"])
                                        select(cUserInfo) rowView["cUserInfo"])
                         .ToList();

            if (listNV.Count == 0)
            {
                ACMessageBox.Show(Resources.Text_ChuaChonNV, Resources.Caption_ThongBao, 2000);                 //
                GC.Collect();
                return;
            }

            #endregion
            XL.LayBang_PH_Them(listNV, ngayBD, ngayKT, ref m_Bang_PH_Them);
            XL.LayBang_PH_Xoaa(listNV, ngayBD, ngayKT, ref m_Bang_PH_Xoaa);
            XL.LayBang_PH_GioGoc(listNV, ngayBD, ngayKT, ref m_Bang_PH_GioGoc);
            XL.LayBang_GioDaXN(listNV, ngayBD, ngayKT, ref m_Bang_GioDaXN);
            dgrdPH_Them.DataSource   = m_Bang_PH_Them;
            dgrdPH_Xoaa.DataSource   = m_Bang_PH_Xoaa;
            dgrdPH_GioGoc.DataSource = m_Bang_PH_GioGoc;
            dgrdGioDaXN.DataSource   = m_Bang_GioDaXN;
        }
        private void frm_ChamCongTay_Load(object sender, EventArgs e)
        {
            #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

            dtpBDLam.ValueChanged += dtp_ValueChanged;
            dtpKTLam.ValueChanged += dtp_ValueChanged;

            #region             //2. lấy dữ liệu phòng ban được phép thao tác  và load treePhongBan ,
            // trường hợp ko có phòng ban nào được phép thao tác thì báo và thoát form
            XL.KhoiTaoDSPhongBan(m_DSPhg, XL2.currUserID);
            if (m_DSPhg.Count == 0)
            {
                ACMessageBox.Show(Resources.Text_ChuaCapQuyenPhongBanThaoTac, Resources.Caption_ThongBao, 5000);
                Close();
                return;
            }
            XL.loadTreePhgBan(treePhongBan, XL2.TatcaPhongban, m_DSPhg);

            #endregion

            // đăng ký sự kiện cho tree và chọn topNode
            treePhongBan.AfterSelect += treePhongBan_AfterSelect;
            treePhongBan.SelectedNode = treePhongBan.TopNode;

            #region chọn mặc định ca hành chánh cho cấp quản lý

            cCa defaultShift = XL.DSCa.Find(item => item.Duty.Onn == XL2._07h30 && item.Duty.Off == XL2._16gio && Math.Abs(item.Workingday - 1f) < 0.01f);             //tbd
            tbCa.Tag       = defaultShift;
            tbCa.Text      = defaultShift.Code;
            dtpBDLam.Value = DateTime.Today.Date.Add(defaultShift.Duty.Onn);
            dtpKTLam.Value = DateTime.Today.Date.Add(defaultShift.Duty.Off);

            #endregion
        }
Exemplo n.º 8
0
//		public static void SaveSetting(string connectionstring = null, string lastAccLogIn = null, string lastUserName = null,
//			string lastDatabase = null, string lastServerName = null,
//			DateTime? lastStartDate = null, DateTime? lastEndDate = null,
//			int? lastSanLuong = null, int? lastDonGia = null,
//			int? lastSanLuongGiaCongNoiBo = null, int? lastDonGiaGiaCongNoiBo = null,
//			int? lastSanLuongGiaCongNgoai = null, int? lastDonGiaGiaCongNgoai = null,
//			int? lastLuongToiThieu = null, int? lastBoiDuongCa3 = null,
//			string lastTenNVLapBieuChamCong = null, string lastTenNVLapBieuLuong = null, string lastTenTruongBP = null
//			) {
//			if (string.IsNullOrEmpty(connectionstring) == false) Settings.Default.ConnectionStringPath = connectionstring;
//			if (string.IsNullOrEmpty(lastAccLogIn) == false) Settings.Default.LastAccLogIn = lastAccLogIn;
//			if (string.IsNullOrEmpty(lastUserName) == false) Settings.Default.LastUsername = lastUserName;
//			if (string.IsNullOrEmpty(lastDatabase) == false) Settings.Default.LastDatabase = lastDatabase;
//			if (string.IsNullOrEmpty(lastServerName) == false) Settings.Default.LastServerName = lastServerName;
//			if (lastStartDate != null) Settings.Default.LastStartDate = new DateTime(lastStartDate.Value.Year, lastStartDate.Value.Month, lastStartDate.Value.Day);
//			if (lastEndDate != null) Settings.Default.LastEndDate = new DateTime(lastEndDate.Value.Year, lastEndDate.Value.Month, lastEndDate.Value.Day);
//			if (lastSanLuong != null) Settings.Default.LastSanLuong = (int)lastSanLuong;
//			if (lastDonGia != null) Settings.Default.LastDonGia = (int)lastDonGia;
//			if (lastSanLuongGiaCongNoiBo != null) Settings.Default.LastSanluongGiaCongNoibo = (int)lastSanLuongGiaCongNoiBo;
//			if (lastDonGiaGiaCongNoiBo != null) Settings.Default.LastDongiaGiacongNoibo = (int)lastDonGiaGiaCongNoiBo;
//			if (lastSanLuongGiaCongNgoai != null) Settings.Default.LastSanluongGiacongNgoai = (int)lastSanLuongGiaCongNgoai;
//			if (lastDonGiaGiaCongNgoai != null) Settings.Default.LastDongiaGiacongNgoai = (int)lastDonGiaGiaCongNgoai;
//			if (lastLuongToiThieu != null) Settings.Default.LastLuongToiThieu = (int)lastLuongToiThieu;
//			if (lastBoiDuongCa3 != null) Settings.Default.LastBoiDuongCa3 = (int)lastBoiDuongCa3;
//			if (lastTenNVLapBieuChamCong != null) Settings.Default.LastTenNVLapBieuChamCong = lastTenNVLapBieuChamCong;
//			if (lastTenNVLapBieuLuong != null) Settings.Default.LastTenNVLapBieuLuong = lastTenNVLapBieuLuong;
//			if (lastTenTruongBP != null) Settings.Default.LastTenTruongBP = lastTenTruongBP;
//			//if ( != null) Settings.Default. = ();
//			Settings.Default.Save();
//		}

//		#region xử lý load treeView dsnv ở các form

//		#region cách làm không store procedure

//		public static TreeView loadTreePhgBan(TreeView tvDSPhongBan, List<cPhongBan> TatcaPhongban, List<cPhongBan> dsPhongduocThaotac) {
//			tvDSPhongBan.Nodes.Clear();

//			//load tất cả phòng ban vào tree
//			foreach (cPhongBan phong in TatcaPhongban.FindAll(item => item.idParent == 0).OrderBy(item => item.ViTri)) {
//				TreeNode parentNode = new TreeNode { Text = phong.Ten, Tag = phong };
//				tvDSPhongBan.Nodes.Add(parentNode);
//				loadTreeSubNode(ref parentNode, phong.ID, TatcaPhongban);
//			}

//			// lập ds các node chứa các phòng ban được thao tác
//			TreeNode root = tvDSPhongBan.TopNode;

//			List<TreeNode> dsNodeThaotac = new List<TreeNode>();
//			GetListNode_Thaotac(root, dsPhongduocThaotac, ref dsNodeThaotac); // lấy tất cả các node chứa phòng ban được thao tác

//			// thêm vào danh sách các node không được thao tác nhưng nằm trên đường dẫn đến node được thao tác
//			for (int i = 0; i < dsNodeThaotac.Count; i++) {
//				TreeNode node = dsNodeThaotac[i];
//				GetNodesInPath(node.Parent, dsNodeThaotac);
//			}

//			// loại bỏ các node ko được thao tác và không thuộc đường dẫn đến node thao tác
//			RemoveNodeNotInPath(ref root, dsNodeThaotac);

//			return tvDSPhongBan;
//		}

//		private static bool RemoveNodeNotInPath(ref TreeNode root, List<TreeNode> nodesInPath) {
//			if (root == null)
//				return false;

//			if (root.Nodes.Count > 0) {
//				int i = 0;
//				// sử dụng kiểu này vì khi xoá 1 node thì danh sách node bị thay đổi --> foreach ko cho phép
//				// sử dụng for i thì khi xoá node, node sau dồn lên, index i phải giữ nguyên ko được ++
//				while (i < root.Nodes.Count) {
//					TreeNode node = root.Nodes[i];
//					bool kq = RemoveNodeNotInPath(ref node, nodesInPath);
//					if (kq == false) i++; // điều kiện tăng i là nếu xoá được node, ngược lại hết đường thì dừng,
//				}
//			}

//			bool found1 = false;
//			for (int i = 0; i < nodesInPath.Count; i++) {
//				TreeNode node = nodesInPath[i];
//				if (root != node) continue;
//				else {
//					found1 = true;
//					break;
//				}
//			}
//			if (found1 == false) {
//				root.Remove();
//				return true;
//			}
//			return false;

//		}

//		private static void GetNodesInPath(TreeNode root, List<TreeNode> nodes) {
//			if (root == null) return;

//			// nếu curr đã nằm trong ds node được thao tác thì trùng ko add thêm
//			bool found = false;
//			for (int i = nodes.Count - 1; i >= 0; i--) {
//				if (nodes[i] != root) continue;
//				found = true; //nodes[i] == root ==> đã tồn tại trong danh sách -> break vòng lặp, ko add mà tiếp tục
//				break;
//			}
//			if (found == false) nodes.Add(root); // ko tìm thấy --> đó là node mới--> add node mới
//			GetNodesInPath(root.Parent, nodes); // tiếp tục kiểm tra node cha của node hiện tại
//		}

//		private static void GetListNode_Thaotac(TreeNode root, List<cPhongBan> dsPhongduocThaotac, ref List<TreeNode> nodes) {
//			if (root == null) return;

//			// nếu currNode được phép thao tác thì add current node
//			for (int i = 0; i < dsPhongduocThaotac.Count; i++) {
//				cPhongBan phongDuocThaotac = dsPhongduocThaotac[i];
//				cPhongBan phongDangXet = (cPhongBan)root.Tag;
//				if (phongDangXet.ID == phongDuocThaotac.ID) {
//					phongDangXet.ChoPhep = true;
//					nodes.Add(root);
//				}
//			}

//			if (root.Nodes.Count > 0) {
//				// nếu có node con thì add các node con thoả điều kiện
//				for (int i = 0; i < root.Nodes.Count; i++) {
//					TreeNode node = root.Nodes[i];
//					GetListNode_Thaotac(node, dsPhongduocThaotac, ref nodes);
//				}
//			}
//			// ko có node con thì dừng

//		}

//		public static void loadTreeSubNode(ref TreeNode ParentNode, int idPhongBanTrucThuoc, List<cPhongBan> dsphongban) {
//			List<cPhongBan> childs = dsphongban.Where(item => item.idParent == idPhongBanTrucThuoc).OrderBy(item => item.ViTri).ToList();
//			foreach (cPhongBan phong in childs) {
//				TreeNode child = new TreeNode { Text = phong.Ten, Tag = phong, ToolTipText = phong.Ten };
//				ParentNode.Nodes.Add(child);
//				loadTreeSubNode(ref child, phong.ID, dsphongban);
//			}
//		}

//		public static void GetIDNodeAndChildNode(TreeNode root, ref List<int> listID) {
//			if (root == null) return;

//			cPhongBan phong = (cPhongBan)root.Tag;
//			if (phong != null && phong.ChoPhep) listID.Add(phong.ID);

//			if (root.Nodes.Count > 0) {
//				foreach (TreeNode node in root.Nodes) {
//					GetIDNodeAndChildNode(node, ref listID);
//				}
//			}
//			// xuốn đến đây tương đương root.Nodes.Count== 0; return
//		}

//		#endregion

//		#region cách làm có store procedure
//		public static TreeView loadTreePhgBan(TreeView tvDSPhongBan) {
//			tvDSPhongBan.Nodes.Clear();
//			DataTable tableDSPhong = SqlDataAccessHelper.ExecSPQuery(SPName.RelationDept_DocTatCaPhongBan.ToString());
//			DataTable tableDSPhongThacTac = SqlDataAccessHelper.ExecSPQuery(SPName.RelationDept_DocDSPhongDuocThaoTac.ToString(),
//				new SqlParameter("@UserID", XL2.currUserID));

//			var rowsPhong = (from DataRow row in tableDSPhong.Rows select row).OrderBy(s => (int)s["ViTri"]);
//			var relationID_0 = rowsPhong.Where(o => (int)o["RelationID"] == 0).ToList().OrderBy(s => (int)s["ViTri"]);
//			var rowsPhongThaoTac = (from DataRow row in tableDSPhongThacTac.Rows select row).OrderBy(s => (int)s["ViTri"]);

//			foreach (var dataRowView in relationID_0) {
//				TreeNode parentNode = new TreeNode { Text = dataRowView["Description"].ToString(), Tag = dataRowView };
//				tvDSPhongBan.Nodes.Add(parentNode);
//				loadTreeSubNode(ref parentNode, (int)dataRowView["ID"], rowsPhong/*TatcaPhongban*/);
//			}

//			// lập ds các node chứa các phòng ban được thao tác
//			TreeNode root = TopNode(tvDSPhongBan.TopNode);
//			List<TreeNode> dsNodeThaotac = new List<TreeNode>();
//			GetListNode_Thaotac(root, rowsPhongThaoTac.ToList(), ref dsNodeThaotac);// lấy tất cả các node chứa phòng ban được thao tác
//			// loại bỏ các node ko được thao tác và không thuộc đường dẫn đến node thao tác
//			RemoveNodeNotInPath(ref root, dsNodeThaotac);


//			return tvDSPhongBan;
//		}



//		public static void loadTreeSubNode(ref TreeNode ParentNode, int idPhongBanTrucThuoc, IOrderedEnumerable<DataRow> dsphongban /*List<cPhongBan> dsphongban*/) {
//			IOrderedEnumerable<DataRow> childs = dsphongban.Where(item => (int)item["RelationID"] == idPhongBanTrucThuoc).ToList().OrderBy(item => (int)item["ViTri"]);
//			foreach (DataRow phong in childs) {
//				TreeNode child = new TreeNode { Text = phong["Description"].ToString(), Tag = phong };
//				ParentNode.Nodes.Add(child);
//				loadTreeSubNode(ref child, (int)phong["ID"], dsphongban);
//			}
//		}

//		private static void GetListNode_Thaotac(TreeNode root, List<DataRow> dsPhongduocThaotac, ref List<TreeNode> nodes) {
//			if (root == null) return;

//			// nếu currNode được phép thao tác thì add current node
//			for (int i = 0; i < dsPhongduocThaotac.Count; i++) {
//				DataRow phongDangXet = (DataRow)root.Tag; // isyes phongDangXet = 0
//				DataRow phongDuocThaotac = dsPhongduocThaotac[i]; //isyes phongDuocThaotac =1
//				if ((int)phongDangXet["ID"] == (int)phongDuocThaotac["ID"]) {
//					phongDangXet["IsYes"] = 1;
//					nodes.Add(root);
//				}
//			}

//			if (root.Nodes.Count > 0) { // nếu có node con thì add các node con thoả điều kiện
//				for (int i = 0; i < root.Nodes.Count; i++) {
//					TreeNode node = root.Nodes[i];
//					GetListNode_Thaotac(node, dsPhongduocThaotac, ref nodes);
//				}
//			}
//			// ko có node con thì dừng

//		}

//		public static void GetIDNodeAndChildNode1(TreeNode root, ref List<int> listID) {
//			if (root == null) return;

//			DataRow phong = (DataRow)root.Tag;
//			if (phong != null && (int)phong["IsYes"] == 1) listID.Add((int)phong["ID"]);

//			if (root.Nodes.Count > 0) {
//				foreach (TreeNode node in root.Nodes) {
//					GetIDNodeAndChildNode1(node, ref listID);
//				}
//			}
//			// xuốn đến đây tương đương root.Nodes.Count== 0; return
//		}
//		#endregion

//		#endregion

//		public static void ChuanBiDSLichTrinhVaCa() {

//			XL.DSCaMoRong.Clear();
//			XL.DSCa.Clear();

//			//lấy danh sách tất cả các ca
//			var tableDSCa = DAO5.LayDSCa();
//			List<cCa> tempList = new List<cCa>();
//			foreach (DataRow row in tableDSCa.Rows) {
//				#region transfer dữ liệu từ row sang đối tượng
//				var iShiftID = (int)row["ShiftID"];
//				var sShiftCode = row["ShiftCode"].ToString();

//				TimeSpan tsOnDuty;
//				TimeSpan.TryParse(row["Onduty"].ToString(), out tsOnDuty);
//				TimeSpan tOffDuty;
//				TimeSpan.TryParse(row["Offduty"].ToString(), out tOffDuty);
//				var iDayCount = (int)row["DayCount"];
//				tOffDuty = tOffDuty.Add(new TimeSpan(iDayCount, 0, 0, 0));
//				TimeSpan timespanStartNightTime, timespanEndddNightTime;
//				if (row["StartNT"] == DBNull.Value || TimeSpan.TryParse(row["StartNT"].ToString(), out timespanStartNightTime) == false) timespanStartNightTime = XL2._22h00;//ver 4.0.0.4
//				if (row["EndNT"] == DBNull.Value || TimeSpan.TryParse(row["EndNT"].ToString(), out timespanEndddNightTime) == false) timespanEndddNightTime = XL2._06h00;//ver 4.0.0.4

//				var tOnLunch = XL2._0gio;
//				var tOffLunch = XL2._0gio;
//				if (row["OnLunch"] != DBNull.Value && row["OffLunch"] != DBNull.Value) {
//					TimeSpan.TryParse(row["OnLunch"].ToString(), out tOnLunch);
//					TimeSpan.TryParse(row["OffLunch"].ToString(), out tOffLunch);
//				}
//				var LunchMin = tOffLunch.Subtract(tOnLunch);

//				var tempWorkingTime = int.Parse(row["WorkingTime"].ToString());
//				var kyhieucc = row["KyHieuCC"].ToString();
//				var tachcadem = (row["IsSplited"] != DBNull.Value) && (bool)row["IsSplited"];
//				var idCaTruoc = (row["ShiftID1"] != DBNull.Value) ? (int)row["ShiftID1"] : -1;
//				var idCaSauuu = (row["ShiftID2"] != DBNull.Value) ? (int)row["ShiftID2"] : -1;
//				var isextend = (row["IsExtended"] != DBNull.Value) && (bool)row["IsExtended"];
//				var tempShift = new cCa {
//					ID = iShiftID,
//					Code = sShiftCode,
//					TOD_Duty = new TS { Onn = tsOnDuty, Off = tOffDuty },
//					PhutOnnInn = (int)row["OnTimeIn"],
//					PhutCutInn = (int)row["CutIn"],
//					PhutOnnOut = (int)row["OnTimeOut"],
//					PhutCutOut = (int)row["CutOut"],
//					PhutToiThieuTinhOT = (int)row["AfterOT"],
//					PhutChoTre = (int)row["LateGrace"],
//					PhutChoSom = (int)row["EarlyGrace"],
//					//LateeMin = tLateGrace,
//					//EarlyMin = tEarlyGrace,
//					Workingday = (Single)row["Workingday"],
//					WorkingTimeTS = new TimeSpan(0, tempWorkingTime, 0),
//					PhutNghiTrua = Convert.ToInt32(LunchMin.TotalMinutes),
//					TachCaDem = tachcadem,
//					idCaTruoc = idCaTruoc,
//					idCaSauuu = idCaSauuu,
//					KyHieuCC = kyhieucc,
//					MoTa = row["Description"].ToString(),
//					IsExtended = isextend,
//					TOD_NightTime = new TS { Onn = timespanStartNightTime, Off = timespanEndddNightTime }
//				};
//					//tempShift.TOD_NhanDienVao = new TS { Onn = tempShift.ThoiDiemOnnInn(), Off = tod_CutIn },
//					//tempShift.TOD_NhanDienRaa = new TS { Onn = tod_OnTimeOut, Off = tod_CutOut },
//				#endregion

//				tempList.Add(tempShift);

//			}
//			// ra khỏi vòng lặp,ca 3&1, ca 3&1A chưa cập nhật ca trước, ca sau--> cập nhật
//			#region update lại ca tách qua đêm trong ds ca
//			foreach (cCa ca in tempList.Where(item => item.TachCaDem)) {
//				var catruoc = tempList.Find(item => item.ID == ca.idCaTruoc);
//				var casauuu = tempList.Find(item => item.ID == ca.idCaSauuu);
//				ca.catruoc = catruoc;
//				ca.casauuu = casauuu;
//			}
//			#endregion

//			// có được toàn bộ ds ca --> gán cho DSCa toàn cục, DSCaMR toàn cục
//			XL.DSCa = tempList;
//			XL.DSCaMoRong = tempList.Where(item => item.IsExtended).ToList();
//			//DSCaMoRong chỉ bao gồm các ca ghép Ca1&2A, Ca1B&2, mỗi ca có caTrước caSau

//			// gán lịch trình
//			XL.DSLichTrinh.Clear();
//			// lấy danh sách lịch trình, mỗi dòng là 1 ca thuộc lịch trình => để duyệt từng lịch trình thì phải lấy dicstint
//			var tableLichTrinh = DAO5.LayDSLichTrinh();
//			var arrRows_Distinct = (from DataRow row in tableLichTrinh.Rows
//									select new { SchID = (int)(row["SchID"]), SchName = row["SchName"].ToString() })
//									.Distinct();
//			foreach (var row in arrRows_Distinct) {
//				var arrRows1 = tableLichTrinh.Select("SchID=" + row.SchID, "");
//				var lichtrinh = new cShiftSchedule {
//					SchID = row.SchID,
//					TenLichTrinh = row.SchName,
//					DSCaThu = new List<List<cCa>>(7),
//					DSCaMRThu = new List<List<cCa>>(7),
//				};
//				// mỗi lịch trình chứa 7T, mỗi T là 1 danh sách ca
//				for (int i = 0; i < 7; i++) {
//					lichtrinh.DSCaThu.Add(new List<cCa>());
//					lichtrinh.DSCaMRThu.Add(new List<cCa>());
//				}
//				foreach (var row1 in arrRows1) {
//					for (int i = 0; i < 7; i++) {
//						if (row1["T" + (i + 1)] == DBNull.Value)
//							continue;
//						var shiftid = (int)row1["T" + (i + 1)];
//						var ca = XL.DSCa.Find(o => o.ID == shiftid);
//						if (ca != null)
//							lichtrinh.DSCaThu[i].Add(ca);
//					}
//				}
//				for (int i = 0; i < 7; i++) {
//					List<cCa> dscathu = lichtrinh.DSCaThu[i];
//					foreach (var ca in from ca in XL.DSCaMoRong
//									   let catruoc = ca.catruoc
//									   let casauuu = ca.casauuu
//									   where dscathu.Exists(item => item.ID == catruoc.ID)
//											&& dscathu.Exists(item => item.ID == casauuu.ID)
//									   select ca) {
//						lichtrinh.DSCaMRThu[i].Add(ca);
//					}
//				}
//				//var ca3 = lichtrinh.DSCaThu[0].FirstOrDefault(o => o.QuaDem && Math.Abs(o.Workingday - 1f) < 0.01f);//ver 4.0.0.4 //xác định ca 3 có giờ qua đêm 21h45 hay 22 giờ để gán
//				//if (ca3 == null) lichtrinh.TGLamDemTheoQuyDinh = TGLamDemTheoQuyDinh._22h00;//ver 4.0.0.4
//				//else if (ca3.StartNT == XL2._21h45) lichtrinh.TGLamDemTheoQuyDinh = TGLamDemTheoQuyDinh._21h45;//ver 4.0.0.4
//				//else lichtrinh.TGLamDemTheoQuyDinh = TGLamDemTheoQuyDinh._22h00;//ver 4.0.0.4
//				XL.DSLichTrinh.Add(lichtrinh);
//			}


//			if (XL.DSLichTrinh.Count == 0)
//				throw new NullReferenceException("Không có ds lịch trình");

//		}

//		public static bool KiemtraDulieuCapnhatTuServer(DateTime now) {
//			//logic lấy thời gian MAX nguồn từ máy chấm công, nếu ko có dữ liệu trả về MinValue
//			// trong vòng 7 tiếng trước ko có chấm công nghĩa là chưa lấy dữ liệu từ máy chấm công về
//			const string query = @"	SELECT	MAX(CheckInOut.TimeStr) FROM CheckInOut WHERE OriginType != N'PC' and MachineNo != 21 and MachineNo != 22";
//			var kq = SqlDataAccessHelper.ExecuteQueryString(query, null, null);
//			var lastCheckTime = DateTime.MinValue;
//			if (kq.Rows.Count != 0)
//				if (kq.Rows[0][0] != DBNull.Value)
//					lastCheckTime = (DateTime)kq.Rows[0][0];

//			return (lastCheckTime != DateTime.MinValue && now - lastCheckTime <= XL2._07h00);
//		}

//		public static bool KiemtraDocFileKetnoiDL(string FileName, ref string connectionString) {
//			var kq = true;
//			// Open the file into a StreamReader
//			try {
//				StreamReader file = File.OpenText(FileName);
//				string s = file.ReadToEnd();
//				connectionString = MyUtility.giaima(s);

//				file.Close();
//			} catch (Exception ex) {
//				kq = false;
//				if (ex is FileNotFoundException || ex is DirectoryNotFoundException)
//					MessageBox.Show(string.Format(Resources.Text_KoTimThayFileX, "kết nối CSDL"), Resources.Caption_Loi);
//				else if (ex is NotSupportedException || ex is PathTooLongException)
//					MessageBox.Show(string.Format(Resources.Text_UnsupportedFile_PathTooLong, "kết nối CSDL"), Resources.Caption_Loi);
//				else if (ex is UnauthorizedAccessException)
//					MessageBox.Show(string.Format(Resources.Text_KoCoQuyenTruyCapFileX, "kết nối CSDL"), Resources.Caption_Loi);
//				else {
//					lg.Error(string.Format("[{0}]_[{1}]\n", "XL", System.Reflection.MethodBase.GetCurrentMethod().Name), ex);
//					MessageBox.Show(Resources.Text_KoTheKetNoiCSDL + ex.Message, Resources.Caption_Loi);
//				}
//			}
//			return kq;
//		}
        public static bool CheckLogIn(string tempUsername, string tempPassword, string passroot,
                                      ref string tmpConnStr, out LoaiTK loaiTK, out int currUserID, out string currUserAccount)
        {
            bool kq;

            loaiTK          = LoaiTK.None;
            currUserID      = 0;
            currUserAccount = string.Empty;
            // đọc được file thành công, kiểm tra kết nối csdl
            if (SqlDataAccessHelper.TestConnection(tmpConnStr) == false)
            {
                ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 3000);
                return(false);
            }

            // kết nối csdl thành công, kiểm tra loại tài khoản
            SqlDataAccessHelper.ConnectionString = tmpConnStr;
            if (tempUsername == "root" && tempPassword == passroot)               //log in bằng tài khoản root
            {
                currUserID      = int.MaxValue;
                currUserAccount = tempUsername;
                loaiTK          = LoaiTK.LocalRoot;
                kq = true;
            }
            else              // kiểm tra login bằng tài khoản thường
            {
                string    passEncrypt = MyUtility.Mahoa(tempPassword);
                DataTable dt          = LogIn(tempUsername, passEncrypt); //DAO5.LogIn(tempUsername, passEncrypt);
                if (dt.Rows.Count != 0)                                   // tài khoản thường ->
                {
                    currUserID      = (int)dt.Rows[0]["UserID"];
                    currUserAccount = dt.Rows[0]["UserAccount"].ToString();
                    loaiTK          = LoaiTK.User;
                    kq = true;
                }
                else
                {
                    MessageBox.Show(Resources.Text_Acc_Pass_incorrect, Resources.Caption_ThongBao, MessageBoxButtons.OK);
                    kq = false;
                }
            }
            return(kq);
        }
Exemplo n.º 9
0
        private void btnCapnhatCongnhat_Click(object sender, EventArgs e)
        {
            #region lấy ds UserEnrollNumber được chọn

            BindingContext[dgrdDSNVTrgPhg.DataSource].EndCurrentEdit();

            var checkRow = (from DataGridViewRow dataGridViewRow in dgrdDSNVTrgPhg.Rows
                            let row = (DataRowView)dataGridViewRow.DataBoundItem
                                      where dataGridViewRow.Cells["check"].FormattedValue != null && (bool)dataGridViewRow.Cells["check"].FormattedValue
                                      select row).SingleOrDefault();
            if (checkRow == null)
            {
                ACMessageBox.Show(Resources.Text_ChuaChonNV, Resources.Caption_ThongBao, 2000);
                return;
            }

            TreeNode node      = treePhongBan.SelectedNode;
            string   oldFilter = string.Empty;

            frmCapNhatCongNhat frm = new frmCapNhatCongNhat {
                StartPosition = FormStartPosition.CenterParent, m_currRowNV = checkRow
            };
            frm.ShowDialog();


            if (frm.IsReload)
            {
                var dataView = dgrdDSNVTrgPhg.DataSource as DataView;
                if (dataView != null)
                {
                    oldFilter = dataView.RowFilter;
                }
                treePhongBan_AfterSelect(treePhongBan, new TreeViewEventArgs(node));
                dataView = dgrdDSNVTrgPhg.DataSource as DataView;
                if (dataView != null)
                {
                    dataView.RowFilter = oldFilter;
                }
            }


            #endregion
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (XL2.KiemtraKetnoiCSDL() == false)
            {
                return;
            }

            var val30 = (int)numPC30.Value;

            DAO5.UpdSetting((int)numPC30.Tag, val30.ToString());
            var val50 = (int)numPC50.Value;

            DAO5.UpdSetting((int)numPC50.Tag, val50.ToString());
            var valPCTCC3 = (int)numPCTCC3.Value;

            DAO5.UpdSetting((int)numPCTCC3.Tag, valPCTCC3.ToString());
            var val100 = (int)numPC100.Value;

            DAO5.UpdSetting((int)numPC100.Tag, val100.ToString());
            var val160 = (int)numPC160.Value;

            DAO5.UpdSetting((int)numPC160.Tag, val160.ToString());
            var val200 = (int)numPC200.Value;

            DAO5.UpdSetting((int)numPC200.Tag, val200.ToString());
            var val290 = (int)numPC290.Value;

            DAO5.UpdSetting((int)numPC290.Tag, val290.ToString());
            var valTGLamDemToiThieu = dateTimePicker1.Value.TimeOfDay;

            DAO5.UpdSetting((int)dateTimePicker1.Tag, valTGLamDemToiThieu.ToString(@"hh\:mm\:") + "00");
            var valChoPhepTre = (int)numPhutTre.Value;

            DAO5.UpdSetting((int)numPhutTre.Tag, valChoPhepTre.ToString());
            var valChoPhepSom = (int)numPhutSom.Value;

            DAO5.UpdSetting((int)numPhutSom.Tag, valChoPhepSom.ToString());
            var valLamThemAfterOT = (int)numPhutAfterOT.Value;

            DAO5.UpdSetting((int)numPhutAfterOT.Tag, valLamThemAfterOT.ToString());
            ACMessageBox.Show("Lưu thông số thành công.", "Thông báo", 2000);
        }
Exemplo n.º 11
0
        private void frm_XemCong_Load(object sender, EventArgs 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

            #region             //2. lấy dữ liệu phòng ban được phép thao tác  và load treePhongBan ,
            // trường hợp ko có phòng ban nào được phép thao tác thì báo và thoát form

            XL.KhoiTaoDSPhongBan(m_DSPhg, XL2.currUserID);             // tạo danh sách phòng ban chỉ userID này được thao tác
            if (m_DSPhg.Count == 0)
            {
                ACMessageBox.Show(Resources.Text_ChuaCapQuyenPhongBanThaoTac, Resources.Caption_ThongBao, 5000);
                Close();
                return;
            }
            XL.loadTreePhgBan(treePhongBan, XL2.TatcaPhongban, m_DSPhg);

            #endregion

            // đăng ký sự kiện cho tree và chọn topNode
            treePhongBan.AfterSelect += treePhongBan_AfterSelect;
            treePhongBan.SelectedNode = treePhongBan.TopNode;

            //vô hiệu hoá các nút chức năng ko có phân quyền
            btnThemXoaSuaHangLoat.Enabled = XL2.QuyenThaoTac.Any(o => o == (int)Quyen.ThemXoaSuaGioCC);
            btnThemXoaSuaDonGian.Enabled  = XL2.QuyenThaoTac.Any(o => o == (int)Quyen.ThemXoaSuaGioCC);
            btnKetCongThang.Enabled       = XL2.QuyenThaoTac.Any(o => o == (int)Quyen.KetCongThang);
            btnThemKBVang.Enabled         = XL2.QuyenThaoTac.Any(o => o == (int)Quyen.KhaiBaoVang);
            btnXoaKBVang.Enabled          = XL2.QuyenThaoTac.Any(o => o == (int)Quyen.KhaiBaoVang);
            btnXNCa.Enabled          = XL2.QuyenThaoTac.Any(o => o == (int)Quyen.XNCa_LamThem);
            btnXNCaVaLamThem.Enabled = XL2.QuyenThaoTac.Any(o => o == (int)Quyen.XNCa_LamThem);
            btnXNPCTC.Enabled        = XL2.QuyenThaoTac.Any(o => o == (int)Quyen.XN_PCTC);
            btnXacNhanPC100.Enabled  = XL2.QuyenThaoTac.Any(o => o == (int)Quyen.XN_PCDB);
        }
        private void btnLietKe_Click(object sender, EventArgs e)
        {
            if (XL2.KiemtraKetnoiCSDL() == false)
            {
                return;
            }

            //1. lấy dữ liệu từ form
            dtpThang.Update();
            currMonth = dtpThang.Value;
            var ngayBD = DateTime.MinValue;
            var ngayKT = DateTime.MinValue;

            ngayBD = new DateTime(currMonth.Year, currMonth.Month, 1);
            ngayKT = new DateTime(currMonth.Year, currMonth.Month, DateTime.DaysInMonth(currMonth.Year, currMonth.Month));
            //-----------INFO bắt buộc EndEdit thao tác trên Grid rồi mới thực hiện xử lý tác vụ

            dgrdDSNVTrgPhg.EndEdit();
            dgrdDSNVTrgPhg.Update();

            //2. lấy danh sách nhân viên check, nếu chưa có nv nào check thì thông báo
            BindingContext[dgrdDSNVTrgPhg.DataSource].EndCurrentEdit();
            var listNV = (from DataGridViewRow dataGridViewRow in dgrdDSNVTrgPhg.Rows
                          let row = (DataRowView)dataGridViewRow.DataBoundItem
                                    where (row["check"] != DBNull.Value && (bool)row["check"])
                                    select((cUserInfo)row["cUserInfo"]).MaCC).ToList();

            if (listNV.Count == 0)
            {
                ACMessageBox.Show(Resources.Text_ChuaChonNV, Resources.Caption_ThongBao, 2000);
                return;
            }

            var table = DAO.LietKeNgayVangChoNV(listNV, ngayBD, ngayKT);

            dgrdNgayVang.DataSource = table;
            if (table.Rows.Count == 0)
            {
                ACMessageBox.Show("Các nhân viên đang chọn không vắng ngày nào trong tháng.", "Thông báo", 1500);
            }
            GC.Collect();
        }
Exemplo n.º 13
0
        private void frm_KetCongBoPhan_Load(object sender, EventArgs 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

            //set default tháng đang chọn là trước 1 tháng so với hiện tại vì qua tháng mới kết công
            var firstDay_CurrMonth = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
            var firstDay_PrevMonth = firstDay_CurrMonth.AddMonths(-1);
            dtpThang.Value = new DateTime(firstDay_PrevMonth.Year, firstDay_PrevMonth.Month, firstDay_PrevMonth.Day);
            // gọi hàm để load danh sách phòng ban đã kết công
            dtpThang_ValueChanged(dtpThang, null);
        }
        private void frm_KhaiBaoVang_Load(object sender, EventArgs e)
        {
            #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, 4000);
                Close();
                return;
            }

            #endregion

            #region             //2. lấy dữ liệu phòng ban được phép thao tác  và load treePhongBan ,
            // trường hợp ko có phòng ban nào được phép thao tác thì báo và thoát form

            XL.KhoiTaoDSPhongBan(m_DSPhg, XL2.currUserID);
            if (m_DSPhg.Count == 0)
            {
                ACMessageBox.Show(Resources.Text_ChuaCapQuyenPhongBanThaoTac, Resources.Caption_ThongBao, 5000);
                Close();
                return;
            }
            XL.loadTreePhgBan(treePhongBan, XL2.TatcaPhongban, m_DSPhg);

            #endregion

            // đăng ký sự kiện cho tree và chọn topNode
            treePhongBan.AfterSelect += treePhongBan_AfterSelect;
            treePhongBan.SelectedNode = treePhongBan.TopNode;


            // lấy tháng hiện tại cho dtpThang
            dtpThang.Value = currMonth;

            var tableLV = SqlDataAccessHelper.ExecuteQueryString("Select * from LoaiVang");
            cbLoaiVang.ValueMember   = "AbsentCode";
            cbLoaiVang.DisplayMember = "AbsentDescription";
            cbLoaiVang.DataSource    = tableLV;
            cbLoaiVang.SelectedIndex = 0;
        }
Exemplo n.º 15
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (XL2.KiemtraKetnoiCSDL() == false)
            {
                return;
            }
            #region ko cho chỉnh sửa giờ nếu khoảng thời gian xem công tồn tại các ngày đã kết lương

            if (XL.Kiemtra(m_thang.Date, MyUtility.LastDayOfMonth(m_thang)))
            {
                MessageBox.Show(string.Format(Resources.Text_KhoangTGDaKetCong_KoChinhSuaGioCC, "chỉnh sửa thu chi tháng", "thực hiện thao tác", ""),
                                Resources.Caption_ThongBao, MessageBoxButtons.OK);
                return;
            }

            #endregion

            #region lấy thông tin từ form

            int?macc = (int?)lbUserEnrollNumber.Tag;
            if (macc == null)
            {
                ACMessageBox.Show(Resources.Text_ChuaChonNV, Resources.Caption_ThongBao, 2000);
                return;
            }

            #endregion

            // thực hiện query
            int kq = SqlDataAccessHelper.ExecNoneQueryString(
                " delete from DSThuChiThang where Thang=@Thang and UserEnrollNumber=@UserEnrollNumber ",
                new string[] { "@Thang", "@UserEnrollNumber" },
                new object[] { m_thang, macc });
            DAO5.GhiNhatKyThaotac("Xoá khoản thu chi tháng", string.Format("Xoá tạm ứng, lương điều chỉnh, mức đóng BHXH, thu chi khác tháng [{0}]... của 1 NV có mã chấm công [{1}]", m_thang.ToString("dd/MM/yyyy"), macc), maCC: macc);
            if (kq == 0)
            {
                MessageBox.Show(Resources.Text_CoLoi, Resources.Caption_Loi);
            }

            reloadGridDSThuChi();
        }
Exemplo n.º 16
0
        private void frm_DiemDanhNV_Load(object sender, EventArgs e)
        {
            #region kiểm tra kết nối csdl trước
            if (SqlDataAccessHelper.TestConnection(SqlDataAccessHelper.ConnectionString) == false)
            {
                ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 4000);
                Close();
                return;
            }
            #endregion

            try             //general try catch
            {
                #region     //2. lấy dữ liệu phòng ban được phép thao tác  và load treePhongBan ,
                // trường hợp ko có phòng ban nào được phép thao tác thì báo và thoát form

                XL.KhoiTaoDSPhongBan(m_DSPhg, XL2.currUserID);
                if (m_DSPhg.Count == 0)
                {
                    ACMessageBox.Show(Resources.Text_ChuaCapQuyenPhongBanThaoTac, Resources.Caption_ThongBao, 5000);
                    Close();
                    return;
                }
                XL.loadTreePhgBan(treePhongBan, XL2.TatcaPhongban, m_DSPhg);

                #endregion

                // đăng ký sự kiện cho tree và chọn topNode
                treePhongBan.AfterSelect += treePhongBan_AfterSelect;
                treePhongBan.SelectedNode = treePhongBan.TopNode;
                dtpNgay.ValueChanged     += dtpNgay_ValueChanged;

                //vô hiệu hoá các button ko có phân quyền
                btnKBVangNhanh.Enabled = XL2.QuyenThaoTac.Any(o => o == (int)Quyen.KhaiBaoVang);
                btnXoaKBVang.Enabled   = XL2.QuyenThaoTac.Any(o => o == (int)Quyen.KhaiBaoVang);
            } 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);
            }
        }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            //1. kiểm tra dữ liệu nhập ko hợp lệ thì báo
            //2. thực hiện
            string   shiftCode;
            TimeSpan onDuty, offDuty, onLunch, offLunch;
            int      dayCount;
            int      shiftID, onTimeInMin, onTimeOutMin, cutInMin, cutOutMin, lateGraceMin, earlyGraceMin, afterOTMin;

            float chamCong;

            //1.
            if (ValidateValueForm(out shiftCode, out onDuty, out offDuty, out dayCount, out chamCong, out onTimeInMin, out cutInMin, out onTimeOutMin, out cutOutMin,
                                  out lateGraceMin, out earlyGraceMin, out afterOTMin, out onLunch, out offLunch) == false)
            {
                ACMessageBox.Show("Dữ liệu nhập chưa hợp lệ. Vui lòng kiểm tra lại!", Resources.Caption_Loi, 3000);
                return;
            }

            //2.
            m_ShiftID   = (lbShiftID.Tag != null) ? (int)lbShiftID.Tag : -1;
            m_ShiftCode = shiftCode;
            m_OnDuty    = onDuty;
            m_OffDuty   = offDuty;
            m_DayCount  = dayCount;
            //tongiolam
            m_ChamCong      = chamCong;
            m_OnTimeInMin   = onTimeInMin;
            m_CutInMin      = cutInMin;
            m_OnTimeOutMin  = onTimeOutMin;
            m_CutOutMin     = cutOutMin;
            m_EarlyGraceMin = earlyGraceMin;
            m_LateGraceMin  = lateGraceMin;
            m_AfterOTMin    = afterOTMin;
            m_KyHieuCC      = textBoxKyhieu.Text;
            m_OnLunch       = onLunch;
            m_OffLunch      = offLunch;
            m_Enable        = checkBoxEnable.Checked;

            Close();
        }
Exemplo n.º 18
0
        private void btnHuyKetluong_Click(object sender, EventArgs e)
        {
            if (XL2.KiemtraKetnoiCSDL() == false)
            {
                return;                                              // kiểm tra kết nối csdl trước khi thực hiện
            }
            //confirm trước khi thực hiện
            if (MessageBox.Show(string.Format("Bạn muốn hủy kết lương tháng {0}?", m_Thang.ToString("MM/yyyy")), Resources.Caption_XacNhan, MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            if (XL.HuyKetLuongThang(MyUtility.FirstDayOfMonth(m_Thang)))
            {
                ACMessageBox.Show("Đã huỷ kết lương tháng " + m_Thang.ToString("MM/yyyy"), Resources.Caption_ThongBao, 3000);
            }
            else
            {
                MessageBox.Show(Resources.Text_CoLoi, Resources.Caption_Loi);
            }
        }
Exemplo n.º 19
0
        private void btnLuuChucNang_Click(object sender, EventArgs e)
        {
            int focusRowHandle = gridViewTaiKhoan.FocusedRowHandle;

            // kiểm tra focusRowHandle hợp lệ
            if (focusRowHandle == GridControl.InvalidRowHandle || focusRowHandle < 0)
            {
                ACMessageBox.Show("Bạn chưa chọn tài khoản để thao tác.", Resources.Caption_ThongBao, 2000);
                return;
            }

            //kiểm tra kết nối csdl
            if (SqlDataAccessHelper.TestConnection(SqlDataAccessHelper.ConnectionString) == false)
            {
                ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 3000);
                return;
            }

            DataRow    selectedDataRow_TaiKhoan = gridViewTaiKhoan.GetDataRow(focusRowHandle);
            int        userID = (int)selectedDataRow_TaiKhoan["UserID"];
            List <int> dsChucNang_DuocPhanQuyen   = new List <int>();
            List <int> dsChucNang_KoDuocPhanQuyen = new List <int>();

            for (int i = 0; i < checkedListChucNang.ItemCount; i++)
            {
                DataRowView dataRowView = (DataRowView)checkedListChucNang.GetItem(i);
                int         functionID  = (int)dataRowView["ID"];
                bool        checkStatus = checkedListChucNang.GetItemChecked(i);
                if (checkStatus)
                {
                    dsChucNang_DuocPhanQuyen.Add(functionID);
                }
                else
                {
                    dsChucNang_KoDuocPhanQuyen.Add(functionID);
                }
            }
            LuuPhanQuyenChucNang(userID, dsChucNang_DuocPhanQuyen, true);
            LuuPhanQuyenChucNang(userID, dsChucNang_KoDuocPhanQuyen, false);
        }
Exemplo n.º 20
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn muốn XÓA ca làm việc? " +
                                "Xóa ca làm việc sẽ xóa toàn bộ dữ liệu chấm công liên quan đến ca làm việc này." +
                                "Cân nhắc sử dụng Enable/Disable ca làm việc." +
                                "Bấm YES để tiếp tục, No để hủy thao tác.", Resources.Caption_XacNhan) == DialogResult.No)
            {
                return;
            }

            int[]       selRows     = ((GridView)gridControl.MainView).GetSelectedRows();
            DataRowView selRow      = (DataRowView)(((GridView)gridControl.MainView).GetRow(selRows[0]));
            DataRow     selectedRow = selRow.Row;

            var shiftID = (int)selectedRow["ShiftID"];

            //sử dụng kết quả trả về thêm vào CSDL
            if (SqlDataAccessHelper.TestConnection(SqlDataAccessHelper.ConnectionString) == false)
            {
                ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 3000);
                return;
            }

            //todo thực hiện kiểm tra tất cả các bảng có sử dụng shiftID, nếu còn thì ko cho xóa
            // nếu ko còn mới cho xóa
            if (TODOKiemTra() == false)
            {
            }
            else
            {
                int kq = SqlDataAccessHelper.ExecSPNoneQuery(SPName6.Shift_DeleteShiftV6.ToString(),
                                                             new SqlParameter(@"ShiftID", shiftID));
                if (kq == 0)
                {
                    ACMessageBox.Show(Resources.Text_CoLoi, Resources.Caption_Loi, 2000);
                    return;
                }
                LoadGrid();
            }
        }
Exemplo n.º 21
0
        private bool Validate_NgayBD_NgayKT(DateEdit dateEditNgayBdcc, DateEdit dateEditNgayKtcc, out DateTime ngayBdXemCong, out DateTime ngayKtXemCong)
        {
            ngayBdXemCong = new DateTime();
            ngayKtXemCong = new DateTime();

            if (dateEditNgayBdcc.DateTime < DateTime.Now.AddYears(-2) || dateEditNgayBdcc.DateTime > DateTime.Now.AddMonths(2) ||
                dateEditNgayKtcc.DateTime < DateTime.Now.AddYears(-2) || dateEditNgayKtcc.DateTime > DateTime.Now.AddMonths(2))
            {
                ACMessageBox.Show("Nhập ngày chấm công chưa hợp lệ.", Resources.Caption_Loi, 2000);
                return(false);
            }

            ngayBdXemCong = dateEditNgayBdcc.DateTime.Date;            //bỏ phần giờ, lấy phần ngày
            ngayKtXemCong = dateEditNgayKtcc.DateTime.Date;            //bỏ phần giờ, lấy phần ngày
            if (ngayKtXemCong < ngayBdXemCong)
            {
                DateTime temp = ngayBdXemCong;
                ngayBdXemCong = ngayKtXemCong;
                ngayKtXemCong = temp;
            }
            return(true);
        }
        private void fmXemCong4_Load(object sender, EventArgs 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

            /* 1. load tree phòng ( datasource cho checkComboEdit chọn nv do hàm treeAfterselect tạo
             * 2.
             * 3. set tháng khi load lần đầu
             */
            loadTreePhgBan(treePhongBan);
            treePhongBan.AfterSelect += treePhongBan_AfterSelect;

            // xác định lịch trình tổng quan
            BUS_LichTrinh_Ca busLichTrinhCa = new BUS_LichTrinh_Ca();
            busLichTrinhCa.LayTatCaLichTrinhVaCa(ref m_AllNhomCa);
        }
Exemplo n.º 23
0
        private DataRow XacDinh_DataRowTaiKhoan_DangChon()
        {
            #region kiểm tra đang chọn dòng nào

            if (gridViewTaiKhoan.FocusedRowHandle == GridControl.InvalidRowHandle)
            {
                ACMessageBox.Show("Không có tài khoản.", Resources.Caption_ThongBao, 2000);
                return(null);
            }
            if (gridViewTaiKhoan.FocusedRowHandle < 0)
            {
                ACMessageBox.Show("Vui lòng chọn tài khoản.", Resources.Caption_ThongBao, 2000);
                return(null);
            }

            #endregion

            //xác định tài khoản sẽ xóa
            int     focusRowHandle = gridViewTaiKhoan.FocusedRowHandle;
            DataRow dataRow        = gridViewTaiKhoan.GetDataRow(focusRowHandle);
            return(dataRow);
        }
Exemplo n.º 24
0
        private void XuLyInsert(frmTTCaLamViec frm)
        {
            if (SqlDataAccessHelper.TestConnection(SqlDataAccessHelper.ConnectionString) == false)
            {
                ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 3000);
                return;
            }

            bool     enableCSDL     = frm.m_Enable;
            TimeSpan workingTime    = (frm.m_OffDuty - frm.m_OnDuty);
            int      workingTimeMin = Convert.ToInt32(workingTime.TotalMinutes);

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@ShiftCode", frm.m_ShiftCode),
                new SqlParameter("@Enable", enableCSDL),
                new SqlParameter("@OnDuty", frm.m_OnDuty.ToString(@"hh\:mm")),
                new SqlParameter("@OffDuty", frm.m_OffDuty.ToString(@"hh\:mm")),
                new SqlParameter("@DayCount", frm.m_DayCount),
                new SqlParameter("@WorkingTimeMin", workingTimeMin),
                new SqlParameter("@Workingday", frm.m_ChamCong),
                new SqlParameter("@LateGrace", frm.m_LateGraceMin),
                new SqlParameter("@EarlyGrace", frm.m_EarlyGraceMin),
                new SqlParameter("@AfterOT", frm.m_AfterOTMin),
                new SqlParameter("@OnTimeIn", frm.m_OnTimeInMin),
                new SqlParameter("@CutIn", frm.m_CutInMin),
                new SqlParameter("@OnTimeOut", frm.m_OnTimeOutMin),
                new SqlParameter("@CutOut", frm.m_CutOutMin),
                new SqlParameter("@KyHieuCC", frm.m_KyHieuCC),
                new SqlParameter("@OnLunch", frm.m_OnLunch.ToString(@"hh\:mm")),
                new SqlParameter("@OffLunch", frm.m_OffLunch.ToString(@"hh\:mm"))
            };
            int kq = (SqlDataAccessHelper.ExecSPNoneQuery(SPName6.Shift_InsertNewShiftV6.ToString(), param));

            if (kq == 0)
            {
                ACMessageBox.Show(Resources.Text_CoLoi, Resources.Caption_Loi, 2000);
            }
        }
Exemplo n.º 25
0
        private void gridViewTaiKhoan_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            // nếu ko có focus vào dòng nào thì thoát form, nếu có thì xử lý load phòng ban thao tác và phân quyền
            if (e.FocusedRowHandle == GridControl.InvalidRowHandle)
            {
                ACMessageBox.Show("Không có dòng dữ liệu nào được chọn. Form tự động đóng.", Resources.Caption_ThongBao, 2000);
                Close();
            }
            if (e.FocusedRowHandle < 0)
            {
                return;
            }
            //có focus, load phòng và phân quyền theo tài khoản này
            //xác định userID
            DataRow dataRow = gridViewTaiKhoan.GetDataRow(e.FocusedRowHandle);

            if (dataRow == null)
            {
                return;
            }
            int userID = (int)dataRow["UserID"];
            // uncheck all treeNode Phòng ban
            TreeNode root = GeneralBUS.ReturnRootNode(treePhongBan.TopNode);

            SetCheckStatus_AllTreeNode(root, false);
            treePhongBan.Refresh();
            // load dữ liệu phân quyền phòng ban và thực hiện check
            treePhongBan.AfterCheck -= treePhongBan_OnAfterCheck;
            DataTable tablePhanQuyenPhongBan = LoadDataTable_PhanQuyenPhongBan(userID);

            PopulateData_ToTreePhong(tablePhanQuyenPhongBan);
            treePhongBan.ExpandAll();
            treePhongBan.AfterCheck += treePhongBan_OnAfterCheck;
            //load dữ liệu phân quyền chức năng và thực hiện check
            DataTable tablePhanQuyenChucNang = LoadDataTable_PhanQuyenChucNang(userID);

            PopulateData_ToCheckList(tablePhanQuyenChucNang);
        }
Exemplo n.º 26
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            #region kiểm tra nhập liệu hợp lệ

            if (btnTenPhong.Text == string.Empty)
            {
                ACMessageBox.Show("Tên phòng trống", Resources.Caption_Loi, 2000);
                return;
            }
            if (int.TryParse(tbVitriPhong.Text, out m_VitriPhong) == false)
            {
                ACMessageBox.Show("Vị trí phòng không hợp lệ", Resources.Caption_Loi, 2000);
                return;
            }

            #endregion

            this.m_TenPhong      = btnTenPhong.Text;
            this.m_ParentDataRow = (DataRow)treePhongBan.SelectedNode.Tag;
            this.m_Enable        = checkEnable.Checked;
            //this.VitriPhong = VitriPhong;
            this.Close();
        }
Exemplo n.º 27
0
        private void SubMenu_xemHistory_Click(object sender, EventArgs e)
        {
            if (XL2.QuyenThaoTac.Any(o => o == (int)Quyen.XemNhatKyThaoTac) == false)
            {
                ACMessageBox.Show(Resources.Text_KoCoQuyen, Resources.Caption_ThongBao, 3000);
                return;
            }

            frm_32_XemLichSu frm1 = new frm_32_XemLichSu();
            int indexForm         = LayVitriForm(this, frm1.GetType());

            if (indexForm != -1)
            {
                frm1 = this.MdiChildren[indexForm] as frm_32_XemLichSu;
                frm1.BringToFront();
            }
            else
            {
                frm1.MdiParent   = this;
                frm1.WindowState = FormWindowState.Maximized;
                frm1.Show();
            }
        }
Exemplo n.º 28
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            // xác định thông tin tài khoản đang chọn để thực hiện thao tác
            DataRow dataRow = XacDinh_DataRowTaiKhoan_DangChon();
            int     userID  = (int)dataRow["UserID"];

            frmNhapTTTaiKhoan frm = new frmNhapTTTaiKhoan();

            frm.m_Mode        = ModeType.Sua;
            frm.m_TenTaiKhoan = dataRow["UserAccount"].ToString();
            frm.m_Enable      = (bool)dataRow["Enable"];
            frm.ShowDialog();

            if (frm.m_Mode == ModeType.Cancel)
            {
                return;
            }

            //kiểm tra kết nối csdl
            if (SqlDataAccessHelper.TestConnection(SqlDataAccessHelper.ConnectionString) == false)
            {
                ACMessageBox.Show(Resources.Text_MatKetNoiCSDL, Resources.Caption_Loi, 3000);
                return;
            }

            int kq = SqlDataAccessHelper.ExecSPNoneQuery(SPName6.NewUserAccount_CapNhatTaiKhoanV6.ToString(),
                                                         new SqlParameter("@UserID", userID),
                                                         new SqlParameter("@UserAccount", frm.m_TenTaiKhoan),
                                                         new SqlParameter("@Enable", frm.m_Enable));

            if (kq == 0)
            {
                ACMessageBox.Show(Resources.Text_CoLoi, Resources.Caption_Loi, 2000);
                return;
            }
            LoadDSTaiKhoan();
        }
Exemplo n.º 29
0
        private void BtnStart_Click(object sender, EventArgs e)
        {
            if (!TlpInputFields.AC_CheckRequiredFields(txtInputString, NumFramesCount))
            {
                ACMessageBox.ShowFillRequiredFields();
                return;
            }

            var mfu = new VM_PageReplacment(
                txtInputString.Text,
                Convert.ToInt32(NumFramesCount.Value), VMAlgorithmType.MFU);

            var watch = Stopwatch.StartNew();

            if (!mfu.Calculate())
            {
                ACMessageBox.ShowFailedMessage("Failed to start, please check your input");
                return;
            }

            watch.Stop();

            lblTime.Text = $"Estimated Time= {watch.ElapsedMilliseconds}ms";

            mfu.FillDGV(DGV);

            var hits   = $"{mfu.Hits}/{mfu.InputString.Length}";
            var faults = $"{mfu.Faults}/{mfu.InputString.Length}";

            lblHits.Text   = $"Page Hits = {hits}";
            lblFaults.Text = $"Page Faults = {faults}";

            lblHits.Visible = lblFaults.Visible = lblTime.Visible = true;

            GbInput.Enabled  = false;
            BtnStart.Enabled = false;
        }
Exemplo n.º 30
0
        private void btnThaydoi_Click(object sender, EventArgs e)
        {
            if (XL2.KiemtraKetnoiCSDL() == false)
            {
                return;
            }

            string oldPass     = btnEditMatkhauCu.Text;
            string newPass     = btnEditMatkhauMoi1.Text;
            string testPass    = btnEditMatkhauMoi2.Text;
            string userAccount = GlobalVariables.CurrentUserAccount;
            int    userID      = GlobalVariables.CurrentUserID;

            if (newPass == testPass)
            {
                ACMessageBox.Show("Vui lòng nhập 2 mật khẩu mới giống nhau.", Resources.Caption_Loi, 2000);
                return;
            }
            if (DAO5.ChangePassword(oldPass, newPass, userAccount, userID))
            {
                ACMessageBox.Show(Resources.Text_DaThucHienXong, Resources.Caption_ThongBao, 2000);
                this.Close();
            }
        }