コード例 #1
0
        public static AddedView AddedFabricator(DicFabricator fabricator)
        {
            var tbFabricator = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var lblFE = new Label()
            {
                Content = "Необходимо заполнить Производитель", Foreground = Brushes.Red, Visibility = Visibility.Collapsed
            };
            var a = new AddedView
            {
                Controls = new List <Control> {
                    new Label()
                    {
                        Content = "Производитель", Margin = new Thickness(10, 10, 10, 0)
                    },
                    tbFabricator,
                    lblFE
                }
            };

            if (fabricator == null)
            {
                a.Submit = new SimpleCommand(() =>
                {
                    if (string.IsNullOrEmpty(tbFabricator.Text.Trim()))
                    {
                        lblFE.Visibility = Visibility.Visible;
                        return;
                    }
                    SQL.Add(new DicFabricator()
                    {
                        Fabricator = tbFabricator.Text
                    });
                    a.Close();
                });
            }
            else
            {
                tbFabricator.Text = fabricator.Fabricator;
                a.Submit          = new SimpleCommand(() =>
                {
                    if (string.IsNullOrEmpty(tbFabricator.Text.Trim()))
                    {
                        lblFE.Visibility = Visibility.Visible;
                        return;
                    }
                    SQL.Update(new DicFabricator()
                    {
                        IdFabricator = fabricator.IdFabricator, Fabricator = tbFabricator.Text
                    });
                    a.Close();
                });
            }

            a.Init();
            mainWindow.ShowAddedWindow(a);
            return(a);
        }
コード例 #2
0
        public static AddedView AddedExecutors(Executors executors)
        {
            var tbExecutors = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var a = new AddedView {
                Controls = new List <Control> {
                    new Label()
                    {
                        Content = "Исполнитель", Margin = new Thickness(10, 10, 10, 0)
                    }, tbExecutors
                }
            };

            if (executors == null)
            {
                a.Submit = new SimpleCommand(() =>
                {
                    SQL.Add(new Executors()
                    {
                        Name = tbExecutors.Text
                    });
                    a.Close();
                });
            }
            else
            {
                tbExecutors.Text = executors.Name;
                a.Submit         = new SimpleCommand(() =>
                {
                    SQL.Update(new Executors()
                    {
                        IdExecutor = executors.IdExecutor, Name = tbExecutors.Text
                    });
                    a.Close();
                });
            }

            a.Init();
            mainWindow.ShowAddedWindow(a);
            return(a);
        }
コード例 #3
0
        public static AddedView AddedDicWork(DicWork work)
        {
            var tbWork = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var tbPrice = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var tbDescription = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var a = new AddedView
            {
                Controls = new List <Control>
                {
                    new Label()
                    {
                        Content = "Работа", Margin = new Thickness(10, 10, 10, 0)
                    },
                    tbWork,
                    new Label()
                    {
                        Content = "Цена", Margin = new Thickness(10, 10, 10, 0)
                    },
                    tbPrice,
                    new Label()
                    {
                        Content = "Описание", Margin = new Thickness(10, 10, 10, 0)
                    },
                    tbDescription
                }
            };

            if (work == null)
            {
                a.Submit = new SimpleCommand(() =>
                {
                    SQL.Add(new DicWork()
                    {
                        Work = tbWork.Text, Price = Int32.Parse(tbPrice.Text), Description = tbDescription.Text
                    });
                    a.Close();
                });
            }
            else
            {
                tbWork.Text        = work.Work;
                tbPrice.Text       = work.Price.ToString();
                tbDescription.Text = work.Description;
                a.Submit           = new SimpleCommand(() =>
                {
                    SQL.Update(new DicWork()
                    {
                        Work = tbWork.Text, Price = Int32.Parse(tbPrice.Text), Description = tbDescription.Text
                    });
                    a.Close();
                });
            }

            a.Init();
            mainWindow.ShowAddedWindow(a);
            return(a);
        }
コード例 #4
0
        public static AddedView AddedTypeDevice(DicTypesDevices type)
        {
            var tbType = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var lblTypeE = new Label()
            {
                Content = "Необходимо заполнить Тип устройства", Foreground = Brushes.Red, Visibility = Visibility.Collapsed
            };
            var a = new AddedView
            {
                Controls = new List <Control>
                {
                    new Label()
                    {
                        Content = "Тип устройства", Margin = new Thickness(10, 10, 10, 0)
                    },
                    tbType,
                    lblTypeE
                }
            };

            if (type == null)
            {
                a.Submit = new SimpleCommand(() =>
                {
                    if (string.IsNullOrEmpty(tbType.Text.Trim()))
                    {
                        lblTypeE.Visibility = Visibility.Visible;
                        return;
                    }
                    SQL.Add(new DicTypesDevices()
                    {
                        Type = tbType.Text
                    });
                    a.Close();
                });
            }
            else
            {
                tbType.Text = type.Type;
                a.Submit    = new SimpleCommand(() =>
                {
                    if (string.IsNullOrEmpty(tbType.Text.Trim()))
                    {
                        lblTypeE.Visibility = Visibility.Visible;
                        return;
                    }
                    SQL.Update(new DicTypesDevices()
                    {
                        IdType = type.IdType, Type = tbType.Text
                    });
                    a.Close();
                });
            }

            a.Init();
            mainWindow.ShowAddedWindow(a);
            return(a);
        }
コード例 #5
0
        public static AddedView AddedWork(Works works)
        {
            var cbWork = new ComboBox()
            {
                Text        = SQL.GetWork(works.IdWork),
                Margin      = new Thickness(10, 0, 10, 10),
                ItemsSource = SQL.GetDicWork(),
                IsEditable  = true
            };
            var tbPrice = new TextBox()
            {
                Text   = works.Price.ToString(CultureInfo.InvariantCulture),
                Margin = new Thickness(10, 0, 10, 10)
            };
            var tbCount = new TextBox()
            {
                Text = works.Count.ToString(), Margin = new Thickness(10, 0, 10, 10)
            };

            var lblW = new Label()
            {
                Content = "Необходимо заполнить Работу", Foreground = Brushes.Red, Visibility = Visibility.Collapsed
            };
            var lblP = new Label()
            {
                Content = "Необходимо заполнить Цену", Foreground = Brushes.Red, Visibility = Visibility.Collapsed
            };
            var lblPInt = new Label()
            {
                Content = "Цена должна быть числом", Foreground = Brushes.Red, Visibility = Visibility.Collapsed
            };
            var lblC = new Label()
            {
                Content = "Необходимо заполнить Количество", Foreground = Brushes.Red, Visibility = Visibility.Collapsed
            };
            var lblCInt = new Label()
            {
                Content = "Количество должно быть числом", Foreground = Brushes.Red, Visibility = Visibility.Collapsed
            };
            var a = new AddedView
            {
                Controls = new List <Control>
                {
                    new Label()
                    {
                        Content = "Работа", Margin = new Thickness(10, 0, 10, 0)
                    },
                    cbWork, lblW,
                    new Label()
                    {
                        Content = "Цена", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbPrice, lblP, lblPInt,
                    new Label()
                    {
                        Content = "Количество", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbCount, lblC, lblCInt
                }
            };

            a.Submit = new SimpleCommand(() =>
            {
                int res;
                lblW.Visibility    = (string.IsNullOrEmpty(cbWork.Text.Trim())) ? Visibility.Visible : Visibility.Collapsed;
                lblP.Visibility    = (string.IsNullOrEmpty(tbPrice.Text.Trim())) ? Visibility.Visible : Visibility.Collapsed;
                lblC.Visibility    = (string.IsNullOrEmpty(tbCount.Text.Trim())) ? Visibility.Visible : Visibility.Collapsed;
                lblPInt.Visibility = (!Int32.TryParse(tbPrice.Text.Trim(), out res)) ? Visibility.Visible : Visibility.Collapsed;
                lblCInt.Visibility = (!Int32.TryParse(tbCount.Text.Trim(), out res)) ? Visibility.Visible : Visibility.Collapsed;
                if (lblW.Visibility == Visibility.Visible || lblP.Visibility == Visibility.Visible ||
                    lblC.Visibility == Visibility.Visible || lblPInt.Visibility == Visibility.Visible || lblCInt.Visibility == Visibility.Visible)
                {
                    return;
                }

                if (!SQL.GetDicWork().Contains(cbWork.Text))
                {
                    SQL.Add(new DicWork()
                    {
                        Work = cbWork.Text, Price = Int32.Parse(tbPrice.Text)
                    });
                }

                var newW = new Works()
                {
                    Id      = works.Id,
                    IdOrder = works.IdOrder,
                    IdWork  = SQL.GetIdWork(cbWork.Text),
                    Count   = Int32.Parse(tbCount.Text) == 0 ? 1 : Int32.Parse(tbCount.Text),
                    Price   = Int32.Parse(tbPrice.Text)
                };
                string message = "";
                if (works.IdWork != newW.IdWork)
                {
                    message += String.Format("Работа с {0} на {1}; ", SQL.GetWork(works.IdWork), cbWork.Text);
                }
                if (works.Price != newW.Price)
                {
                    message += String.Format("Цена с {0} на {1};", works.Price, newW.Price);
                }
                if (works.Count != newW.Count)
                {
                    message += String.Format("Количество с {0} на {1}; ", works.Count, newW.Count);
                }

                SQL.AddHistory(works.IdOrder, String.Format("Работа {1} изменена: {0}", message, SQL.GetWork(works.IdWork)));
                SQL.Update(newW);
                a.Close();
            });

            a.Init();
            mainWindow.ShowAddedWindow(a);
            return(a);
        }
コード例 #6
0
        public static AddedView AddedMalfunction(DicMalfunction malfunction)
        {
            var tbMalfunction = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var lblM = new Label()
            {
                Content = "Необходимо заполнить Неисправность", Foreground = Brushes.Red, Visibility = Visibility.Collapsed
            };
            var a = new AddedView
            {
                Controls = new List <Control>
                {
                    new Label()
                    {
                        Content = "Неисправность", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbMalfunction
                }
            };

            if (malfunction == null)
            {
                a.Submit = new SimpleCommand(() =>
                {
                    if (string.IsNullOrEmpty(tbMalfunction.Text.Trim()))
                    {
                        lblM.Visibility = Visibility.Visible;
                        return;
                    }
                    SQL.Add(new DicMalfunction()
                    {
                        Malfunction = tbMalfunction.Text
                    });
                    a.Close();
                });
            }
            else
            {
                tbMalfunction.Text = malfunction.Malfunction;

                a.Submit = new SimpleCommand(() =>
                {
                    if (string.IsNullOrEmpty(tbMalfunction.Text.Trim()))
                    {
                        lblM.Visibility = Visibility.Visible;
                        return;
                    }
                    SQL.Update(new DicMalfunction()
                    {
                        IdMalfunction = malfunction.IdMalfunction,
                        Malfunction   = tbMalfunction.Text
                    });
                    a.Close();
                });
            }

            a.Init();
            mainWindow.ShowAddedWindow(a);
            return(a);
        }
コード例 #7
0
        public static AddedView AddedAppearance(DicAppearance appearance)
        {
            var tbAppearance = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var lblA = new Label()
            {
                Content = "Необходимо заполнить Внешний вид", Foreground = Brushes.Red, Visibility = Visibility.Collapsed
            };
            var a = new AddedView
            {
                Controls = new List <Control>
                {
                    new Label()
                    {
                        Content = "Внешний вид", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbAppearance,
                    lblA
                }
            };

            if (appearance == null)
            {
                a.Submit = new SimpleCommand(() =>
                {
                    if (string.IsNullOrEmpty(tbAppearance.Text.Trim()))
                    {
                        lblA.Visibility = Visibility.Visible;
                        return;
                    }
                    SQL.Add(new DicAppearance()
                    {
                        Appearance = tbAppearance.Text
                    });
                    a.Close();
                });
            }
            else
            {
                tbAppearance.Text = appearance.Appearance;

                a.Submit = new SimpleCommand(() =>
                {
                    if (string.IsNullOrEmpty(tbAppearance.Text.Trim()))
                    {
                        lblA.Visibility = Visibility.Visible;
                        return;
                    }
                    SQL.Update(new DicAppearance()
                    {
                        IdAppearance = appearance.IdAppearance,
                        Appearance   = tbAppearance.Text
                    });
                    a.Close();
                });
            }

            a.Init();
            mainWindow.ShowAddedWindow(a);
            return(a);
        }
コード例 #8
0
        public static AddedView AddedModel(DicModel model)
        {
            var cbFabricator = new ComboBox()
            {
                Margin = new Thickness(10, 0, 10, 10), ItemsSource = SQL.GetFabricator().Select(s => s.Fabricator)
            };
            var lblF = new Label()
            {
                Content = "Необходимо заполнить Производителя", Foreground = Brushes.Red, Visibility = Visibility.Collapsed
            };
            var tbModel = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var lblM = new Label()
            {
                Content = "Необходимо заполнить Модель", Foreground = Brushes.Red, Visibility = Visibility.Collapsed
            };
            var a = new AddedView
            {
                Controls = new List <Control>
                {
                    new Label()
                    {
                        Content = "Производитель", Margin = new Thickness(10, 0, 10, 0)
                    },
                    cbFabricator,
                    lblF,
                    new Label()
                    {
                        Content = "Модель", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbModel,
                    lblM
                }
            };

            if (model == null)
            {
                a.Submit = new SimpleCommand(() =>
                {
                    if (string.IsNullOrEmpty(cbFabricator.Text.Trim()) || (string.IsNullOrEmpty(tbModel.Text.Trim())))
                    {
                        lblF.Visibility = (string.IsNullOrEmpty(cbFabricator.Text.Trim())) ? Visibility.Visible : Visibility.Collapsed;
                        lblM.Visibility = (string.IsNullOrEmpty(tbModel.Text.Trim())) ? Visibility.Visible : Visibility.Collapsed;
                        return;
                    }
                    SQL.Add(new DicModel()
                    {
                        IdFabricator = SQL.GetIdFabricator(cbFabricator.SelectedItem.ToString()),
                        Model        = tbModel.Text
                    });
                    a.Close();
                });
            }
            else
            {
                tbModel.Text = model.Model;
                cbFabricator.SelectedValue = SQL.GetFabricator(model.IdFabricator);

                a.Submit = new SimpleCommand(() =>
                {
                    if (string.IsNullOrEmpty(cbFabricator.Text.Trim()) || (string.IsNullOrEmpty(tbModel.Text.Trim())))
                    {
                        lblF.Visibility = (string.IsNullOrEmpty(cbFabricator.Text.Trim())) ? Visibility.Visible : Visibility.Collapsed;
                        lblM.Visibility = (string.IsNullOrEmpty(tbModel.Text.Trim())) ? Visibility.Visible : Visibility.Collapsed;
                        return;
                    }
                    SQL.Update(new DicModel()
                    {
                        IdModel      = model.IdModel,
                        IdFabricator = SQL.GetIdFabricator(cbFabricator.SelectedItem.ToString()),
                        Model        = tbModel.Text
                    });
                    a.Close();
                });
            }

            a.Init();
            mainWindow.ShowAddedWindow(a);
            return(a);
        }
コード例 #9
0
        public static AddedView AddedEquipment(DicEquipment equipment)
        {
            var cbType = new ComboBox()
            {
                Margin = new Thickness(10, 0, 10, 10), ItemsSource = SQL.GetTypesDevices().Select(s => s.Type)
            };
            var lblT = new Label()
            {
                Content = "Необходимо заполнить Тип устройства", Foreground = Brushes.Red, Visibility = Visibility.Collapsed
            };
            var tbEquip = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var lblE = new Label()
            {
                Content = "Необходимо заполнить Комплектацию", Foreground = Brushes.Red, Visibility = Visibility.Collapsed
            };
            var a = new AddedView
            {
                Controls = new List <Control>
                {
                    new Label()
                    {
                        Content = "Тип устройства", Margin = new Thickness(10, 0, 10, 0)
                    },
                    cbType,
                    lblT,
                    new Label()
                    {
                        Content = "Комплектация", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbEquip,
                    lblE
                }
            };

            if (equipment == null)
            {
                a.Submit = new SimpleCommand(() =>
                {
                    if (string.IsNullOrEmpty(cbType.Text.Trim()) || (string.IsNullOrEmpty(tbEquip.Text.Trim())))
                    {
                        lblT.Visibility = (string.IsNullOrEmpty(cbType.Text.Trim())) ? Visibility.Visible : Visibility.Collapsed;
                        lblE.Visibility = (string.IsNullOrEmpty(tbEquip.Text.Trim())) ? Visibility.Visible : Visibility.Collapsed;
                        return;
                    }
                    SQL.Add(new DicEquipment()
                    {
                        IdTypeDevices = SQL.GetIdTypeDevice(cbType.SelectedItem.ToString()),
                        Equipment     = tbEquip.Text
                    });
                    a.Close();
                });
            }
            else
            {
                tbEquip.Text         = equipment.Equipment;
                cbType.SelectedValue = SQL.GetTypesDevices(equipment.IdTypeDevices);

                a.Submit = new SimpleCommand(() =>
                {
                    if (string.IsNullOrEmpty(cbType.Text.Trim()) || (string.IsNullOrEmpty(tbEquip.Text.Trim())))
                    {
                        lblT.Visibility = (string.IsNullOrEmpty(cbType.Text.Trim())) ? Visibility.Visible : Visibility.Collapsed;
                        lblE.Visibility = (string.IsNullOrEmpty(tbEquip.Text.Trim())) ? Visibility.Visible : Visibility.Collapsed;
                        return;
                    }
                    SQL.Update(new DicEquipment()
                    {
                        IdEquipment   = equipment.IdEquipment,
                        IdTypeDevices = SQL.GetIdTypeDevice(cbType.SelectedItem.ToString()),
                        Equipment     = tbEquip.Text
                    });
                    a.Close();
                });
            }
            a.Init();
            mainWindow.ShowAddedWindow(a);
            return(a);
        }
コード例 #10
0
        public DictionariesViewModel()
        {
            var fab = SQL.GetFabricator(); fab.Add(new DicFabricator()
            {
                Fabricator = "", IdFabricator = 0
            }); fab.Add(new DicFabricator()
            {
                Fabricator = ""
            });
            var mod = SQL.GetModel();

            var cli    = SQL.GetClientses();
            var states = SQL.GetState();

            OrdersEntries = new CollectionView(SQL.GetOrders().Select(o =>
            {
                var client = cli.FirstOrDefault(c => c.IdClient == o.IdClient);
                return(new Order()
                {
                    Id = o.IdOrder,
                    State = states.First(f => f.Id == o.IdState).State,
                    Number = o.Number ?? "",
                    NameClient = client != null ? client.Name : "",
                    PhoneClient = client != null ? client.Phone : "",
                    Model =
                        String.Format("{0} {1}",
                                      fab.First(f => f.IdFabricator == o.IdFabricator).Fabricator,
                                      mod.First(m => m.IdModel == o.IdModel).Model),
                    DateReceipt = o.DateReceipt.Date,
                    AvailabilityDate = o.AvailabilityDate.Date,
                    NameExecutor = SQL.GetExecutors(o.IdExecutor),
                    EditOrder = new SimpleCommand((_) => ShowWin.ShowWork(o))
                });
            }));

            #region Тип устройств

            TypesDevicesEntries = new CollectionView(SQL.GetTypesDevices());

            AddTypeDevices = new SimpleCommand((edit) =>
            {
                AddedView a = bool.Parse(edit.ToString()) ? ShowWin.AddedTypeDevice(TypesDevicesEntries.CurrentItem as DicTypesDevices) : ShowWin.AddedTypeDevice(null);
                a.OnClose  += () => { TypesDevicesEntries = new CollectionView(SQL.GetTypesDevices()); TypesDevicesEntries.Refresh(); };
            });

            DeleteTypeDevices = new SimpleCommand((_) =>
            {
                var res = MessageBox.Show("Вы действительно хотите удалить тип устройств", "Удалить тип устройств", MessageBoxButton.OKCancel,
                                          MessageBoxImage.Warning);

                if (res == MessageBoxResult.OK)
                {
                    SQL.Delete(TypesDevicesEntries.CurrentItem as DicTypesDevices);
                    TypesDevicesEntries = new CollectionView(SQL.GetTypesDevices());
                }
            });

            #endregion

            #region Производители

            FabricatorEntries = new CollectionView(SQL.GetFabricator());

            AddFabricator = new SimpleCommand((edit) =>
            {
                AddedView a = bool.Parse(edit.ToString()) ? ShowWin.AddedFabricator(FabricatorEntries.CurrentItem as DicFabricator) : ShowWin.AddedFabricator(null);
                a.OnClose  += () => FabricatorEntries = new CollectionView(SQL.GetFabricator());
            });

            DeleteFabricator = new SimpleCommand((_) =>
            {
                var res = MessageBox.Show("Вы действительно хотите удалить производителя", "Удалить производителя", MessageBoxButton.OKCancel,
                                          MessageBoxImage.Warning);

                if (res == MessageBoxResult.OK)
                {
                    SQL.Delete(TypesDevicesEntries.CurrentItem as DicFabricator);
                    FabricatorEntries = new CollectionView(SQL.GetFabricator());
                }
            });

            #endregion

            #region Модель

            ModelEntries = new CollectionView(SQL.GetModel().OrderBy(o => o.IdFabricator));

            AddModel = new SimpleCommand((edit) =>
            {
                var a      = bool.Parse(edit.ToString()) ? ShowWin.AddedModel(ModelEntries.CurrentItem as DicModel) : ShowWin.AddedModel(null);
                a.OnClose += () => ModelEntries = new CollectionView(SQL.GetModel().OrderBy(o => o.IdFabricator));
            });

            DeleteModel = new SimpleCommand((_) =>
            {
                var res = MessageBox.Show("Вы действительно хотите удалить модель", "Удалить модель", MessageBoxButton.OKCancel,
                                          MessageBoxImage.Warning);

                if (res == MessageBoxResult.OK)
                {
                    SQL.Delete(ModelEntries.CurrentItem as DicModel);
                    ModelEntries = new CollectionView(SQL.GetModel().OrderBy(o => o.IdFabricator));
                }
            });

            #endregion

            #region  аботы

            WorkEntries = new CollectionView(SQL.GetAllDicWork());

            AddWork = new SimpleCommand((edit) =>
            {
                var a      = bool.Parse(edit.ToString()) ? ShowWin.AddedDicWork(WorkEntries.CurrentItem as DicWork) : ShowWin.AddedDicWork(null);
                a.OnClose += () => WorkEntries = new CollectionView(SQL.GetAllDicWork());
            });

            DeleteWork = new SimpleCommand((_) =>
            {
                var res = MessageBox.Show("Вы действительно хотите удалить работу", "Удалить работу", MessageBoxButton.OKCancel,
                                          MessageBoxImage.Warning);

                if (res == MessageBoxResult.OK)
                {
                    SQL.Delete(WorkEntries.CurrentItem as DicWork);
                    WorkEntries = new CollectionView(SQL.GetAllDicWork());
                }
            });

            #endregion

            #region Неисправность

            MalfunctionEntries = new CollectionView(SQL.GetMalfunction());

            AddMalfunction = new SimpleCommand((edit) =>
            {
                var a      = bool.Parse(edit.ToString()) ? ShowWin.AddedMalfunction(MalfunctionEntries.CurrentItem as DicMalfunction) : ShowWin.AddedMalfunction(null);
                a.OnClose += () => MalfunctionEntries = new CollectionView(SQL.GetMalfunction());
            });

            DeleteMalfunction = new SimpleCommand((_) =>
            {
                var res = MessageBox.Show("Вы действительно хотите удалить неисправность", "Удалить неисправность", MessageBoxButton.OKCancel,
                                          MessageBoxImage.Warning);

                if (res == MessageBoxResult.OK)
                {
                    SQL.Delete(MalfunctionEntries.CurrentItem as DicMalfunction);
                    MalfunctionEntries = new CollectionView(SQL.GetMalfunction());
                }
            });

            #endregion

            #region Состояние

            AppearanceEntries = new CollectionView(SQL.GetAppearance());

            AddAppearance = new SimpleCommand((edit) =>
            {
                var a      = bool.Parse(edit.ToString()) ? ShowWin.AddedAppearance(AppearanceEntries.CurrentItem as DicAppearance) : ShowWin.AddedAppearance(null);
                a.OnClose += () => AppearanceEntries = new CollectionView(SQL.GetAppearance());
            });

            DeleteAppearance = new SimpleCommand((_) =>
            {
                var res = MessageBox.Show("Вы действительно хотите удалить состояние", "Удалить состояние", MessageBoxButton.OKCancel,
                                          MessageBoxImage.Warning);

                if (res == MessageBoxResult.OK)
                {
                    SQL.Delete(AppearanceEntries.CurrentItem as DicAppearance);
                    AppearanceEntries = new CollectionView(SQL.GetAppearance());
                }
            });
            #endregion

            #region Комплектация

            EquipmentEntries = new CollectionView(SQL.GetEquipment());

            AddEquipment = new SimpleCommand((edit) =>
            {
                var a      = bool.Parse(edit.ToString()) ? ShowWin.AddedEquipment(EquipmentEntries.CurrentItem as DicEquipment) : ShowWin.AddedEquipment(null);
                a.OnClose += () => EquipmentEntries = new CollectionView(SQL.GetEquipment());
            });
            DeleteEquipment = new SimpleCommand((_) =>
            {
                var res = MessageBox.Show("Вы действительно хотите удалить комплектацию", "Удалить комплектацию", MessageBoxButton.OKCancel,
                                          MessageBoxImage.Warning);

                if (res == MessageBoxResult.OK)
                {
                    SQL.Delete(EquipmentEntries.CurrentItem as DicEquipment);
                    EquipmentEntries = new CollectionView(SQL.GetEquipment());
                }
            });
            #endregion

            #region Исполнитель

            ExecutorsEntries = new CollectionView(SQL.GetExecutors());

            AddExecutors = new SimpleCommand((edit) =>
            {
                var a      = bool.Parse(edit.ToString()) ? ShowWin.AddedExecutors(ExecutorsEntries.CurrentItem as Executors) : ShowWin.AddedExecutors(null);
                a.OnClose += () => ExecutorsEntries = new CollectionView(SQL.GetExecutors());
            });
            DeleteExecutors = new SimpleCommand((_) =>
            {
                var res = MessageBox.Show("Вы действительно хотите удалить исполнителя", "Удалить исполнителя", MessageBoxButton.OKCancel,
                                          MessageBoxImage.Warning);

                if (res == MessageBoxResult.OK)
                {
                    SQL.Delete(ExecutorsEntries.CurrentItem as Executors);
                    ExecutorsEntries = new CollectionView(SQL.GetExecutors());
                }
            });
            #endregion
        }
コード例 #11
0
        public static AddedView AddedProvider(ProviderModel provider = null, ICommand sumbit = null)
        {
            var tbName = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var lblNameE = new Label()
            {
                Content    = "Необходимо заполнить Имя поставщика",
                Foreground = Brushes.Red,
                Visibility = Visibility.Collapsed
            };
            var tbAddress = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var tbEmail = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var tbPhone = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var tbNote = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var a = new AddedView
            {
                Controls = new List <Control>
                {
                    new Label()
                    {
                        Content = "Имя", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbName,
                    lblNameE,
                    new Label()
                    {
                        Content = "Адрес", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbAddress,
                    new Label()
                    {
                        Content = "E-mail", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbEmail,
                    new Label()
                    {
                        Content = "Телефон", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbPhone,
                    new Label()
                    {
                        Content = "Примечание", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbNote
                }
            };

            if (provider != null)
            {
                tbName.Text    = provider.Name;
                tbAddress.Text = provider.Address;
                tbEmail.Text   = provider.Email;
                tbPhone.Text   = provider.Phone;
                tbNote.Text    = provider.Note;
            }

            a.Submit = new SimpleCommand(() =>
            {
                if (string.IsNullOrEmpty(tbName.Text.Trim()))
                {
                    lblNameE.Visibility = Visibility.Visible;
                    return;
                }
                Services.Providers.Save(new ProviderModel()
                {
                    Name    = tbName.Text,
                    Address = tbAddress.Text,
                    Email   = tbEmail.Text,
                    Phone   = tbPhone.Text,
                    Note    = tbNote.Text
                });
                sumbit?.Execute(null);
                a.Close();
            });

            a.Init();
            mainWindow.ShowAddedWindow(a);
            return(a);
        }
コード例 #12
0
        public static AddedView AddedProduct(ProductModel product = null, ICommand sumbit = null)
        {
            var tbName = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var lblNameE = new Label()
            {
                Content    = "Необходимо заполнить Наименование товара",
                Foreground = Brushes.Red,
                Visibility = Visibility.Collapsed
            };
            var tbDescription = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var tbCode = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var tbArticle = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var tbMinCount = new TextBox()
            {
                Margin = new Thickness(10, 0, 10, 10)
            };
            var lblMinCountE = new Label()
            {
                Content    = "Должно быть числом",
                Foreground = Brushes.Red,
                Visibility = Visibility.Collapsed
            };
            var a = new AddedView
            {
                Controls = new List <Control>
                {
                    new Label()
                    {
                        Content = "Наименование", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbName,
                    lblNameE,
                    new Label()
                    {
                        Content = "Описание", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbDescription,
                    new Label()
                    {
                        Content = "Код", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbCode,
                    new Label()
                    {
                        Content = "Артикул", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbArticle,
                    new Label()
                    {
                        Content = "Минимальный остаток", Margin = new Thickness(10, 0, 10, 0)
                    },
                    tbMinCount
                }
            };

            if (product == null)
            {
                tbMinCount.Text = "0";
            }
            else
            {
                tbName.Text        = product.ProductName;
                tbDescription.Text = product.Description;
                tbCode.Text        = product.Code;
                tbArticle.Text     = product.Article;
                tbMinCount.Text    = product.MinCount.ToString();
            }

            a.Submit = new SimpleCommand(() =>
            {
                if (string.IsNullOrEmpty(tbName.Text.Trim()))
                {
                    lblNameE.Visibility = Visibility.Visible;
                    return;
                }
                int res;
                if (!int.TryParse(tbMinCount.Text.Trim(), out res))
                {
                    lblMinCountE.Visibility = Visibility.Visible;
                    return;
                }
                Services.Products.Save(new ProductModel()
                {
                    ProductName = tbName.Text,
                    Description = tbDescription.Text,
                    Code        = tbCode.Text,
                    Article     = tbArticle.Text,
                    MinCount    = int.Parse(tbMinCount.Text),
                    Count       = 0
                });
                sumbit?.Execute(null);
                a.Close();
            });

            a.Init();
            mainWindow.ShowAddedWindow(a);
            return(a);
        }