Пример #1
0
        public void FormView()
        {
            AssController assController = new AssController();

            //InDoor && OutDoor
            Dictionary <int, string> doorOrdinal = assController.DoorOrdinal();

            foreach (var pvk in doorOrdinal)
            {
                this.comboBoxInOutDoor.Items.Add(pvk.Value);
            }

            this.comboBoxInOutDoor.DropDownStyle = ComboBoxStyle.DropDownList;

            //DEPARTMENT
            Dictionary <int, string> department = assController.Department();

            this.comboBoxDepartmen.Items.Add(translationText.Get("allDepartments"));

            foreach (var pvk in department.OrderBy(x => x.Value))
            {
                this.comboBoxDepartmen.Items.Add(pvk.Value);
            }

            this.comboBoxDepartmen.DropDownStyle = ComboBoxStyle.DropDownList;
            this.comboBoxDepartmen.SelectedIndex = 0;
        }
Пример #2
0
        private void ComboBoxDepartmen_SelectedIndexChanged(object sender, EventArgs e)
        {
            AssController assController = new AssController();
            //Employee
            int searchDepartment = assController.SearchDepartment(this.comboBoxDepartmen.Text);
            Dictionary <int, Employee> cardEmployeeDepart =
                assController.CardEmployeeDepart(String.Empty, searchDepartment);

            this.comboBoxEmploee.Items.Clear();

            if (cardEmployeeDepart.Count > 0)
            {
                this.comboBoxEmploee.Items.Add(translationText.Get("allOfficers"));
            }

            foreach (var pvk in cardEmployeeDepart.OrderBy(x => x.Value.EmployeeName))
            {
                this.comboBoxEmploee.Items.Add(pvk.Value.EmployeeName.ToString());
            }

            this.comboBoxEmploee.DropDownStyle = ComboBoxStyle.DropDownList;
            this.comboBoxEmploee.SelectedIndex = 0;
        }
Пример #3
0
        private async void BtnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                this.listViewEventRecord.Items.Clear();
                AssController assController = new AssController();

                Dictionary <int, string> doorCtrlID  = assController.DoorCtrlID();
                Dictionary <int, string> doorOrdinal = assController.DoorOrdinal();

                SearchDataTime searchDataTime =
                    new SearchDataTime(this.startSearchDataTimePicker.Text, this.endSearchDataTimePicker.Text);

                string startSearchData = searchDataTime.StartData();
                string endSearchData   = searchDataTime.EndData();
                string startSearchTime = searchDataTime.StartTime();
                string endSearchTime   = searchDataTime.EndTime();

                int ctrlIDOptional   = 3;
                int ordinalOptional  = assController.OrdinalOptional(this.comboBoxInOutDoor.Text);
                int searchDepartment = assController.SearchDepartment(this.comboBoxDepartmen.Text);

                //First Name Second Name Last Name
                string searchUserName = assController.SearchUserName(this.comboBoxEmploee.Text);

                //checket error
                ErrorMessage errorMessage = new ErrorMessage();
                errorMessage.ShowErrorMessage(startSearchData, endSearchData, startSearchTime,
                                              endSearchTime, ordinalOptional, searchDepartment, searchUserName);

                lblStatus.Text = string.Format($"{translationText.Get("process")}...10%");
                lblStatus.Update();
                progressBar.Value = 10;
                progressBar.Update();

                EventRecord eventRecord = assController.EventRecordRead(startSearchData, endSearchData,
                                                                        startSearchTime, endSearchTime, ctrlIDOptional, ordinalOptional);

                //progress bar
                Progress <ProgressReport> progress = new Progress <ProgressReport>();
                progress.ProgressChanged += (o, report) => {
                    if (report.PercentComplete > 15)
                    {
                        lblStatus.Text = string.Format($"{translationText.Get("process")}...{report.PercentComplete}%");
                        lblStatus.Update();
                        progressBar.Value = report.PercentComplete;
                        progressBar.Update();
                    }
                };
                await ProcessData(eventRecord, progress);

                lblStatus.Text = translationText.Get("done");

                Dictionary <int, Employee> cardEmployeeDepart = new Dictionary <int, Employee>();
                cardEmployeeDepart = assController.CardEmployeeDepart(searchUserName, searchDepartment);

                print = new List <PrintList>();

                int index = 0;
                foreach (var cardLow in eventRecord.CardLow)
                {
                    if (!cardEmployeeDepart.ContainsKey(cardLow))
                    {
                        index++;
                        continue;
                    }

                    PrintList prnName = new PrintList
                    {
                        EmployeeName   = cardEmployeeDepart[cardLow].EmployeeName,
                        DateTime       = eventRecord.AriseTime[index],
                        CtrlID         = doorCtrlID[eventRecord.CtrlID[index]],
                        Ordinal        = doorOrdinal[eventRecord.Ordinal[index]],
                        DepartmentName = cardEmployeeDepart[cardLow].DepartmentName
                    };

                    index++;
                    print.Add(prnName);
                }

                if (print.Count == 0)
                {
                    throw new Exception(translationText.Get("emptyOfficers"));
                }

                ViewFormEvent(print);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }