예제 #1
0
        protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (ValidateFields())
            {
                Category category = null;
                if (EditMode)
                {
                    category = _current;
                }

                if (category == null)
                {
                    category = new Category();
                }

                category.Name        = tbName.Text.Trim();
                category.Description = tbDescription.Text.Trim();

                if (CategoriesService.Instanse.Insert(category))
                {
                    Global.SubmissionSuceeded(this);
                    EditMode            = btnCancelChanges.IsEnabled = ChangesHappened = false;
                    btnDelete.IsEnabled = cutTextBox.IsEnabled = true;
                    ResetFields();
                    TryToLoad();
                }
                else
                {
                    Global.SubmissionFailed(this);
                }
            }
            aiLoader.Visibility = Visibility.Collapsed;
            OnSaving            = false;
        }
예제 #2
0
        private void DataGridHyperlinkColumnClick(object sender, RoutedEventArgs e)
        {
            var material = dgResults.SelectedItem as Material;

            if (material != null)
            {
                var    amount = 0;
                object returnValue;
                int    temp;
                if (InputWindowHelpers.Show(this, x => int.TryParse(x as string, out temp) && temp > 0,
                                            MaterialsResources.IncreaseAmountDescription,
                                            MaterialsResources.IncreaseAmount, out returnValue, 0))
                {
                    amount = int.Parse(returnValue.ToString());
                }
                if (amount != 0)
                {
                    if (
                        RepositoryMaterialsService.Instanse.Insert(new RepositoryMaterial {
                        MaterialID = material.MaterialID,
                        Amount = amount,
                        TargetApplicant = AppContext.User.UserName
                    }))
                    {
                        TryToLoad();
                        Global.SubmissionSuceeded(this);
                    }
                    else
                    {
                        Global.SubmissionFailed(this);
                    }
                }
            }
        }
예제 #3
0
        protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (ValidateFields())
            {
                if (_materials)
                {
                    var repositoryMaterial = new RepositoryMaterial {
                        Amount =
                            (cmbActionType.SelectedIndex == 0
                                                                                 ? -int.Parse(tbAmount.Text)
                                                                                 : int.Parse(tbAmount.Text)),
                        LabID           = (Guid)cmbLabs.SelectedValue,
                        TargetApplicant = tbTargetApplicant.Text,
                        MaterialID      = (Guid)cmbMaterials.SelectedValue
                    };

                    if (RepositoryMaterialsService.Instanse.Insert(repositoryMaterial))
                    {
                        Global.SubmissionSuceeded(this);
                        ChangesHappened     = false;
                        btnDelete.IsEnabled = true;
                        ResetFields();
                        TryToLoad(cmbFilterBy.SelectedIndex);
                    }
                    else
                    {
                        Global.SubmissionFailed(this);
                    }
                    btnSubmit.IsEnabled = false;
                }
                else
                {
                    var repositoryItem = new RepositoryItem {
                        Count =
                            (cmbActionType.SelectedIndex == 0
                                                                         ? -int.Parse(tbAmount.Text)
                                                                         : int.Parse(tbAmount.Text)),
                        LabID           = (Guid)cmbLabs.SelectedValue,
                        TargetApplicant = tbTargetApplicant.Text,
                        ItemID          = (Guid)cmbItems.SelectedValue
                    };

                    if (RepositoryItemsService.Instanse.Insert(repositoryItem))
                    {
                        Global.SubmissionSuceeded(this);
                        ChangesHappened     = false;
                        btnDelete.IsEnabled = true;
                        ResetFields();
                        TryToLoad(cmbFilterBy.SelectedIndex);
                    }
                    else
                    {
                        Global.SubmissionFailed(this);
                    }
                    btnSubmit.IsEnabled = false;
                }
            }
            aiLoader.Visibility = Visibility.Collapsed;
            OnSaving            = false;
        }
예제 #4
0
        protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (ValidateFields())
            {
                var      initialAmount = 0;
                Material material      = null;
                if (EditMode)
                {
                    material = _current;
                }

                if (material == null)
                {
                    object returnValue;
                    uint   temp;
                    if (InputWindowHelpers.Show(this, x => uint.TryParse(x.ToString(), out temp),
                                                MaterialsResources.InitialAmountDescription,
                                                MaterialsResources.InitialAmount, out returnValue, 0))
                    {
                        initialAmount = int.Parse(returnValue.ToString());
                    }
                    material = new Material();
                }
                material.Name          = cmbNames.Text.Trim();
                material.Unit          = (short)cmbMesureUnit.SelectedIndex;
                material.LowestAmount  = int.Parse(tbLowestAmount.Text);
                material.Formula       = tbFormula.Text;
                material.MolecularMass = tbMolecularMass.Text;
                material.Description   = tbDescription.Text.Trim();
                if (cmbCategories.SelectedValue != null)
                {
                    material.CategoryID = (Guid)cmbCategories.SelectedValue;
                }

                if (MaterialsService.Insert(material, initialAmount))
                {
                    Global.SubmissionSuceeded(this);
                    EditMode             = btnCancelChanges.IsEnabled = ChangesHappened = false;
                    btnDelete.IsEnabled  = cutTextBox.IsEnabled = true;
                    cmbNames.ItemsSource = MaterialsService.Instanse.GetAll();
                    ResetFields();
                    TryToLoad();
                }
                else
                {
                    Global.SubmissionFailed(this);
                }
            }
            aiLoader.Visibility = Visibility.Collapsed;
            OnSaving            = false;
        }
예제 #5
0
        protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (ValidateFields())
            {
                var  initialCount = 0;
                Item item         = null;
                if (EditMode)
                {
                    item = _current;
                }

                if (item == null)
                {
                    object returnValue;
                    uint   temp;
                    if (InputWindowHelpers.Show(this, x => uint.TryParse(x.ToString(), out temp),
                                                ItemsResources.InitialCountDescription, ItemsResources.InitialCount,
                                                out returnValue, 0))
                    {
                        initialCount = int.Parse(returnValue.ToString());
                    }
                    item = new Item();
                }
                item.Name        = cmbNames.Text.Trim();
                item.LowestCount = int.Parse(tbLowestCount.Text);
                item.Description = tbDescription.Text.Trim();
                if (cmbCategories.SelectedValue != null)
                {
                    item.CategoryID = (Guid)cmbCategories.SelectedValue;
                }

                if (ItemsService.Insert(item, initialCount))
                {
                    Global.SubmissionSuceeded(this);
                    EditMode             = btnCancelChanges.IsEnabled = ChangesHappened = false;
                    btnDelete.IsEnabled  = cutTextBox.IsEnabled = true;
                    cmbNames.ItemsSource = ItemsService.Instanse.GetAll();
                    ResetFields();
                    TryToLoad();
                }
                else
                {
                    Global.SubmissionFailed(this);
                }
            }
            aiLoader.Visibility = Visibility.Collapsed;
            OnSaving            = false;
        }
예제 #6
0
        protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (ValidateFields())
            {
                Lab lab = null;
                if (EditMode)
                {
                    lab = _current;
                }

                if (lab == null)
                {
                    lab = new Lab();
                }

                lab.Name        = tbName.Text.Trim();
                lab.Description = tbDescription.Text.Trim();
                if (InitialCategoryID.HasValue)
                {
                    lab.CategoryID = InitialCategoryID;
                }
                else
                {
                    if (cmbCategories.SelectedValue != null)
                    {
                        lab.CategoryID = (Guid)cmbCategories.SelectedValue;
                    }
                }

                if (LabsService.Instanse.Insert(lab))
                {
                    Global.SubmissionSuceeded(this);
                    EditMode            = btnCancelChanges.IsEnabled = ChangesHappened = false;
                    btnDelete.IsEnabled = cutTextBox.IsEnabled = true;
                    ResetFields();
                    TryToLoad();
                }
                else
                {
                    Global.SubmissionFailed(this);
                }
            }
            aiLoader.Visibility = Visibility.Collapsed;
            OnSaving            = false;
        }
예제 #7
0
        protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (ValidateFields())
            {
                User user = null;
                if (EditMode)
                {
                    user = _current;
                }

                if (user == null)
                {
                    user = new User();
                }

                if (!EditMode)
                {
                    user.UserName = tbUserName.Text.Trim();
                }
                user.Password    = pbPassword.Password;
                user.Description = tbDescription.Text;
                user.RoleID      = (Guid)cmbRoles.SelectedValue;
                user.LockedOut   = chbLockedOut.IsChecked ?? false;

                if (UsersService.Instanse.Insert(user))
                {
                    Global.SubmissionSuceeded(this);
                    EditMode            = btnCancelChanges.IsEnabled = ChangesHappened = false;
                    btnDelete.IsEnabled = cutTextBox.IsEnabled = true;
                    ResetFields();
                    TryToLoad();
                }
                else
                {
                    Global.SubmissionFailed(this);
                }
            }
            aiLoader.Visibility = Visibility.Collapsed;
            OnSaving            = false;
        }
예제 #8
0
 protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (ValidateFields())
     {
         var user = AppContext.User;
         user.Name = tbName.Text;
         if (!string.IsNullOrEmpty(pbNewPassword.Password))
         {
             user.Password = UsersService.EncodePassword(pbNewPassword.Password);
         }
         if (UsersService.Instanse.Insert(user))
         {
             Global.SubmissionSuceeded(this);
             ChangesHappened = false;
             ResetFields();
         }
         else
         {
             Global.SubmissionFailed(this);
         }
     }
     aiLoader.Visibility = Visibility.Collapsed;
     OnSaving            = false;
 }
예제 #9
0
        protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (ValidateFields())
            {
                Role role = null;
                if (EditMode)
                {
                    role = _current;
                }

                if (role == null)
                {
                    role = new Role();
                }

                role.Name        = tbName.Text.Trim();
                role.Description = tbDescription.Text.Trim();

                role.CategoriesDisplay = chbCategoriesDisplay.IsChecked ?? false;
                role.CategoriesInsert  = chbCategoriesInsert.IsChecked ?? false;
                role.CategoriesUpdate  = chbCategoriesUpdate.IsChecked ?? false;
                role.CategoriesDelete  = chbCategoriesDelete.IsChecked ?? false;

                role.PropsDisplay = chbPropsDisplay.IsChecked ?? false;
                role.PropsInsert  = chbPropsInsert.IsChecked ?? false;
                role.PropsUpdate  = chbPropsUpdate.IsChecked ?? false;
                role.PropsDelete  = chbPropsDelete.IsChecked ?? false;

                role.PropStatusDisplay = chbPropStatusDisplay.IsChecked ?? false;
                role.PropStatusUpdate  = chbPropStatusUpdate.IsChecked ?? false;

                role.MaterialsDisplay = chbMaterialsDisplay.IsChecked ?? false;
                role.MaterialsInsert  = chbMaterialsInsert.IsChecked ?? false;
                role.MaterialsUpdate  = chbMaterialsUpdate.IsChecked ?? false;
                role.MaterialsDelete  = chbMaterialsDelete.IsChecked ?? false;

                role.ItemsDisplay = chbItemsDisplay.IsChecked ?? false;
                role.ItemsInsert  = chbItemsInsert.IsChecked ?? false;
                role.ItemsUpdate  = chbItemsUpdate.IsChecked ?? false;
                role.ItemsDelete  = chbItemsDelete.IsChecked ?? false;

                role.RepositoryMaterialsAndItemsInsert = chbRepositoryMaterialsAndItemsInsert.IsChecked ?? false;
                role.RepositoryMaterialsAndItemsDelete = chbRepositoryMaterialsAndItemsDelete.IsChecked ?? false;

                role.LabsDisplay = chbLabsDisplay.IsChecked ?? false;
                role.LabsInsert  = chbLabsInsert.IsChecked ?? false;
                role.LabsUpdate  = chbLabsUpdate.IsChecked ?? false;
                role.LabsDelete  = chbLabsDelete.IsChecked ?? false;

                role.LabPropsDisplay = chbLabPropsDisplay.IsChecked ?? false;
                role.LabPropsInsert  = chbLabPropsInsert.IsChecked ?? false;
                role.LabPropsDelete  = chbLabPropsDelete.IsChecked ?? false;

                role.UsersDisplay = chbUsersDisplay.IsChecked ?? false;
                role.UsersInsert  = chbUsersInsert.IsChecked ?? false;
                role.UsersUpdate  = chbUsersUpdate.IsChecked ?? false;
                role.UsersDelete  = chbUsersDelete.IsChecked ?? false;

                role.SearchDisplay             = chbSearchDisplay.IsChecked ?? false;
                role.PropsSearch               = chbPropsSearch.IsChecked ?? false;
                role.MaterialsSearch           = chbMaterialsSearch.IsChecked ?? false;
                role.RepositoryMaterialsSearch = chbRepositoryMaterialsSearch.IsChecked ?? false;
                role.RepositoryItemsSearch     = chbRepositoryItemsSearch.IsChecked ?? false;
                role.LabsSearch     = chbLabsSearch.IsChecked ?? false;
                role.LabPropsSearch = chbLabPropsSearch.IsChecked ?? false;
                role.ItemsSearch    = chbItemsSearch.IsChecked ?? false;
                role.LogsSearch     = chbLogsSearch.IsChecked ?? false;

                role.RolesDisplay = chbRolesDisplay.IsChecked ?? false;
                role.RolesInsert  = chbRolesInsert.IsChecked ?? false;
                role.RolesUpdate  = chbRolesUpdate.IsChecked ?? false;
                role.RolesDelete  = chbRolesDelete.IsChecked ?? false;

                role.LogsDisplay = chbLogsDisplay.IsChecked ?? false;
                role.LogsDelete  = chbLogsDelete.IsChecked ?? false;

                if (RolesService.Instanse.Insert(role))
                {
                    Global.SubmissionSuceeded(this);
                    EditMode            = btnCancelChanges.IsEnabled = ChangesHappened = false;
                    btnDelete.IsEnabled = cutTextBox.IsEnabled = true;
                    ResetFields();
                    TryToLoad();
                }
                else
                {
                    Global.SubmissionFailed(this);
                }
            }
            aiLoader.Visibility = Visibility.Collapsed;
            OnSaving            = false;
        }
예제 #10
0
        protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (ValidateFields())
            {
                Prop prop = null;
                if (EditMode)
                {
                    prop = _current;
                }
                var initialLabID = Guid.Empty;
                if (prop == null)
                {
                    prop = new Prop();
                    object returnValue;
                    Guid   temp;
                    if (InputWindowHelpers.Show(this, x => Guid.TryParse(x != null ? x.ToString() : "", out temp),
                                                PropsResources.InitialLabID, PropsResources.LabName, out returnValue,
                                                null, LabsService.Instanse.GetAll(cmbCategories.SelectedValue as Guid?),
                                                "Name", "LabID"))
                    {
                        initialLabID = Guid.Parse(returnValue.ToString());
                    }
                }

                prop.Name = cmbNames.Text.Trim();
                if (!string.IsNullOrEmpty(tbPropNo.Text))
                {
                    prop.PropNo = int.Parse(tbPropNo.Text);
                }
                else
                {
                    prop.PropNo = null;
                }
                prop.SerialNo               = tbSerialNo.Text.Trim();
                prop.PurchasingDate         = dtpPurchasingDate.Value;
                prop.WarrantyExpirationDate = dtpWarrantyExpirationDate.Value;
                prop.Description            = tbDescription.Text.Trim();
                if (cmbCategories.SelectedValue != null)
                {
                    prop.CategoryID = (Guid)cmbCategories.SelectedValue;
                }

                if (PropsService.Instanse.Insert(prop))
                {
                    if (initialLabID != Guid.Empty)
                    {
                        LabPropsService.Instanse.Insert(new LabProp {
                            LabID = initialLabID, PropID = prop.PropID
                        });
                    }
                    Global.SubmissionSuceeded(this);
                    EditMode             = btnCancelChanges.IsEnabled = ChangesHappened = false;
                    btnDelete.IsEnabled  = cutTextBox.IsEnabled = true;
                    cmbNames.ItemsSource = PropsService.Instanse.GetAll();
                    ResetFields();
                    TryToLoad();
                }
                else
                {
                    Global.SubmissionFailed(this);
                }
            }
            aiLoader.Visibility = Visibility.Collapsed;
            OnSaving            = false;
        }
예제 #11
0
        protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (ValidateFields())
            {
                var result = MessageBoxResult.Yes;
                var type   = (ReportType)cmbStatus.SelectedIndex;
                if (type == ReportType.Used || type == ReportType.DeliveredToRepository)
                {
                    result = MessageWindowHelpers.Show(this, PropStatusResources.Attention, MessageBoxButton.YesNo,
                                                       MessageBoxImage.Question);
                }
                if (result == MessageBoxResult.Yes)
                {
                    if (_current.Type == (short)cmbStatus.SelectedIndex)
                    {
                        switch (_current.Type)
                        {
                        case 1:
                        case 2:
                            _current.ChangedOn   = dtpOutDate.Value;
                            _current.ResolveDate = dtpInDate.Value;
                            break;

                        case 3:
                        case 5:
                            _current.ChangedOn = dtpOutDate.Value;
                            break;
                        }
                        _current.Description = tbDescription.Text;
                        if (PropStatusChangesService.Instanse.Insert(_current))
                        {
                            Global.SubmissionSuceeded(this);
                            ResetFields();
                            if (
                                MessageWindowHelpers.Show(this, PropStatusResources.SelectAnotherProp,
                                                          MessageBoxButton.YesNo, MessageBoxImage.Question) ==
                                MessageBoxResult.Yes)
                            {
                                TryToLoad(true);
                            }
                            else
                            {
                                Close();
                            }
                        }
                        else
                        {
                            Global.SubmissionFailed(this);
                        }
                    }
                    else
                    {
                        _current.IsAlive = false;
                        if (PropStatusChangesService.Instanse.Insert(_current))
                        {
                            var newPropStatusChange = new PropStatusChange
                            {
                                PropID = _current.PropID, Type = (short)cmbStatus.SelectedIndex
                            };

                            switch (newPropStatusChange.Type)
                            {
                            case 1:
                            case 2:
                                newPropStatusChange.ChangedOn   = dtpOutDate.Value;
                                newPropStatusChange.ResolveDate = dtpInDate.Value;
                                break;

                            case 3:
                            case 5:
                                newPropStatusChange.ChangedOn = dtpOutDate.Value;
                                break;
                            }
                            newPropStatusChange.Description = tbDescription.Text;
                            if (PropStatusChangesService.Instanse.Insert(newPropStatusChange))
                            {
                                Global.SubmissionSuceeded(this);
                                ResetFields();
                                if (
                                    MessageWindowHelpers.Show(this, PropStatusResources.SelectAnotherProp,
                                                              MessageBoxButton.YesNo, MessageBoxImage.Question) ==
                                    MessageBoxResult.Yes)
                                {
                                    TryToLoad(true);
                                }
                                else
                                {
                                    Close();
                                }
                            }
                            else
                            {
                                Global.SubmissionFailed(this);
                            }
                        }
                        else
                        {
                            Global.SubmissionFailed(this);
                        }
                    }
                }
            }
            aiLoader.Visibility = Visibility.Collapsed;
            OnSaving            = false;
        }