Ejemplo n.º 1
0
        public MainWindow(SectionModel section)
        {
            InitializeComponent();
            this.section = section;
            bwLoadData   = new BackgroundWorker();
            bwLoadData.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwLoadData_RunWorkerCompleted);
            bwLoadData.DoWork             += new DoWorkEventHandler(bwLoadData_DoWork);
            lineList            = new List <LineModel>();
            personalList        = new List <PersonalModel>();
            sourceList          = new List <SourceModel>();
            workerLoginList     = new List <WorkerLoginModel>();
            workerLoginViewList = new ObservableCollection <WorkerLoginViewModel>();
            bwInsertWorkerLogin = new BackgroundWorker();
            bwInsertWorkerLogin.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwInsertWorkerLogin_RunWorkerCompleted);
            bwInsertWorkerLogin.DoWork             += new DoWorkEventHandler(bwInsertWorkerLogin_DoWork);
            workerLoginToImport     = new WorkerLoginModel();
            workerLoginViewToImport = new WorkerLoginViewModel();
            resultInsert            = false;

            threadOtherDate                     = new BackgroundWorker();
            threadOtherDate.DoWork             += new DoWorkEventHandler(threadOtherDate_DoWork);
            threadOtherDate.RunWorkerCompleted += new RunWorkerCompletedEventHandler(threadOtherDate_RunWorkerCompleted);
            lineAllList = new List <LineModel>();
        }
Ejemplo n.º 2
0
        private void bwLoadData_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            string version = AssemblyHelper.Version();

            miRequestList.Visibility = Visibility.Collapsed;
            if (section.SectionId == "F")
            {
                this.Title = string.Format("Assembly Incentives - {0}", version);
                miAssemblyReportIncentives.IsEnabled = true;
            }
            if (section.SectionId == "E")
            {
                this.Title = string.Format("Sewing Incentives - {0}", version);
            }
            if (section.SectionId == "B" || section.SectionId == "C")
            {
                this.Title = string.Format("Cut-Prep Incentives - {0}", version);
            }
            if (section.SectionId == "G")
            {
                this.Title = string.Format("Outsole Incentives - {0}", version);
            }
            if (section.SectionId == "IE")
            {
                miRequestList.Visibility = Visibility.Visible;
            }
            int countColumn = gridLine.ColumnDefinitions.Count();
            int countRow    = countRow = lineList.Count / countColumn;

            if (lineList.Count % countColumn != 0)
            {
                countRow = lineList.Count / countColumn + 1;
            }
            gridLine.RowDefinitions.Clear();
            for (int i = 1; i <= countRow; i++)
            {
                RowDefinition rd = new RowDefinition
                {
                    Height = new GridLength(1, GridUnitType.Star),
                };
                gridLine.RowDefinitions.Add(rd);
            }

            for (int i = 0; i <= lineList.Count() - 1; i++)
            {
                LineModel line    = lineList[i];
                Button    btnLine = new Button();
                Grid.SetColumn(btnLine, i % countColumn);
                Grid.SetRow(btnLine, i / countColumn);
                btnLine.Margin     = new Thickness(3, 1, 3, 1);
                btnLine.Content    = String.Format("LINE {0}", line.Name);
                btnLine.Tag        = line;
                btnLine.ToolTip    = String.Format("Log-in to LINE {0}", line.Name);
                btnLine.Background = Brushes.RoyalBlue;
                btnLine.Foreground = Brushes.White;
                btnLine.FontWeight = FontWeights.Bold;
                btnLine.Click     += new RoutedEventHandler(btnLine_Click);
                gridLine.Children.Add(btnLine);
            }

            foreach (WorkerLoginModel workerLogin in workerLoginList)
            {
                PersonalModel personal = personalList.Where(p => p.CardId == workerLogin.CardId || p.WorkerId == workerLogin.WorkerId).FirstOrDefault();
                if (personal != null)
                {
                    WorkerLoginViewModel workerLoginView = new WorkerLoginViewModel
                    {
                        CardId   = personal.CardId,
                        WorkerId = personal.WorkerId,
                        Name     = personal.Name,
                        Line     = personal.Department,
                        LineWork = workerLogin.LineId,
                        Position = personal.Position,
                    };
                    workerLoginViewList.Add(workerLoginView);
                }
            }
            dgWorkerLogin.ItemsSource = workerLoginViewList;
            txtCardId.IsEnabled       = true;
            this.Cursor = null;
        }
Ejemplo n.º 3
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            string cardId = txtCardId.Text;

            if (chbOtherDate.IsChecked == true)
            {
                if (threadOtherDate.IsBusy == false)
                {
                    this.Cursor         = Cursors.Wait;
                    txtCardId.IsEnabled = false;

                    DateTime      date      = dpOtherDate.SelectedDate.Value.Date;
                    List <Object> arguments = new List <Object>();
                    arguments.Add(cardId);
                    arguments.Add(date);
                    threadOtherDate.RunWorkerAsync(arguments);
                }
            }
            else
            {
                PersonalModel personal = personalList.Where(p => p.CardId == cardId || p.WorkerId == cardId).FirstOrDefault();
                if (personal == null)
                {
                    MessageBox.Show("This Worker Not Found!", this.Title, MessageBoxButton.OK, MessageBoxImage.Warning);
                    txtCardId.Focus();
                    txtCardId.SelectAll();
                    return;
                }
                workerLoginViewToImport = workerLoginViewList.Where(w => w.CardId == personal.CardId && w.WorkerId == personal.WorkerId).FirstOrDefault();
                if (workerLoginViewToImport != null)
                {
                    dgWorkerLogin.SelectedItem = workerLoginViewToImport;
                    string    lineWork = workerLoginViewToImport.LineWork;
                    LineModel line     = lineList.Where(l => l.LineId == lineWork).FirstOrDefault();
                    if (line != null)
                    {
                        lineWork = line.Name;
                    }
                    MessageBox.Show(String.Format("Id: {0}\nName: {1}\nPosition: {2}\nWork at Line: LINE {3}", workerLoginViewToImport.WorkerId, workerLoginViewToImport.Name, workerLoginViewToImport.Position, lineWork), this.Title, MessageBoxButton.OK, MessageBoxImage.Information);
                    txtCardId.Focus();
                    txtCardId.SelectAll();
                    return;
                }
                workerLoginViewToImport = new WorkerLoginViewModel
                {
                    CardId   = personal.CardId,
                    WorkerId = personal.WorkerId,
                    Name     = personal.Name,
                    Line     = personal.Department,
                    LineWork = btnLogin.Tag.ToString(),
                    Position = personal.Position,
                };

                workerLoginToImport = new WorkerLoginModel
                {
                    CardId   = personal.CardId,
                    WorkerId = personal.WorkerId,
                    LineId   = btnLogin.Tag.ToString(),
                };

                if (bwInsertWorkerLogin.IsBusy == false)
                {
                    this.Cursor         = Cursors.Wait;
                    resultInsert        = false;
                    txtCardId.IsEnabled = false;
                    bwInsertWorkerLogin.RunWorkerAsync();
                }
            }
        }