Exemple #1
0
        /// <summary>
        /// Loading a file stores the old data and the new data in the command.
        /// So, when undoing or redoing this command, you won't access the disk again.
        /// </summary>
        /// <param name="vm"></param>
        /// <param name="lc"></param>
        /// <param name="newCases"></param>
        public LoadCommand(MainViewModel vm, string newFilePath, ListCases newCases) : base(vm)
        {
            OldCases    = vm.Cases;
            OldFilePath = vm.Settings.DataFilePath;

            NewCases    = newCases;
            NewFilePath = new FileInfo(newFilePath);
        }
Exemple #2
0
 private void Search_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(txtCodeFind.Text))
     {
         var nro = int.Parse(txtCodeFind.Text);
         lboxCases.DataSource = ListCases.Where(x => x.Code == nro).ToList();
     }
     else
     {
         InitialLoad();
         ChargeList();
     }
 }
Exemple #3
0
 private void txtCodeFind_KeyPress(object sender, KeyPressEventArgs e)
 {
     General.ValidNumber(e);
     if (!string.IsNullOrWhiteSpace(txtCodeFind.Text))
     {
         var nro = int.Parse(txtCodeFind.Text);
         lboxCases.DataSource = ListCases.Where(x => x.Code == nro).ToList();
     }
     else
     {
         InitialLoad();
         ChargeList();
     }
 }
Exemple #4
0
        private void CreateCase()
        {
            int code = Convert.ToInt16(txtBarCodeScanned.Text.Length == 5 ? txtBarCodeScanned.Text.Substring(1) : txtBarCodeScanned.Text);

            var iCode = ListCases.FirstOrDefault(c => c.Code == code);

            if (iCode != null)
            {
                if (!ValidateCase(iCode))
                {
                    return;
                }
                iCode.Units++;
            }
            else
            {
                var singleOrDefault = UnitOfWork.ListConfigurations().SingleOrDefault(x => x.Name == "xETADefault");
                if (singleOrDefault != null)
                {
                    var objCase = new Case
                    {
                        Code           = code,
                        DateCreation   = DateTime.Now,
                        ETA            = int.Parse(string.IsNullOrWhiteSpace(nudTimeETA.Text) ? singleOrDefault.Value : nudTimeETA.Text),
                        IsInProduction = false,
                        Units          = int.Parse(string.IsNullOrWhiteSpace(nudUnitsManual.Text) ? "1" : nudUnitsManual.Text),
                        Company        = (Company)lbxCompany.SelectedItem
                    };
                    ((Company)lbxCompany.SelectedItem).MaxCodeActual = code;
                    UnitOfWork.DalCases.CreateCase(objCase);
                    CreateCaseControl();
                }
            }

            UnitOfWork.SaveData();
            InitialLoad();
            var copySelection = (Company)lbxCompany.SelectedItem;

            ChargeList();
            lbxCompany.SelectedItem = copySelection;
            SearchAndCleanControl(tpManual.Controls);
            SearchAndCleanControl(tpScan.Controls);
        }
Exemple #5
0
        private void lbxCompany_SelectedIndexChanged(object sender, EventArgs e)
        {
            var filterCases = ListCases.Where(x => x.IdCompany == ((Company)lbxCompany.SelectedItem).Id).ToList();

            FillListBox(lboxCases, filterCases, "Id", "code");
        }
 public NewCommand(MainViewModel vm) : base(vm)
 {
     OldList = ViewModel.Cases;
 }