Exemplo n.º 1
0
        private void btnOK_Clicked(object o, EventArgs args)
        {
            StringBuilder bankNotesAndMoneyBuilder = new StringBuilder();

            foreach (ToggleButton toggleButton in allButtons)
            {
                if (toggleButton.Active)
                {
                    double value = (double)toggleButton.Data ["Value"];
                    bankNotesAndMoneyBuilder.Append(value.ToString(CultureInfo.InvariantCulture.NumberFormat) + ';');
                }
            }

            if (string.IsNullOrEmpty(bankNotesAndMoneyBuilder.ToString()))
            {
                MessageError.ShowDialog(Translator.GetString("You must have at least one bank note or coin type selected."),
                                        ErrorSeverity.Error);
                return;
            }

            bankNotesAndMoneyBuilder.Remove(bankNotesAndMoneyBuilder.Length - 1, 1);
            bankNotesAndCoins = bankNotesAndMoneyBuilder.ToString();
            BusinessDomain.AppConfiguration.BankNotesAndCoins = bankNotesAndCoins;

            dlgChooseBankNotesAndCoins.Respond(ResponseType.Ok);
        }
Exemplo n.º 2
0
        private bool Validate()
        {
            if (!Percent.IsValidExpression(txtValue.Text))
            {
                MessageError.ShowDialog(Translator.GetString("Invalid percent value!"));
                txtValue.GrabFocus();
                return(false);
            }

            return(GetVATGroup().Validate((message, severity, code, state) =>
            {
                using (MessageError dlgError = new MessageError(message, severity))
                    if (severity == ErrorSeverity.Warning)
                    {
                        dlgError.Buttons = MessageButtons.YesNo;
                        if (dlgError.Run() != ResponseType.Yes)
                        {
                            return false;
                        }
                    }
                    else
                    {
                        dlgError.Run();
                        return false;
                    }

                return true;
            }, null));
        }
Exemplo n.º 3
0
        protected override bool DeleteEntity(Partner entity)
        {
            selectedId = entity.Id;

            switch (Partner.RequestDelete(entity.Id))
            {
            case DeletePermission.InUse:
                string title       = Translator.GetString("Partner in Use");
                string translation = Translator.GetString(
                    "The partner \"{0}\" cannot be deleted, because it is used in operations. Do you want to move it to the \"Deleted\" group?");
                string message = string.Format(translation, entity.Name);

                if (Message.ShowDialog(title, "Icons.Partner16.png", message, "Icons.Question32.png",
                                       MessageButtons.YesNo) == ResponseType.Yes)
                {
                    entity.Deleted = true;
                    entity.GroupId = PartnersGroup.DefaultGroupId;
                    entity.CommitChanges();
                    return(true);
                }
                return(false);

            case DeletePermission.Reserved:
            case DeletePermission.No:
                MessageError.ShowDialog(
                    string.Format(Translator.GetString("Cannot delete partner \"{0}\"!"), entity.Name),
                    "Icons.Partner16.png");
                return(false);
            }

            Partner.Delete(entity.Id);
            return(true);
        }
Exemplo n.º 4
0
        private bool Validate()
        {
            if (!GetUser().Validate((message, severity, code, state) =>
            {
                using (MessageError dlgError = new MessageError(message, severity))
                    if (severity == ErrorSeverity.Warning)
                    {
                        dlgError.Buttons = MessageButtons.YesNo;
                        if (dlgError.Run() != ResponseType.Yes)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        dlgError.Run();
                        return(false);
                    }

                return(true);
            }, null))
            {
                return(false);
            }

            if (txtPassword1.Text != txtPassword2.Text)
            {
                MessageError.ShowDialog(Translator.GetString("Wrong password confirmation!"));
                return(false);
            }

            return(true);
        }
        protected virtual void btnOK_Clicked(object o, EventArgs args)
        {
            if (total == 0)
            {
                MessageError.ShowDialog(Translator.GetString("Please select a valid cash amount before proceeding!"));
                return;
            }

            if (!FormHelper.TryReceiptPrinterCommand(delegate
            {
                BusinessDomain.DeviceManager.TryDeviceCommand(delegate
                {
                    if (rbnCashInput.Active)
                    {
                        cashReceiptDriver.RegisterCash(total, txvCashDescription.Buffer.Text, txvReason.Buffer.Text);
                    }
                    else if (rbnCashOutput.Active)
                    {
                        cashReceiptDriver.RegisterCash(-total, txvCashDescription.Buffer.Text, txvReason.Buffer.Text);
                    }
                });
            }))
            {
                return;
            }

            dlgFiscalRegisterCash.Respond(ResponseType.Ok);
        }
Exemplo n.º 6
0
        protected override void btnImport_Clicked(object o, EventArgs args)
        {
            if (!User.CheckOwnerExists())
            {
                string text = Translator.GetString("You need to add an owner before you can import users.");
                MessageError.ShowDialog(text, ErrorSeverity.Error);
                return;
            }

            int  selectedRow = grid.FocusedRow;
            long?groupId     = null;

            if (selectedRow >= 0)
            {
                selectedId = entities [selectedRow].Id;
                groupId    = entities [selectedRow].GroupId;
            }

            // Added transaction to ensure that we are connected to the same server in case of
            // master-slave replication
            using (new DbMasterScope(BusinessDomain.DataAccessProvider)) {
                FormHelper.ImportData <User> (CustomValidate);
                OnEntitiesChanged(groupId);
            }
        }
Exemplo n.º 7
0
        protected override void btnGroupDelete_Clicked(object sender, EventArgs e)
        {
            G group = groupsPanel.GetSelectedGroup();
            DeletePermission permission = GetDeletePermission(group);

            switch (permission)
            {
            case DeletePermission.InUse:
                MessageError.ShowDialog(
                    Translator.GetString("This group cannot be deleted, because it is not empty. Please, delete or move to another group the contents of this group in order to be able to delete it!"),
                    "Icons.Group16.png");
                return;

            case DeletePermission.Reserved:
            case DeletePermission.No:
                MessageError.ShowDialog(
                    string.Format(Translator.GetString("Cannot delete group \"{0}\"!"), group.Name),
                    "Icons.Group16.png");
                return;
            }

            DeleteGroup(group);
            ReinitializeGrid(true, @group.Parent != null ? @group.Parent.Id : -1);
            OnGroupDeleted();
        }
Exemplo n.º 8
0
        private bool Validate()
        {
            foreach (KeyValuePair <Entry, string> pair in priceGroupWarnings)
            {
                Entry txtPrice = pair.Key;
                if (Currency.IsValidExpression(txtPrice.Text))
                {
                    continue;
                }

                MessageError.ShowDialog(pair.Value);
                SelectInvalidPrice(txtPrice);
                return(false);
            }

            if (!CheckPricesSaleLessThanPurchase())
            {
                return(false);
            }

            Item ret = GetItem();

            if (string.IsNullOrWhiteSpace(ret.MUnit))
            {
                if (!OnValidateCallback(Translator.GetString("Measurement unit cannot be empty!"), ErrorSeverity.Error, (int)Item.ErrorCodes.MeasUnitEmpty, null))
                {
                    return(false);
                }
            }

            BusinessDomain.AppConfiguration.CustomGeneratedBarcodeType   = (GeneratedBarcodeType)cboBarcodeType.GetSelectedValue();
            BusinessDomain.AppConfiguration.CustomGeneratedBarcodeFormat = txtBarcodeFormat.Text;

            return(GetItem().Validate(OnValidateCallback, null));
        }
Exemplo n.º 9
0
        protected virtual bool SaveDocument(FinalizeAction action = FinalizeAction.CommitDocument)
        {
            if (sale != null && chkPrintCashReceipt.Active)
            {
                action |= FinalizeAction.PrintCashReceipt | FinalizeAction.CollectSaleData;

                if (sale.IsVATExempt || (sale.VAT.IsZero() && sale.Total > 0))
                {
                    if (VATGroup.GetExemptGroup() == null)
                    {
                        MessageError.ShowDialog(string.Format(Translator.GetString("To print a receipt for a document without VAT you need to define a 0% VAT group in {0} and in the receipt printer if necessary!"), DataHelper.ProductName));
                        return(false);
                    }
                }
            }

            HardwareErrorResponse res;

            do
            {
                res.Retry = false;
                try {
                    BusinessDomain.DeviceManager.FinalizeOperation(new FinalizeOperationOptions {
                        Sale = sale, Document = document, Action = action
                    });
                } catch (InvoiceNumberInUseException ex) {
                    txtNumber.SelectRegion(0, txtNumber.Text.Length);
                    MessageError.ShowDialog(
                        Translator.GetString("The entered document number already exists!"),
                        ErrorSeverity.Error, ex);
                    return(false);
                } catch (HardwareErrorException ex) {
                    res = FormHelper.HandleHardwareError(ex);
                    if (!res.Retry)
                    {
                        dlgEditNewDocument.Respond(ResponseType.Cancel);
                        return(false);
                    }
                } catch (InsufficientItemAvailabilityException ex) {
                    MessageError.ShowDialog(
                        string.Format(Translator.GetString("The document cannot be saved due to insufficient quantities of item \"{0}\"."), ex.ItemName),
                        ErrorSeverity.Warning, ex);
                    dlgEditNewDocument.Respond(ResponseType.Cancel);
                    return(false);
                } catch (Exception ex) {
                    MessageError.ShowDialog(
                        Translator.GetString("An error occurred while saving the document!"),
                        ErrorSeverity.Error, ex);
                    dlgEditNewDocument.Respond(ResponseType.Cancel);
                    return(false);
                }
            } while (res.Retry);

            if (sale != null)
            {
                document.Signature = sale.Signature;
            }

            return(true);
        }
Exemplo n.º 10
0
        protected override void btnEdit_Clicked(object o, EventArgs args)
        {
            if (grid.Selection.Count <= 0)
            {
                MessageError.ShowDialog(Translator.GetString("Please select an operation to edit a payment of."), ErrorSeverity.Error);
                return;
            }

            Payment selectedPayment = entities [grid.Selection [0]];
            string  message;

            if (!BusinessDomain.CanEditPayment(selectedPayment, out message))
            {
                MessageError.ShowDialog(message);
                return;
            }

            selectedId = selectedPayment.Id;
            if (selectedPayment.OperationType == (int)OperationType.AdvancePayment)
            {
                using (new DbMasterScope(BusinessDomain.DataAccessProvider))
                    using (EditNewAdvancePayment dialog = new EditNewAdvancePayment(selectedPayment)) {
                        if (dialog.Run() != ResponseType.Ok || dialog.Payments.Count == 0)
                        {
                            return;
                        }

                        foreach (Payment payment in dialog.Payments)
                        {
                            payment.EditAdvance();
                        }

                        dialog.PrintPayments(dialog.Payments);
                        ReinitializeGrid(true, null);
                        return;
                    }
            }

            Operation operation = GetOperationOfSelectedPayment();

            if (operation == null)
            {
                return;
            }

            using (new DbMasterScope(BusinessDomain.DataAccessProvider))
                using (EditNewPayment dialog = new EditNewPayment(operation)) {
                    if (dialog.Run() != ResponseType.Ok)
                    {
                        return;
                    }

                    operation.CommitPayments();
                    dialog.PrintPayments(dialog.OriginalPayments, operation);
                    ReinitializeGrid(true, null);
                }
        }
Exemplo n.º 11
0
        protected void btnOK_Clicked(object o, EventArgs args)
        {
            if (IsEditable)
            {
                if (!CheckEntries())
                {
                    return;
                }

                SetDocumentFields();

                SaveOperationPartner();

                if (!SaveDocument())
                {
                    return;
                }

                BusinessDomain.AppConfiguration.LastDocumentPaymentMethodId = (long)cboPaymentType.GetSelectedValue();
            }
            else
            {
                SetDocumentFields();
                if (!SaveDocument(FinalizeAction.None))
                {
                    return;
                }
            }

            try {
                if (isPrintable && (chkPrintOriginal.Active || chkPrintCopy.Active || chkPrintInternational.Active))
                {
                    document.PrintOriginal      = chkPrintOriginal.Active;
                    document.PrintCopies        = chkPrintCopy.Active ? spnPrintCopy.ValueAsInt : 0;
                    document.PrintInternational = chkPrintInternational.Active;

                    document.IsOriginal = document.PrintOriginal;

                    // Hide this dialog so the preview can show on a clean screen
                    dlgEditNewDocument.Hide();
                    DocumentBase doc = document;
                    if (!document.PrintOriginal && document.PrintInternational)
                    {
                        doc            = document.GetInternational();
                        doc.IsOriginal = null;
                    }
                    FormHelper.PrintPreviewObject(doc);
                }

                dlgEditNewDocument.Respond(ResponseType.Ok);
            } catch (Exception ex) {
                MessageError.ShowDialog(GetErrorWhileGeneratingMessage(), ErrorSeverity.Error, ex);

                dlgEditNewDocument.Respond(ResponseType.Cancel);
            }
        }
Exemplo n.º 12
0
        protected void btnOK_Clicked(object o, EventArgs args)
        {
            if (selected.Count == 0)
            {
                MessageError.ShowDialog(Translator.GetString("Please select at least one payment type."), ErrorSeverity.Error);
                return;
            }

            dlgChoosePaymentTypes.Respond(ResponseType.Ok);
        }
Exemplo n.º 13
0
 private bool Validate()
 {
     if (txtEmail.Visible && !Validator.CheckEmail(txtEmail.Text.Trim()))
     {
         MessageError.ShowDialog(Translator.GetString("The entered e-mail address is invalid."));
         txtEmail.GrabFocus();
         return(false);
     }
     return(true);
 }
Exemplo n.º 14
0
        protected override void btnOK_Clicked(object o, System.EventArgs args)
        {
            if (!SelectedItem.CheckIsNewFormat())
            {
                MessageError.ShowDialog(string.Format(Translator.GetString("This stock-taking cannot be edited because it is created with an older version of {0}! Only new stock-taking operations can be edited."), DataHelper.ProductName));
                return;
            }

            base.btnOK_Clicked(o, args);
        }
Exemplo n.º 15
0
 private bool Validate()
 {
     if (rbPriceGroup.Active && ArithmeticOperation == OperatorType.Divide && PriceGroupValue.IsZero())
     {
         MessageError.ShowDialog(Translator.GetString("Division by zero is impossible."));
         txtPriceGroupValue.GrabFocus();
         return(false);
     }
     return(true);
 }
Exemplo n.º 16
0
        protected virtual void btnOK_Clicked(object o, EventArgs args)
        {
            string locName = txtExchangeLocation.Text;

            if (usesLocation && location == null && !string.IsNullOrWhiteSpace(locName) && txtExchangeLocation.Sensitive)
            {
                Location loc = Location.GetByCode(locName) ?? Location.GetByName(locName);
                if (loc != null)
                {
                    SetLocation(loc);
                }
                else
                {
                    MessageError.ShowDialog(string.Format(Translator.GetString("A location \"{0}\" cannot be found!"), locName));
                    return;
                }
            }

            if (chkExchangeFile.Active)
            {
                if (string.IsNullOrWhiteSpace(txtExchangeFile.Text))
                {
                    MessageError.ShowDialog(Translator.GetString("No file selected for export!"));
                    return;
                }

                string dir = Path.GetDirectoryName(txtExchangeFile.Text);
                if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir))
                {
                    try {
                        Directory.CreateDirectory(dir);
                    } catch (Exception ex) {
                        MessageError.ShowDialog(string.Format(Translator.GetString("Error occurred while creating folder \"{0}\". Please check if you have write permissions to that location."), dir), ErrorSeverity.Warning, ex);
                        return;
                    }
                }
            }

            if (chkEmail.Active)
            {
                if (string.IsNullOrEmpty(txtEmail.Text))
                {
                    MessageError.ShowDialog(Translator.GetString("No e-mail recipients entered!"));
                    return;
                }

                if (string.IsNullOrEmpty(txtEmailSubject.Text))
                {
                    MessageError.ShowDialog(Translator.GetString("No e-mail subject entered!"));
                    return;
                }
            }

            dlgExchangeObjects.Respond(ResponseType.Ok);
        }
Exemplo n.º 17
0
 protected void btnOK_Clicked(object o, EventArgs args)
 {
     Item = Business.Entities.Item.GetByAny(txtItem.Text);
     if (Item == null)
     {
         MessageError.ShowDialog(Translator.GetString("Please select a valid item."), ErrorSeverity.Error);
         txtItem.GrabFocus();
         return;
     }
     dlgAddServiceCharge.Respond(ResponseType.Ok);
 }
Exemplo n.º 18
0
 private static void ReinitializeHardware(Device oldItem, Device newItem)
 {
     BusinessDomain.ReinitializeHardware(oldItem, newItem,
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the cash receipt device. Check the input parameters.")),
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the receipt device. Check the input parameters.")),
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the external display. Check the input parameters.")),
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the card reader device. Check the input parameters.")),
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the electronic scale. Check the input parameters.")),
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the sales data controller. Check the input parameters.")),
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the kitchen printer. Check the input parameters.")),
                                         () => MessageError.ShowDialog(Translator.GetString("An error occurred while connecting to the barcode scanner. Check the input parameters.")));
 }
Exemplo n.º 19
0
        protected override void AnnulOperation()
        {
            StockTaking stockTaking = SelectedItem;

            if (!stockTaking.CheckIsNewFormat())
            {
                MessageError.ShowDialog(string.Format(Translator.GetString("This stock-taking cannot be annulled because it is created with an older version of {0}! Only new stock-taking operations can be annulled."), DataHelper.ProductName));
                return;
            }

            stockTaking.Annul();
        }
Exemplo n.º 20
0
        private bool Validate()
        {
            string name = txtName.Text.Trim();

            if (name.Length == 0)
            {
                MessageError.ShowDialog(Translator.GetString("Payment type name cannot be empty!"));
                return(false);
            }

            return(true);
        }
Exemplo n.º 21
0
 private void btnTest_Clicked(object sender, EventArgs e)
 {
     if (ReLoadDatabases())
     {
         MessageError.ShowDialog(Translator.GetString("The connection to the server was successful."),
                                 "Icons.Database32.png", ErrorSeverity.Information);
     }
     else
     {
         MessageError.ShowDialog(Translator.GetString("The connection to the server was not successful!"),
                                 "Icons.Database32.png");
     }
 }
        private bool Validate()
        {
            if (hasEmptyRange)
            {
                MessageError.ShowDialog(emptyRangeMessage);
                return(false);
            }

            var  maxId      = Operation.GetMaxId();
            bool userWarned = false;

            for (int i = allStartNumbersPerLocation.Count - 1; i >= 0; i--)
            {
                foreach (OperationNumberingInfo numberingInfo in allStartNumbersPerLocation[i].Value)
                {
                    long endRange = maxId;
                    OperationNumberingInfo nextInfo = null;
                    if (i + 1 < allStartNumbersPerLocation.Count)
                    {
                        nextInfo = allStartNumbersPerLocation [i + 1].Value.FirstOrDefault(n => n.OperationType == numberingInfo.OperationType);
                        if (nextInfo != null)
                        {
                            endRange = nextInfo.StartNumber - 2;
                        }
                    }

                    long rangeSize = Math.Max(endRange - numberingInfo.StartNumber, 0);
                    if (rangeSize < OperationNumberingInfo.MINIMAL_NUMBERS_PER_LOCATION)
                    {
                        MessageError.ShowDialog(GetShortRangeWarning(numberingInfo, nextInfo, true, maxId), ErrorSeverity.Error);
                        SelectDocumentType(numberingInfo);
                        return(false);
                    }

                    if (userWarned || rangeSize >= OperationNumberingInfo.RECOMMENDED_NUMBERS_PER_LOCATION - 2)
                    {
                        continue;
                    }

                    if (Message.ShowDialog(Translator.GetString("Document Numbers per Location"), string.Empty,
                                           string.Format(GetShortRangeWarning(numberingInfo, nextInfo, false, maxId), OperationNumberingInfo.RECOMMENDED_NUMBERS_PER_LOCATION), "Icons.Warning32.png",
                                           MessageButtons.YesNo) == ResponseType.No)
                    {
                        SelectDocumentType(numberingInfo);
                        return(false);
                    }
                    userWarned = true;
                }
            }
            return(true);
        }
        private static bool ValidateDate(ref DateTime?date, Entry txtDate)
        {
            DateTime result = BusinessDomain.GetDateValue(txtDate.Text.Trim());

            if (result == DateTime.MinValue)
            {
                MessageError.ShowDialog(Translator.GetString("The entered date is invalid."), ErrorSeverity.Error);

                txtDate.GrabFocus();
                txtDate.SelectRegion(0, txtDate.Text.Length);
                return(false);
            }

            date = result;
            return(true);
        }
Exemplo n.º 24
0
        private void PresentationDomain_CardRecognized(object sender, CardReadArgs e)
        {
            User user = User.GetByCard(e.CardId);

            if (user == null)
            {
                MessageError.ShowDialog(Translator.GetString("Invalid card!"));
                txtPassword.GrabFocus();
                return;
            }

            BusinessDomain.LoggedUser = user;
            BusinessDomain.AppConfiguration.LastLoggedUID = user.Id;

            dlgUserLogin.Respond(ResponseType.Ok);
        }
Exemplo n.º 25
0
        private bool CheckNoDuplicateConditionType(PriceRule.ConditionType conditionType, bool isException)
        {
            PriceRuleCondition existingCondition = priceRule.Conditions.Find(c => c.Type == conditionType &&
                                                                             c.IsException == !isException);

            if (existingCondition == null || !existingCondition.IsActive)
            {
                return(true);
            }

            MessageError.ShowDialog(isException ?
                                    Translator.GetString("There is already a condition of this type.") :
                                    Translator.GetString("There is already an exception of this type."), ErrorSeverity.Error);

            return(false);
        }
Exemplo n.º 26
0
        protected override void btnOK_Clicked(object o, EventArgs args)
        {
            if (Exchanger.UsesFile && string.IsNullOrWhiteSpace(txtExchangeFile.Text))
            {
                MessageError.ShowDialog(Translator.GetString("Please specify an import file before continuing."));
                return;
            }

            BusinessDomain.AppConfiguration.LastImportFolder = Folder;
            if (grid.Selection.Count > 0)
            {
                BusinessDomain.AppConfiguration.LastImporter = exchangersModel [grid.Selection [0]].GetType().Name;
            }

            base.btnOK_Clicked(o, args);
        }
Exemplo n.º 27
0
        protected override void btnAnnul_Clicked(object o, EventArgs args)
        {
            if (Message.ShowDialog(GetAnnulTitle(), string.Empty, GetAnnulQuestion(), "Icons.Question32.png",
                                   MessageButtons.YesNo) != ResponseType.Yes)
            {
                return;
            }

            string error;
            string warning;

            if (!BusinessDomain.CanAnnulOperation(SelectedItem, out error, out warning))
            {
                if (warning != null)
                {
                    if (MessageError.ShowDialog(warning, buttons: MessageButtons.YesNo) != ResponseType.Yes)
                    {
                        return;
                    }
                }
                else
                {
                    MessageError.ShowDialog(error);
                    return;
                }
            }

            try {
                AnnulOperation();
                GetEntities();
                grid.Model = entities;
                if (btnPreview.Active)
                {
                    previewWidget.LoadOperation(SelectedItem);
                }
            } catch (ArgumentException) {
            } catch (InsufficientItemAvailabilityException ex) {
                if (btnPreview.Active)
                {
                    previewWidget.LoadOperation(SelectedItem);
                }

                MessageError.ShowDialog(string.Format(Translator.GetString("The operation cannot be annulled " +
                                                                           "because the annulment will cause negative availability of item \"{0}\"."), ex.ItemName),
                                        ErrorSeverity.Warning, ex);
            }
        }
Exemplo n.º 28
0
        private void btnNew_Clicked(object sender, EventArgs e)
        {
            if (!BusinessDomain.TryConnect(DbProvider, Server, SlaveServer, User, Password))
            {
                MessageError.ShowDialog(Translator.GetString("The connection to the server was not successful!"),
                                        "Icons.Database32.png");
                return;
            }

            CreateDatabaseType dbType;

            using (NewDatabase dlgNewDB = new NewDatabase()) {
                ResponseType response = dlgNewDB.Run();
                if (response == ResponseType.Apply)
                {
                    BusinessDomain.AppConfiguration.DbDatabase = dlgNewDB.DatabaseName;
                    ReLoadDatabases();
                }

                if (response != ResponseType.Ok)
                {
                    return;
                }

                dbType = dlgNewDB.DatabaseType;

                // Set the new database as the only one as at this point we are closing the dialog and we don't nee the full list
                cboDatabase.Load(new [] { dlgNewDB.DatabaseName }, null, null, null);
            }

            // Unclutter the screen by hiding the background dialog which is no longer needed anyway
            dlgEditDBConnection.Hide();
            if (dbType == CreateDatabaseType.Blank)
            {
                SetSettings();
                BusinessDomain.AppConfiguration.Load(false);

                using (Assistant assistant = new Assistant(AssistType.DatabaseSetup))
                    assistant.Run();

                BusinessDomain.AppConfiguration.Save(true);
            }

            dlgEditDBConnection.Respond(ResponseType.Ok);
        }
Exemplo n.º 29
0
        private bool ValidateDate()
        {
            DateTime date = BusinessDomain.GetDateValue(txtDueDate.Text.Trim());

            if (date == DateTime.MinValue)
            {
                MessageError.ShowDialog(Translator.GetString("The entered date is invalid."), ErrorSeverity.Error);
                txtDueDate.GrabFocus();
                return(false);
            }

            if (date >= operation.Date)
            {
                return(true);
            }

            ShowMessageTooEarlyDate();
            return(false);
        }
Exemplo n.º 30
0
        protected override bool DeleteEntity(User entity)
        {
            selectedId = entity.Id;

            User loggedUser = BusinessDomain.LoggedUser;

            if (loggedUser.UserLevel != UserAccessLevel.Owner &&
                entity.UserLevel >= loggedUser.UserLevel)
            {
                MessageError.ShowDialog(Translator.GetString("Deleting users with access level higher or equal of the current\'s one is not allowed!"));
                return(false);
            }

            if (entity.Id == loggedUser.Id)
            {
                MessageError.ShowDialog(Translator.GetString("Cannot delete the currently active user!"));
                return(false);
            }

            switch (User.RequestDelete(entity.Id))
            {
            case DeletePermission.InUse:
                if (Message.ShowDialog(Translator.GetString("User in Use"), "Icons.User16.png",
                                       string.Format(Translator.GetString("The user \"{0}\" cannot be deleted, because it is used in operations. Do you want to move it to the \"Deleted\" group?"), entity.Name), "Icons.Question32.png",
                                       MessageButtons.YesNo) == ResponseType.Yes)
                {
                    entity.Deleted = true;
                    entity.GroupId = UsersGroup.DefaultGroupId;
                    entity.CommitChanges();
                    return(true);
                }
                return(false);

            case DeletePermission.Reserved:
            case DeletePermission.No:
                MessageError.ShowDialog(string.Format(Translator.GetString("Cannot delete user \"{0}\"!"), entity.Name),
                                        "Icons.User16.png");
                return(false);
            }

            User.Delete(entity.Id, true);
            return(true);
        }