Example #1
0
        /// <summary>
        /// Shows a wait window with the specified text while executing the passed method.
        /// </summary>
        /// <param name="workerMethod">Pointer to the method to execute while displaying the wait window.</param>
        /// <param name="message">The text to display.</param>
        /// <param name="args">Arguments to pass to the worker method.</param>
        /// <returns>The result argument from the worker method.</returns>
        public static object Show(EventHandler <WaitWindowEventArgs> workerMethod, string message, params object[] args)
        {
            List <object> arguments = new List <object>();

            arguments.AddRange(args);

            WaitWindow instance = new WaitWindow();

            return(instance.Show(workerMethod, message, arguments));
        }
Example #2
0
        public WaitWindowGUI(WaitWindow parent)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            this._Parent = parent;

            //	Position the window in the top right of the main screen.
            this.Top  = Convert.ToInt32((Screen.PrimaryScreen.WorkingArea.Bottom - this.Height) / 2d);          // + 32;
            this.Left = Convert.ToInt32((Screen.PrimaryScreen.WorkingArea.Right - this.Width) / 2d);            // - 32;
        }
Example #3
0
        /// <summary>
        /// Shows a wait window with the specified text while executing the passed method.
        /// </summary>
        /// <param name="workerMethod">Pointer to the method to execute while displaying the wait window.</param>
        /// <param name="message">The text to display.</param>
        /// <returns>The result argument from the worker method.</returns>
        public static object Show(EventHandler <WaitWindowEventArgs> workerMethod, string message)
        {
            WaitWindow instance = new WaitWindow();

            return(instance.Show(workerMethod, message, new List <object>()));
        }
Example #4
0
 /// <summary>
 /// Shows a wait window with the text 'Please wait...' while executing the passed method.
 /// </summary>
 /// <param name="workerMethod">Pointer to the method to execute while displaying the wait window.</param>
 /// <returns>The result argument from the worker method.</returns>
 public static object Show(EventHandler <WaitWindowEventArgs> workerMethod)
 {
     return(WaitWindow.Show(workerMethod, null));
 }
 /// <summary>
 /// Initialises a new intance of the WaitWindowEventArgs class.
 /// </summary>
 /// <param name="GUI">The associated WaitWindow instance.</param>
 /// <param name="args">A list of arguments to be passed.</param>
 public WaitWindowEventArgs(WaitWindow GUI, List <object> args) : base()
 {
     this._Window    = GUI;
     this._Arguments = args;
 }
Example #6
0
        private void btnXem_Click(object sender, EventArgs e)
        {
            //1. lấy dữ liệu từ form
            #region lấy ngày BD và kết thúc, 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
            dtpNgayBD.Update(); dtpNgayKT.Update();
            DateTime ngayBD = dtpNgayBD.Value.Date;
            ngayBD = ngayBD.AddDays(-1d);
            DateTime ngayKT = dtpNgayKT.Value.Date;
            ngayKT = ngayKT.AddDays(2d).Subtract(new TimeSpan(0, 0, 1));
            #endregion
            //-----------BUG [KHÔNG PHẢI BUG] CHỈ TÔ MÀU ĐỂ CHÚ Ý] 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
            if (flstDSNVChkXemCong == null)
            {
                flstDSNVChkXemCong = new List <cUserInfo>();
            }
            else
            {
                flstDSNVChkXemCong.Clear();
            }
            LayDSNVXemCong(dgrdDSNVTrgPhg.DataSource as DataTable, flstDSNVChkXemCong, flstDSNV);
            //3. lấy dữ liệu chấm công của các nhân viên
            if (flstDSNVChkXemCong.Count == 0)
            {
                AutoClosingMessageBox.Show("Chưa chọn Nhân viên", "Thông báo", 2000);
                return;
            }
            //[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
            try {
                WaitWindow.Show(this.abc, "Đang xử lý...", new object[] { flstDSNVChkXemCong, ngayBD, ngayKT });
                //XL.XemCong(flstDSNVChkXemCong, ngayBD, ngayKT);

                //4. xử lý dữ liệu để đưa lên lưới tổng hợp

                DataTable dataTableTongHop = dgrdTongHop.DataSource as DataTable;
                if (dataTableTongHop == null)
                {
                    dataTableTongHop = TaoCauTrucDataTableTongHop();
                }
                else
                {
                    dataTableTongHop.Rows.Clear();
                }

                DataTable dataTableKDQD = dgrdGioKDQD.DataSource as DataTable;
                if (dataTableKDQD == null)
                {
                    dataTableKDQD = TaoCauTrucDataTableKDQD();
                }
                else
                {
                    dataTableKDQD.Rows.Clear();
                }

                const string shiftid = "ShiftID";
                int          i1      = 1;
                #region fill vào dataTable
                foreach (cUserInfo nhanvien in flstDSNVChkXemCong)
                {
                    for (int i = 1; i < nhanvien.DSNgayCong.Count - 1; i++)               //[CHÚ Ý] ở đây chỉ chạy từ 1-> kế cuối
                    //Debug.WriteLine(nhanvien.DSNgayCong[0]);
                    //Debug.WriteLine(nhanvien.DSNgayCong[nhanvien.DSNgayCong.Count - 1]);
                    {
                        cNgayCong ngayCong = nhanvien.DSNgayCong[i];
                        //Debug.WriteLine(cChkInOut1.ToString());
                        DataRow rowTH = dataTableTongHop.NewRow();
                        rowTH["check"]            = false;
                        rowTH["UserEnrollNumber"] = nhanvien.UserEnrollNumber; rowTH["UserFullName"] = nhanvien.UserFullName;
                        rowTH["TimeStrNgay"]      = rowTH["TimeStrThu"] = ngayCong.NgayCong;
                        rowTH["Cong"]             = ngayCong.TongCong;
                        rowTH["PhuCap"]           = ngayCong.TongPhuCap;
                        rowTH["TimeStrTre"]       = Math.Floor(ngayCong.TongTre.TotalMinutes);
                        rowTH["TimeStrSom"]       = Math.Floor(ngayCong.TongSom.TotalMinutes);
                        rowTH["TongGioLam"]       = ngayCong.TongGioLam.TotalHours;
                        rowTH["TongGioThuc"]      = ngayCong.TongGioThuc.TotalHours;
                        if (ngayCong.HasCheck)
                        {
                            i1 = 1;
                            foreach (cChkInOut cChkInOut1 in ngayCong.DSVaoRa)
                            {
                                if (i1 > 3)
                                {
                                    break;
                                }
                                rowTH[ThamSo.nameVao + i1] = cChkInOut1.Vao != null ? (object)cChkInOut1.Vao.TimeStr : DBNull.Value;
                                rowTH[ThamSo.nameRa + i1]  = cChkInOut1.Raa != null ? (object)cChkInOut1.Raa.TimeStr : DBNull.Value;
                                rowTH[shiftid + i1]        = (cChkInOut1.HaveINOUT > 0) ? (object)cChkInOut1.ThuocCa.ShiftID : DBNull.Value;
                                rowTH["ShiftCode"]        += (cChkInOut1.HaveINOUT > 0) ? cChkInOut1.ThuocCa.ShiftCode + "; " : ((cChkInOut1.HaveINOUT == -1) ? "KV; " : "KR; ");
                                i1++;
                            }
                            rowTH["ShiftCode"] += ngayCong.XuatChuoiVang();
                        }
                        else
                        {
                            if (ngayCong.DSVang != null && ngayCong.DSVang.Count != 0)
                            {
                                rowTH["ShiftCode"] += ngayCong.XuatChuoiVang();
                            }
                            else
                            {
                                rowTH["ShiftCode"] = "--";
                            }
                        }
                        dataTableTongHop.Rows.Add(rowTH);
                    }
                }
                #endregion

                dgrdTongHop.DataSource = dataTableTongHop;

                foreach (DataRow row in dataTableTongHop.Select("(ShiftID1 is NULL and (TimeStrVao1 is not null or TimeStrRa1 is not null)) " +
                                                                " or (ShiftID2 is NULL and (TimeStrVao2 is not null or TimeStrRa2 is not null))" +
                                                                " or (ShiftID3 is NULL and (TimeStrVao3 is not null or TimeStrRa3 is not null))" +
                                                                " OR (ShiftID1 is NOT NULL and ShiftID1 = " + int.MinValue + ")" +
                                                                " OR (ShiftID2 is NOT NULL and ShiftID2 = " + int.MinValue + ")" +
                                                                " OR (ShiftID3 is NOT NULL and ShiftID3 = " + int.MinValue + ")", string.Empty, DataViewRowState.CurrentRows).ToList())
                {
                    dataTableKDQD.ImportRow(row);
                }
                dgrdGioKDQD.DataSource           = dataTableKDQD;
                checkAllGridTH.CheckedChanged   -= checkAll_CheckedChanged;
                checkAllGridKDQD.CheckedChanged -= checkAll_CheckedChanged;
                checkAllGridTH.Checked           = false;
                checkAllGridKDQD.Checked         = false;
                checkAllGridTH.CheckedChanged   += checkAll_CheckedChanged;
                checkAllGridKDQD.CheckedChanged += checkAll_CheckedChanged;
                GC.Collect();
            } catch {
                MessageBox.Show("Mất kết nối đến máy chủ. Vui lòng thử lại sau.", "Lỗi");
                GC.Collect();
                return;
            }
        }