public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            //ExcelManager _manager = new ExcelManager();
            //List<ExcelB> listB = _manager.LoadCollectionExcelB();

            ExcelC entry = (value as BindingGroup).Items[0] as ExcelC;

            if (string.IsNullOrEmpty(entry.Val1))
            {
                return(new ValidationResult(false, "Value 1 must not be empty!"));
            }


            //bool contains = false;

            //foreach (var item in listB)
            //{
            //    if (item.Val3Main.Equals(entry.Val3))
            //        contains = true;
            //}

            //if (contains)
            //    return ValidationResult.ValidResult;
            //else
            //    return new ValidationResult(false, "Value 3 must exist in ExcelB!");

            return(ValidationResult.ValidResult);
        }
        private string ShowEditEntryDialogFuncExcelC(ExcelC entryToEdit)
        {
            var dialog = new EditValueExcelCWindow(EditEntryFromDialogExcelC, entryToEdit);
            dialog.ShowDialog();

            return ""; //just pseudo
        }
        public EditValueExcelCWindow(Action <ExcelC> editingAction, ExcelC entryToEdit)
        {
            InitializeComponent();

            vm = (EditValueExcelCWindowViewModel)this.DataContext;
            vm.EditExcelCValue = entryToEdit;
            vm.CloseDialogFunc = new Func <int, string>(ShowEditEntryDialogFuncExcelC);

            callbackFromParentWindow = editingAction;
        }
 public void EditEntryExcelCFromCodeBehind(ExcelC entry)
 {
     if (entry != null)
     {
         List <ExcelC> tempList = MyCollectionC.ToList();
         foreach (ExcelC item in tempList)
         {
             if (item.Val1.Equals(entry.Val1))
             {
                 item.Val2     = entry.Val2;
                 item.Val3     = entry.Val3;
                 item.Val4     = entry.Val4;
                 MyCollectionC = new ObservableCollection <ExcelC>(tempList);
                 break;
             }
         }
     }
 }
Beispiel #5
0
        public List <ExcelC> LoadCollectionExcelC(String month)
        {
            try
            {
                slDocExcelC = new SLDocument("ExcelC.xlsx");
            }
            catch (System.IO.FileNotFoundException e)
            {
                slDocExcelC = new SLDocument();
                slDocExcelC.SaveAs("ExcelC.xlsx");
                slDocExcelC = new SLDocument("ExcelC.xlsx");
            }
            catch (System.IO.IOException f)
            {
                throw f;
            }

            _InitWorkSheets(slDocExcelC);
            slDocExcelC.SelectWorksheet(month);

            List <ExcelC> tempList = new List <ExcelC>();

            for (int i = 2; i < 80; i++)
            {
                ExcelC temp = new ExcelC();
                temp.Val1 = slDocExcelC.GetCellValueAsString("B" + i.ToString());
                temp.Val2 = slDocExcelC.GetCellValueAsString("C" + i.ToString());
                temp.Val3 = slDocExcelC.GetCellValueAsString("D" + i.ToString());
                temp.Val4 = slDocExcelC.GetCellValueAsString("E" + i.ToString());

                if (string.IsNullOrEmpty(temp.Val1)) // Check for ID is not empty
                {
                    break;
                }
                else
                {
                    tempList.Add(temp);
                }
            }

            return(tempList);
        }
Beispiel #6
0
 private void InitValuesAndCollections()
 {
     EditExcelCValue = new ExcelC();
 }
 public void AddEntryExcelCFromCodeBehind(ExcelC entry)
 {
     MyCollectionC.Add(entry);
 }
 private void EditEntryFromDialogExcelC(ExcelC entry)
 {
     vm.EditEntryExcelCFromCodeBehind(entry);
 }
 private void AddEntryFromDialogExcelC(ExcelC entry)
 {
     vm.AddEntryExcelCFromCodeBehind(entry);
 }