Ejemplo n.º 1
0
        private void InitStaffs()
        {
            DataTable dt = new DataTable();

            _staffs = new Dictionary <string, OEEStaff>();
            string dataBaseName = gVariable.basicInfoDatabaseName;
            string commandText  = "select * from `" + gVariable.employeeTableName + "`";

            dt = mySQLClass.queryDataTableAction(dataBaseName, commandText, null);
            try
            {
                for (int row = 0; row < dt.Rows.Count; row++)
                {
                    OEEStaff staff;
                    staff = new OEEStaff(dt.Rows[row][STAFF_WORKID].ToString(),
                                         dt.Rows[row][STAFF_NAME].ToString(),
                                         dt.Rows[row][STAFF_WORKSHOP].ToString());
                    _staffs.Add(dt.Rows[row][STAFF_WORKID].ToString(), staff);
                }
            }
            catch (Exception)
            {
                System.Console.WriteLine("Error: No Employees in the database");
            }
        }
Ejemplo n.º 2
0
        private void BtnStaffQuery_Click(object sender, EventArgs e)
        {
            int yearStart  = Convert.ToInt32(this.CmbYearStart.Text);
            int yearEnd    = Convert.ToInt32(this.CmbYearEnd.Text);
            int monthStart = Convert.ToInt32(this.CmbMonthStart.Text);
            int monthEnd   = Convert.ToInt32(this.CmbMonthEnd.Text);

            DateTime startTime = OEEUtils.ConvertToDayStartOfMonth(yearStart, monthStart);
            DateTime endTime   = OEEUtils.ConvertToDayEndOfMonth(yearEnd, monthEnd);

            totalIndex = 1;

            this.LvwMonthView.Items.Clear();
            this.LvwDetailView.Items.Clear();

            if (DateTime.Compare(startTime, endTime) > 0)
            {
                MessageBox.Show("起始时间不能大于终止时间", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                string id = this.CmbStaffName.Text.Split(' ').First();
                selectedStaff = staffs[id];

                for (int year = yearStart; year <= yearEnd; year++)
                {
                    if (monthEnd < monthStart)
                    {
                        monthEnd = OEETypes.MONTH_END;
                    }

                    for (int month = monthStart; month <= monthEnd; month++)
                    {
                        OEETypes.OutputInHours outputInHours;
                        DateTime start = OEEUtils.ConvertToDayStartOfMonth(year, month);
                        DateTime end   = OEEUtils.ConvertToDayEndOfMonth(year, month);
                        outputInHours = selectedStaff.QueryLabourHour(start, end, factory);
                        ShowMonthList(outputInHours, selectedStaff.Name, year, month);
                    }

                    monthStart = 1;
                }
            }
        }