private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            if (_CurrentInventory.id == 0)
            {
                AccountingEquipmentEntities.GetContext().Inventory.Add(_CurrentInventory);
            }

            try
            {
                AccountingEquipmentEntities.GetContext().SaveChanges();
                MessageBox.Show("Информация сохранена");
                FrameManager.MainFrame.GoBack();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Пример #2
0
 public EditNewEquipmentPage()
 {
     InitializeComponent();
     DataContext = _currentEquipment;
     ComboManufacturer.ItemsSource = AccountingEquipmentEntities.GetContext().Manufacturer.ToList();
     ComboNomenclature.ItemsSource = AccountingEquipmentEntities.GetContext().Nomenclature.ToList();
 }
Пример #3
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors  = new StringBuilder();
            string        Current = _currentEquipmentCard.Equipment.Model.Trim(new Char[] { ',', '*', '.', '/', '#', '@', '!', '"', '№', '$', ';'
                                                                                            , '%', '^', ':', '&', '?', '(', ')', '-', '+', '=', '_', '~', '`', '<', '>', '|', '{', '}', '[', ']' });

            _currentEquipmentCard.Equipment.Model = Current;
            Current = _currentEquipmentCard.Equipment.Manufacturer.ManufacturerName.Trim(new Char[] { ',', '*', '.', '/', '#', '@', '!', '"', '№', '$', ';'
                                                                                                      , '%', '^', ':', '&', '?', '(', ')', '-', '+', '=', '_', '~', '`', '<', '>', '|', '{', '}', '[', ']' });
            _currentEquipmentCard.Equipment.Manufacturer.ManufacturerName = Current;
            Current = _currentEquipmentCard.InventNumber.Trim(new Char[] { ',', '*', '.', '/', '#', '@', '!', '"', '№', '$', ';'
                                                                           , '%', '^', ':', '&', '?', '(', ')', '-', '+', '=', '_', '~', '`', '<', '>', '|', '{', '}', '[', ']' });
            _currentEquipmentCard.InventNumber = Current;
            Current = _currentEquipmentCard.InventNumber.Trim(new Char[] { ',', '*', '.', '/', '#', '@', '!', '"', '№', '$', ';'
                                                                           , '%', '^', ':', '&', '?', '(', ')', '-', '+', '=', '_', '~', '`', '<', '>', '|', '{', '}', '[', ']' });
            _currentEquipmentCard.InventNumber = Current;
            if (string.IsNullOrWhiteSpace(_currentEquipmentCard.Equipment.Model))
            {
                errors.AppendLine("Укажите модель оборудования");
            }
            if (string.IsNullOrWhiteSpace(_currentEquipmentCard.InventNumber))
            {
                errors.AppendLine("Укажите инвентарный номер");
            }
            if (string.IsNullOrWhiteSpace(_currentEquipmentCard.Equipment.Manufacturer.ManufacturerName))
            {
                errors.AppendLine("Укажите название производителя");
            }
            if (_currentEquipmentCard.DateOfDelivery == null)
            {
                errors.AppendLine("Укажите дату получения оборудования ");
            }
            if (_currentEquipmentCard.Equipment.Nomenclature.NameOfNomenclature == null)
            {
                errors.AppendLine("Выберите номенклатуру ");
            }


            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            if (_currentEquipmentCard.id == 0)
            {
                AccountingEquipmentEntities.GetContext().EquipmentCard.Add(_currentEquipmentCard);
            }

            //try
            //{
            AccountingEquipmentEntities.GetContext().SaveChanges();
            MessageBox.Show("Информация сохранена");
            FrameManager.MainFrame.GoBack();
            //}

            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message.ToString());
            //}
        }
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(_CurrentWorker.FirstName))
            {
                errors.AppendLine("Введите Фамилию");
            }
            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            if (_CurrentWorker.id == 0)
            {
                AccountingEquipmentEntities.GetContext().Worker.Add(_CurrentWorker);
            }
            //try
            //{
            AccountingEquipmentEntities.GetContext().SaveChanges();
            MessageBox.Show("Информация сохранена");
            FrameManager.MainFrame.GoBack();
            //}

            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message.ToString());
            //}
        }
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (DPDeliver == null)
            {
                errors.AppendLine("Укажите дату выдачи в ремонт оборудования ");
            }
            if (DPBack == null)
            {
                errors.AppendLine("Укажите дату получения оборудования ");
            }
            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            if (_CurrentBreakdown.id == 0)
            {
                AccountingEquipmentEntities.GetContext().Repair.Add(_CurrentBreakdown);
            }

            try
            {
                AccountingEquipmentEntities.GetContext().SaveChanges();
                MessageBox.Show("Информация сохранена");
                FrameManager.MainFrame.GoBack();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (ComboTypeRoom.SelectedItem == null)
            {
                errors.AppendLine("Укажите тип помещения");
            }
            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            if (_CurrentRoom.id == 0)
            {
                AccountingEquipmentEntities.GetContext().Room.Add(_CurrentRoom);
            }

            try
            {
                AccountingEquipmentEntities.GetContext().SaveChanges();
                MessageBox.Show("Информация сохранена");
                FrameManager.MainFrame.GoBack();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (ComboTypeNomenclture.SelectedItem == null)
            {
                errors.AppendLine("Укажите вид номенклатуры");
            }
            if (string.IsNullOrWhiteSpace(_currentnomenclature.NameOfNomenclature))
            {
                errors.AppendLine("введите номенклатуру");
            }
            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            if (_currentnomenclature.id == 0)
            {
                AccountingEquipmentEntities.GetContext().Nomenclature.Add(_currentnomenclature);
            }

            try
            {
                AccountingEquipmentEntities.GetContext().SaveChanges();
                MessageBox.Show("Информация сохранена");
                FrameManager.MainFrame.GoBack();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
 private void Page_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (Visibility == Visibility.Visible)
     {
         AccountingEquipmentEntities.GetContext().ChangeTracker.Entries().ToList().ForEach(p => p.Reload());
         DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Worker.ToList();
     }
 }
Пример #9
0
 public RepairPage()
 {
     InitializeComponent();
     Manufacturers = AccountingEquipmentEntities.GetContext().Manufacturer.ToList();
     Manufacturers.Insert(0, new Manufacturer {
         ManufacturerName = "All"
     });
     ManufacturerCmb.ItemsSource = Manufacturers;
 }
 public EditNomenclaturePage(Nomenclature SelectedNomeclature)
 {
     InitializeComponent();
     if (SelectedNomeclature != null)
     {
         _currentnomenclature = SelectedNomeclature;
     }
     DataContext = _currentnomenclature;
     ComboTypeNomenclture.ItemsSource = AccountingEquipmentEntities.GetContext().TypeOfNomenclature.ToList();
 }
 public WorkerPage()
 {
     InitializeComponent();
     statusOfs = AccountingEquipmentEntities.GetContext().StatusOfWorker.ToList();
     statusOfs.Insert(0, new StatusOfWorker {
         NameOfStatus = "Все работники"
     });
     FilteCmb.ItemsSource = statusOfs;
     DataContext          = _CurrentWorker;
 }
        public EditRoomPage(Room SelectedRoom)
        {
            InitializeComponent(); if (SelectedRoom != null)
            {
                _CurrentRoom = SelectedRoom;
            }
            DataContext = _CurrentRoom;

            ComboTypeRoom.ItemsSource = AccountingEquipmentEntities.GetContext().TypeOfRoom.ToList();
        }
 public EditWorkerPage(Worker SeletedWorker)
 {
     InitializeComponent(); if (SeletedWorker != null)
     {
         _CurrentWorker = SeletedWorker;
     }
     DataContext               = _CurrentWorker;
     ComboGender.ItemsSource   = AccountingEquipmentEntities.GetContext().Gender.ToList();
     ComboPosition.ItemsSource = AccountingEquipmentEntities.GetContext().Position.ToList();
     ComboStatus.ItemsSource   = AccountingEquipmentEntities.GetContext().StatusOfWorker.ToList();
 }
Пример #14
0
 private void BtnSave_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         AccountingEquipmentEntities.GetContext().Equipment.Add(_currentEquipment);
         AccountingEquipmentEntities.GetContext().SaveChanges();
         FrameManager.MainFrame.GoBack();
     }
     catch (Exception ex)
     {
         MessageBox.Show("" + ex);
     }
 }
        public InventarizationPage()
        {
            InitializeComponent();
            List <StatusOfInventory> statusOfs = new List <StatusOfInventory>();

            statusOfs = AccountingEquipmentEntities.GetContext().StatusOfInventory.ToList();
            statusOfs.Insert(0, new StatusOfInventory {
                InventoryStatus = "Весь список"
            });
            FilteCmb.ItemsSource    = statusOfs;
            DataContext             = _CurrentInventory;
            DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Inventory.ToList();
        }
Пример #16
0
        public EditEquipmentPage(EquipmentCard SelectedEQC)
        {
            InitializeComponent();
            if (SelectedEQC != null)
            {
                _currentEquipmentCard = SelectedEQC;
            }

            DataContext = _currentEquipmentCard;
            ComboNomenclature.ItemsSource = AccountingEquipmentEntities.GetContext().Nomenclature.ToList();
            ComboManufacturer.ItemsSource = AccountingEquipmentEntities.GetContext().Manufacturer.ToList();
            ComboModel.ItemsSource        = AccountingEquipmentEntities.GetContext().Equipment.ToList();
        }
 public EditRepairPage(Repair SelectedBRKDWN)
 {
     InitializeComponent();
     if (SelectedBRKDWN != null)
     {
         _CurrentBreakdown = SelectedBRKDWN;
     }
     DataContext = _CurrentBreakdown;
     ComboBreakdown.ItemsSource    = AccountingEquipmentEntities.GetContext().Breakdown.ToList();
     InventNumber.ItemsSource      = AccountingEquipmentEntities.GetContext().EquipmentCard.ToList();
     ComboModel.ItemsSource        = AccountingEquipmentEntities.GetContext().Equipment.ToList();
     ComboServiceName.ItemsSource  = AccountingEquipmentEntities.GetContext().ServiceOrganization.ToList();
     ComboStatusRepair.ItemsSource = AccountingEquipmentEntities.GetContext().StatusEquipInRepair.ToList();
     ComboFIO.ItemsSource          = AccountingEquipmentEntities.GetContext().Worker.ToList();
 }
 private void FilteCmb_DropDownClosed(object sender, EventArgs e)
 {
     if (FilteCmb.SelectedIndex == 0)
     {
         DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Worker.ToList();
     }
     else if (SearchTxt.Text == "")
     {
         DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.StatusOfWorker.NameOfStatus == FilteCmb.Text).ToList();
     }
     else
     {
         DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.Position.PostionName.StartsWith(SearchTxt.Text) && w.StatusOfWorker.NameOfStatus == FilteCmb.Text).ToList();
     }
 }
 public EditInvantarizationPage(Inventory SelectedInventory)
 {
     InitializeComponent();
     if (SelectedInventory != null)
     {
         _CurrentInventory = SelectedInventory;
     }
     DataContext                         = _CurrentInventory;
     ComboInvent.ItemsSource             = AccountingEquipmentEntities.GetContext().EquipmentCard.ToList();
     ComboManufacturerName.ItemsSource   = AccountingEquipmentEntities.GetContext().Manufacturer.ToList();
     ComboModel.ItemsSource              = AccountingEquipmentEntities.GetContext().Equipment.ToList();
     ComboNameOfNomenclature.ItemsSource = AccountingEquipmentEntities.GetContext().Nomenclature.ToList();
     ComboRoom.ItemsSource               = AccountingEquipmentEntities.GetContext().Room.ToList();
     ComboStatus.ItemsSource             = AccountingEquipmentEntities.GetContext().StatusOfInventory.ToList();
     ComboFname.ItemsSource              = AccountingEquipmentEntities.GetContext().Worker.ToList();
 }
 private void SearchTxt_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (SearchTxt.Text == "")
     {
         DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Inventory.ToList();
     }
     else if (FilteCmb.SelectedIndex == 0)
     {
         DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Inventory.Where(w => w.EquipmentCard.Equipment.Nomenclature.NameOfNomenclature.StartsWith(SearchTxt.Text)).ToList();
     }
     else
     {
         DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().
                                   Inventory.Where(w => w.EquipmentCard.Equipment.Nomenclature.NameOfNomenclature.StartsWith(SearchTxt.Text) && w.StatusOfInventory.InventoryStatus == FilteCmb.Text).ToList();
     }
 }
Пример #21
0
        private void BtnReturn_Click(object sender, RoutedEventArgs e)
        {
            var TestCaseUse = DgridMyPage.SelectedItems.Cast <Repair>().FirstOrDefault() as Repair;

            TestCaseUse.FK_StatusEquipInRepair_id = 8;
            try
            {
                AccountingEquipmentEntities.GetContext().SaveChanges();
                MessageBox.Show("Возврат офомлен");
                DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Repair.ToList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Пример #22
0
 private void ManufacturerCmb_DropDownClosed(object sender, EventArgs e)
 {
     if (ManufacturerCmb.SelectedIndex == 0)
     {
         DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Repair.ToList();
     }
     else if (SrchTxt.Text == "")
     {
         DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Repair.Where(w => w.EquipmentCard.Equipment.Manufacturer.ManufacturerName == ManufacturerCmb.Text).ToList();
     }
     else
     {
         DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Repair.
                                   Where(w => w.EquipmentCard.Equipment.Manufacturer.ManufacturerName == ManufacturerCmb.Text && w.EquipmentCard.SerialNumber.StartsWith(SrchTxt.Text)).ToList();
     }
 }
Пример #23
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var idCheck      = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.Login.Equals(LoginTextBX.Text) && w.Password.Equals(PasswordTextBX.Text)).Select(s => s.id).FirstOrDefault();
            var idChecklogin = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.Login.Equals(LoginTextBX.Text)).Select(s => s.id).FirstOrDefault();

            if (LoginTextBX.Text == "" && PasswordTextBX.Text == "")
            {
                Fail1.Visibility = Visibility.Visible;
                Fail1.Content    = "Введите логин";
                Fail2.Visibility = Visibility.Visible;
                Fail2.Content    = "Введите пароль";
            }
            else if (LoginTextBX.Text == "")
            {
                Fail1.Visibility = Visibility.Visible;
                Fail1.Content    = "Введите логин";
            }
            else if (PasswordTextBX.Text == "")
            {
                Fail2.Content    = "Введите пароль";
                Fail2.Visibility = Visibility.Visible;
            }
            else
            {
                if (idChecklogin == 0)
                {
                    GlobarFail.Visibility = Visibility.Visible;
                    GlobarFail.HorizontalContentAlignment = HorizontalAlignment.Center;
                    GlobarFail.Content = "Пользователя с такими данными не существует!";
                }
                else
                {
                    if (idCheck == 0)
                    {
                        GlobarFail.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        string Code = Class.SenderCode();
                        Class.senderMAil(AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == idCheck).Select(s => s.EmailOfWorker).FirstOrDefault(), Code);
                        SenderMail.IntId = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == idCheck).Select(s => s.id).FirstOrDefault();
                        FrameManager.LogFrame.Navigate(new AutherizationPage(Code));
                    }
                }
            }
        }
Пример #24
0
 private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     System.Windows.Controls.TextBox txt = sender as System.Windows.Controls.TextBox;
     if (txt.Text == "")
     {
         DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Repair.ToList();
     }
     else if (ManufacturerCmb.SelectedIndex == 0)
     {
         DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Repair.Where(w => w.EquipmentCard.SerialNumber.StartsWith(txt.Text)).ToList();
     }
     else
     {
         DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Repair.
                                   Where(w => w.EquipmentCard.Equipment.Manufacturer.ManufacturerName == ManufacturerCmb.Text && w.EquipmentCard.SerialNumber.StartsWith(SrchTxt.Text)).ToList();
     }
 }
        private void BtnDel_Click(object sender, RoutedEventArgs e)
        {
            var EquipmentForRemoving = DgridMyPage.SelectedItems.Cast <Worker>().ToList();

            if (MessageBox.Show($"Вы точно хотите удалить следующие {EquipmentForRemoving.Count} элементов?", "Внимание",
                                MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                try
                {
                    AccountingEquipmentEntities.GetContext().Worker.RemoveRange(EquipmentForRemoving);
                    AccountingEquipmentEntities.GetContext().SaveChanges();
                    MessageBox.Show("Данные удалены");
                    DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Worker.ToList();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }
Пример #26
0
        private void BtnExcel_Copy_Click(object sender, RoutedEventArgs e)
        {
            if (Cmb.Text == "1")
            {
                switchNumber = 1;
            }
            if (Cmb.Text == "2")
            {
                switchNumber = 2;
            }
            if (Cmb.Text == "3")
            {
                switchNumber = 3;
            }
            if (Cmb.Text == "4")
            {
                switchNumber = 4;
            }
            if (Cmb.Text == "5")
            {
                switchNumber = 5;
            }
            switch (switchNumber)
            {
            case 1:
                Word.Application word = new Microsoft.Office.Interop.Word.Application();
                Word.Document    doc  = word.Documents.Open(Environment.CurrentDirectory + @"\Akt_utilizatsii_oborudovania.docx");
                var TestCaseUse       = DgridMyPage.SelectedItems.Cast <Repair>().FirstOrDefault() as Repair;
                var XHuman1           = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 1).Select(s => s.FirstName + " " + s.MiddleName.Substring(0, 1) + " " + s.LastName.Substring(0, 1)).FirstOrDefault();
                var XHuman2           = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 5).Select(s => s.FirstName + " " + s.MiddleName.Substring(0, 1) + " " + s.LastName.Substring(0, 1)).FirstOrDefault();
                var XHuman3           = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 9).Select(s => s.FirstName + " " + s.MiddleName.Substring(0, 1) + " " + s.LastName.Substring(0, 1)).FirstOrDefault();
                var Nomencl           = TestCaseUse.EquipmentCard.Equipment.Nomenclature.NameOfNomenclature;
                var Mdl         = TestCaseUse.EquipmentCard.Equipment.Model;
                var SerNumb     = TestCaseUse.EquipmentCard.SerialNumber;
                var StatusEquip = TestCaseUse.EquipmentCard.StatusOfEquipment.NameOfStatus;
                var Break       = TestCaseUse.StatusEquipInRepair.StatusEquipInRepair1;
                var GetDate     = DateTime.Today.ToShortDateString();
                try
                {
                    ReplaceWordStub("{FirstComm}", XHuman1, doc);
                    ReplaceWordStub("{SecComm}", XHuman2, doc);
                    ReplaceWordStub("{ThreeComm}", XHuman3, doc);
                    ReplaceWordStub("{GetDate}", GetDate.ToString(), doc);
                    ReplaceWordStub("{Model}", Mdl, doc);
                    ReplaceWordStub("{Nomenclature}", Nomencl, doc);
                    ReplaceWordStub("{SerialNumber}", SerNumb, doc);
                    ReplaceWordStub("{StatusEq}", StatusEquip.ToString(), doc);
                    ReplaceWordStub("{Dead}", Break, doc);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                }
                doc.SaveAs2(@"G:\1robit.docx");
                doc.Close();
                break;

            case 2:
                Word.Application word2 = new Microsoft.Office.Interop.Word.Application();
                Word.Document    doc2  = word2.Documents.Open(Environment.CurrentDirectory + @"\Akt_remonta_oborudovania.docx");
                var TestCaseUse2       = DgridMyPage.SelectedItems.Cast <Repair>().FirstOrDefault() as Repair;
                var HumanFIO           = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 6).Select(s => s.FirstName + " " + s.MiddleName.Substring(0, 1) + " " + s.LastName.Substring(0, 1)).FirstOrDefault();
                var DateDelBerk        = TestCaseUse2.EquipmentCard.DateOfDelivery.ToShortDateString();
                var Manufac            = TestCaseUse2.EquipmentCard.Equipment.Manufacturer.ManufacturerName;;
                var Nomencl2           = TestCaseUse2.EquipmentCard.Equipment.Nomenclature.NameOfNomenclature;
                var Mdl2          = TestCaseUse2.EquipmentCard.Equipment.Model;
                var SerNum2b      = TestCaseUse2.EquipmentCard.SerialNumber;
                var PhoneNumb     = TestCaseUse2.Worker.PhoneNumber;
                var Brk2          = TestCaseUse2.StatusEquipInRepair.StatusEquipInRepair1;
                var DateCreateBrk = DateTime.Today.ToShortDateString();
                try
                {
                    ReplaceWordStub("{DateOfDelivery}", DateDelBerk, doc2);
                    ReplaceWordStub("{Nomenclature}", Nomencl2, doc2);
                    ReplaceWordStub("{Manufacturer}", Manufac, doc2);
                    ReplaceWordStub("{Model}", Mdl2, doc2);
                    ReplaceWordStub("{SerialNumber}", SerNum2b, doc2);
                    ReplaceWordStub("{BreakDown}", Brk2, doc2);
                    ReplaceWordStub("{FirstName}", HumanFIO, doc2);
                    ReplaceWordStub("{Number}", PhoneNumb, doc2);
                    ReplaceWordStub("{Email}", Brk2, doc2);
                    ReplaceWordStub("{DateRepair}", DateCreateBrk, doc2);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                }
                doc2.SaveAs2(@"G:\G;chromesaves\2robit.docx");
                doc2.Close();
                break;

            case 3:
                Word.Application word3 = new Microsoft.Office.Interop.Word.Application();
                Word.Document    doc3  = word3.Documents.Open(Environment.CurrentDirectory + @"\Akt_priyoma_peredachi_oborudovania_v_remont.docx");
                var TestCaseUse3       = DgridMyPage.SelectedItems.Cast <Repair>().FirstOrDefault() as Repair;
                var HumanFIO2          = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 6).Select(s => s.LastName.Substring(0, 1) + " " + s.MiddleName.Substring(0, 1) + " " + s.FirstName).FirstOrDefault();
                var DateDeliverReapir  = TestCaseUse3.DateOfDeliveryForRepair.ToShortDateString();
                var Manufac2           = TestCaseUse3.EquipmentCard.Equipment.Manufacturer.ManufacturerName;
                var Nomencl3           = TestCaseUse3.EquipmentCard.Equipment.Nomenclature.NameOfNomenclature;
                var Mdl4           = TestCaseUse3.EquipmentCard.Equipment.Model;
                var SerNum3b       = TestCaseUse3.EquipmentCard.SerialNumber;
                var PhoneNumb2     = TestCaseUse3.Worker.PhoneNumber;
                var Mail           = TestCaseUse3.Worker.EmailOfWorker;
                var Positions      = TestCaseUse3.Worker.Position.PostionName;
                var DateCreateBrk3 = TestCaseUse3.DateOfReceiving.ToShortDateString();
                var Breakd         = TestCaseUse3.Breakdown.NameOfBreakdown;
                var ServiceOrg     = TestCaseUse3.ServiceOrganization.NameOfServiceOrganization;
                try
                {
                    ReplaceWordStub("{DateOfDeliveryForRepair}", DateDeliverReapir, doc3);
                    ReplaceWordStub("{Nomenclature}", Nomencl3, doc3);
                    ReplaceWordStub("{Manufacturer}", Manufac2, doc3);
                    ReplaceWordStub("{Model}", Mdl4, doc3);
                    ReplaceWordStub("{BreakDown}", Breakd, doc3);
                    ReplaceWordStub("{F.M.LastName}", HumanFIO2, doc3);
                    ReplaceWordStub("{ContactPhone}", PhoneNumb2, doc3);
                    ReplaceWordStub("{Email}", Mail, doc3);
                    ReplaceWordStub("{DateOfDeliveryForRepair}", DateDeliverReapir, doc3);
                    ReplaceWordStub("{DateOfReceiving}", DateCreateBrk3, doc3);
                    ReplaceWordStub("{ServiceOrganization}", ServiceOrg, doc3);
                    ReplaceWordStub("{ServiceOrganization1}", ServiceOrg, doc3);
                    ReplaceWordStub("{Position}", Positions, doc3);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                }
                doc3.SaveAs2(@"G:\G;chromesaves\3robit.docx");
                doc3.Close();
                break;

            case 4:
                Word.Application word4 = new Microsoft.Office.Interop.Word.Application();
                Word.Document    doc4  = word4.Documents.Open(Environment.CurrentDirectory + @"\Akt_vozvrata_oborudovania_iz_remonta.docx");
                var TestCaseUse4       = DgridMyPage.SelectedItems.Cast <Repair>().FirstOrDefault() as Repair;
                var HumanFIO23         = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 6).Select(s => s.LastName.Substring(0, 1) + " " + s.MiddleName.Substring(0, 1) + " " + s.FirstName).FirstOrDefault();
                var DateDeliverReapir3 = TestCaseUse4.DateOfDeliveryForRepair.ToShortDateString();
                var Manufac22          = TestCaseUse4.EquipmentCard.Equipment.Manufacturer.ManufacturerName;
                var Nomencl33          = TestCaseUse4.EquipmentCard.Equipment.Nomenclature.NameOfNomenclature;
                var Mdl5           = TestCaseUse4.EquipmentCard.Equipment.Model;
                var Positions2     = TestCaseUse4.Worker.Position.PostionName;
                var DateCreateBrk4 = TestCaseUse4.DateOfReceiving.ToShortDateString();
                var ServiceOrg2    = TestCaseUse4.ServiceOrganization.NameOfServiceOrganization;
                try
                {
                    ReplaceWordStub("{Nomenclature}", Nomencl33, doc4);
                    ReplaceWordStub("{Manufacturer}", Manufac22, doc4);
                    ReplaceWordStub("{Model}", Mdl5, doc4);
                    ReplaceWordStub("{F.M.LastName}", HumanFIO23, doc4);
                    ReplaceWordStub("{DateOfDelivery}", DateDeliverReapir3, doc4);
                    ReplaceWordStub("{DateOfReceiving}", DateCreateBrk4, doc4);
                    ReplaceWordStub("{DateOfReceiving1}", DateDeliverReapir3, doc4);
                    ReplaceWordStub("{DateOfReceiving2}", DateCreateBrk4, doc4);
                    ReplaceWordStub("{ServiceOrganization}", ServiceOrg2, doc4);
                    ReplaceWordStub("{ServiceOrganization1}", ServiceOrg2, doc4);
                    ReplaceWordStub("{Position}", Positions2, doc4);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                }
                doc4.SaveAs2(@"G:\G;chromesaves\4robit.docx");
                doc4.Close();
                break;
                break;

            case 5:
                break;
            }
        }
 public NomenclaturePage()
 {
     InitializeComponent();
     DataContext             = _curentnomenclature;
     DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Nomenclature.ToList();
 }
        private void InventarizationOfReport_DropDownClosed(object sender, EventArgs e)
        {
            if (InventarizationOfReport.Text == "Приказ")
            {
                Switchjopbl = 1;
            }
            if (InventarizationOfReport.Text == "Акт")
            {
                Switchjopbl = 2;
            }
            if (DgridMyPage.SelectedItem == null)
            {
                return;
            }
            else
            {
                switch (Switchjopbl)
                {
                case 1:
                    try
                    {
                        SaveFileDialog openDlg = new SaveFileDialog();
                        openDlg.FileName         = "Отчет №";
                        openDlg.Filter           = "Word (.doc)|.doc |Word (.docx)|.docx |All files (.)|.";
                        openDlg.FilterIndex      = 2;
                        openDlg.RestoreDirectory = true;
                        if (openDlg.ShowDialog() == true)
                        {
                            Word.Application word = new Microsoft.Office.Interop.Word.Application();

                            Word.Document doc         = word.Documents.Open(Environment.CurrentDirectory + @"\Prikaz_o_provedenii_inventarizatsii.docx");
                            var           TestCaseUse = DgridMyPage.SelectedItems.Cast <Inventory>().FirstOrDefault() as Inventory;
                            var           XHuman1     = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 1).Select(s => s.FirstName + " " + s.MiddleName.Substring(0, 1) + " " + s.LastName.Substring(0, 1)).FirstOrDefault();
                            var           XHuman2     = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 5).Select(s => s.FirstName + " " + s.MiddleName.Substring(0, 1) + " " + s.LastName.Substring(0, 1)).FirstOrDefault();
                            var           XHuman3     = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 9).Select(s => s.FirstName + " " + s.MiddleName.Substring(0, 1) + " " + s.LastName.Substring(0, 1)).FirstOrDefault();
                            var           XHuman4     = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 41).Select(s => s.FirstName + " " + s.MiddleName.Substring(0, 1) + " " + s.LastName.Substring(0, 1)).FirstOrDefault();
                            var           Position1   = AccountingEquipmentEntities.GetContext().Worker.Include(i => i.Position).Where(w => w.id == 1).Select(s => s.Position.PostionName).FirstOrDefault();
                            var           Position2   = AccountingEquipmentEntities.GetContext().Worker.Include(i => i.Position).Where(w => w.id == 5).Select(s => s.Position.PostionName).FirstOrDefault();
                            var           Position3   = AccountingEquipmentEntities.GetContext().Worker.Include(i => i.Position).Where(w => w.id == 9).Select(s => s.Position.PostionName).FirstOrDefault();
                            var           Position4   = AccountingEquipmentEntities.GetContext().Worker.Include(i => i.Position).Where(w => w.id == 41).Select(s => s.Position.PostionName).FirstOrDefault();
                            var           Nomencl     = TestCaseUse.EquipmentCard.Equipment.Nomenclature.NameOfNomenclature;
                            var           Mdl         = TestCaseUse.EquipmentCard.Equipment.Model;
                            var           SerNumb     = TestCaseUse.EquipmentCard.SerialNumber;
                            var           InvetNumber = TestCaseUse.EquipmentCard.InventNumber;
                            var           StatusEquip = TestCaseUse.EquipmentCard.StatusOfEquipment.NameOfStatus;
                            var           GetDate     = DateTime.Today.ToShortDateString();
                            var           datein      = TestCaseUse.InventoryDate.ToShortDateString();
                            var           iddoc       = TestCaseUse.id;
                            var           dateout     = DateTime.Now.AddDays(3).ToShortDateString();
                            var           dateoutBuh  = DateTime.Now.AddDays(7).ToShortDateString();
                            var           Manufac     = TestCaseUse.EquipmentCard.Equipment.Manufacturer.ManufacturerName;

                            ReplaceWordStub("{FIO1}", XHuman1, doc);
                            ReplaceWordStub("{FIO2}", XHuman2, doc);
                            ReplaceWordStub("{FIO3}", XHuman3, doc);
                            ReplaceWordStub("{FIO4}", XHuman4, doc);
                            ReplaceWordStub("{Position1}", Position1, doc);
                            ReplaceWordStub("{Position2}", Position2, doc);
                            ReplaceWordStub("{Position3}", Position3, doc);
                            ReplaceWordStub("{Position4}", Position4, doc);
                            ReplaceWordStub("{InventNumber}", Mdl, doc);
                            ReplaceWordStub("{Model}", InvetNumber, doc);
                            ReplaceWordStub("{GetDate}", GetDate, doc);
                            ReplaceWordStub("{Nomenclature}", Nomencl, doc);
                            ReplaceWordStub("{SerialNumber}", SerNumb, doc);
                            ReplaceWordStub("{GetDate1}", datein, doc);
                            ReplaceWordStub("{GetDate2}", dateout, doc);
                            ReplaceWordStub("{GetDate3}", dateoutBuh, doc);
                            ReplaceWordStub("{id}", iddoc.ToString(), doc);
                            ReplaceWordStub("{Manufacturer}", Manufac.ToString(), doc);

                            doc.SaveAs2(openDlg.FileName);
                            doc.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("" + ex);
                    }
                    break;

                case 2:
                    try
                    {
                        SaveFileDialog openDlg = new SaveFileDialog();
                        openDlg.FileName         = "Отчет №";
                        openDlg.Filter           = "Word (.doc)|.doc |Word (.docx)|.docx |All files (.)|.";
                        openDlg.FilterIndex      = 2;
                        openDlg.RestoreDirectory = true;
                        if (openDlg.ShowDialog() == true)
                        {
                            Word.Application word2 = new Microsoft.Office.Interop.Word.Application();
                            Word.Document    doc2  = word2.Documents.Open(Environment.CurrentDirectory + @"\Akt_o_rezultatakh_inventarizatsii.docx");
                            var TestCaseUse2       = DgridMyPage.SelectedItems.Cast <Inventory>().FirstOrDefault() as Inventory;
                            var XHuman11           = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 1).Select(s => s.LastName.Substring(0, 1) + " " + s.MiddleName.Substring(0, 1) + " " + s.FirstName).FirstOrDefault();
                            var XHuman21           = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 5).Select(s => s.LastName.Substring(0, 1) + " " + s.MiddleName.Substring(0, 1) + " " + s.FirstName).FirstOrDefault();
                            var XHuman31           = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 9).Select(s => s.LastName.Substring(0, 1) + " " + s.MiddleName.Substring(0, 1) + " " + s.FirstName).FirstOrDefault();
                            var XHuman41           = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 41).Select(s => s.LastName.Substring(0, 1) + " " + s.MiddleName.Substring(0, 1) + " " + s.FirstName).FirstOrDefault();
                            var XHuman51           = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 29).Select(s => s.LastName.Substring(0, 1) + " " + s.MiddleName.Substring(0, 1) + " " + s.FirstName).FirstOrDefault();
                            var XHuman61           = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 35).Select(s => s.LastName.Substring(0, 1) + " " + s.MiddleName.Substring(0, 1) + " " + s.FirstName).FirstOrDefault();
                            var XHuman81           = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 19).Select(s => s.LastName.Substring(0, 1) + " " + s.MiddleName.Substring(0, 1) + " " + s.FirstName).FirstOrDefault();
                            var Position21         = AccountingEquipmentEntities.GetContext().Worker.Include(i => i.Position).Where(w => w.id == 5).Select(s => s.Position.PostionName).FirstOrDefault();
                            var XHuman71           = AccountingEquipmentEntities.GetContext().Worker.Where(w => w.id == 23).Select(s => s.LastName.Substring(0, 1) + " " + s.MiddleName.Substring(0, 1) + " " + s.FirstName).FirstOrDefault();
                            var Position31         = AccountingEquipmentEntities.GetContext().Worker.Include(i => i.Position).Where(w => w.id == 9).Select(s => s.Position.PostionName).FirstOrDefault();
                            var Position41         = AccountingEquipmentEntities.GetContext().Worker.Include(i => i.Position).Where(w => w.id == 41).Select(s => s.Position.PostionName).FirstOrDefault();
                            var Position51         = AccountingEquipmentEntities.GetContext().Worker.Include(i => i.Position).Where(w => w.id == 29).Select(s => s.Position.PostionName).FirstOrDefault();
                            var Position61         = AccountingEquipmentEntities.GetContext().Worker.Include(i => i.Position).Where(w => w.id == 23).Select(s => s.Position.PostionName).FirstOrDefault();
                            var GetDate1           = DateTime.Today.ToShortDateString();
                            var datein1            = TestCaseUse2.InventoryDate.ToShortDateString();
                            var iddoc1             = TestCaseUse2.id;
                            var dateout1           = DateTime.Now.AddDays(3).ToShortDateString();
                            var dateoutBuh1        = DateTime.Now.AddDays(7).ToShortDateString();
                            var dateoutBuh2        = DateTime.Now.AddDays(10).ToShortDateString();
                            ReplaceWordStub("{Worker}", XHuman81, doc2);
                            ReplaceWordStub("{Worker1}", XHuman11, doc2);
                            ReplaceWordStub("{F.M.Lname1}", XHuman21, doc2);
                            ReplaceWordStub("{F.M.Lname2}", XHuman31, doc2);
                            ReplaceWordStub("{F.M.Lname3}", XHuman41, doc2);
                            ReplaceWordStub("{F.M.Lname4}", XHuman51, doc2);
                            ReplaceWordStub("{F.M.Lname4}", XHuman61, doc2);
                            ReplaceWordStub("{Position1}", Position21, doc2);
                            ReplaceWordStub("{F.M.Lname5}", XHuman61, doc2);
                            ReplaceWordStub("{Position2}", Position31, doc2);
                            ReplaceWordStub("{Position3}", Position41, doc2);
                            ReplaceWordStub("{Position4}", Position51, doc2);
                            ReplaceWordStub("{Position5}", Position61, doc2);
                            ReplaceWordStub("{Date1}", GetDate1, doc2);
                            ReplaceWordStub("{InventoryDate}", datein1, doc2);
                            ReplaceWordStub("{GetDate1}", datein1, doc2);
                            ReplaceWordStub("{GetDate2}", dateout1, doc2);
                            ReplaceWordStub("{GetDate3}", dateoutBuh1, doc2);
                            ReplaceWordStub("{GetDate4}", dateoutBuh2, doc2);
                            ReplaceWordStub("{GetDate5}", dateoutBuh2, doc2);
                            ReplaceWordStub("{idInvent}", iddoc1.ToString(), doc2);
                            ReplaceWordStub("{id}", iddoc1.ToString(), doc2);
                            ReplaceWordStub("{id1}", iddoc1.ToString(), doc2);
                            ReplaceWordStub("{GetDate5}", GetDate1, doc2);
                            ReplaceWordStub("{FirstComm}", XHuman21, doc2);
                            ReplaceWordStub("{SecondComm}", XHuman31, doc2);
                            ReplaceWordStub("{ThreeComm}", XHuman41, doc2);
                            ReplaceWordStub("{Comment}", TestCaseUse2.Comment, doc2);

                            doc2.SaveAs2(openDlg.FileName);
                            doc2.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("" + ex);
                    }
                    break;
                }
            }
        }
 public RoomPage()
 {
     InitializeComponent();
     DataContext             = _CurrentRoom;
     DgridMyPage.ItemsSource = AccountingEquipmentEntities.GetContext().Room.ToList();
 }
Пример #30
0
 public void load()
 {
     DgridMyPage_Copy.ItemsSource = AccountingEquipmentEntities.GetContext().Repair.ToList();
 }