public GetCurrentFiscalYearCodeController()
        {
            this._LoginId  = AppUsers.GetCurrent().View.LoginId.ToLong();
            this._UserId   = AppUsers.GetCurrent().View.UserId.ToInt();
            this._OfficeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
            this._Catalog  = AppUsers.GetCurrentUserDB();

            this.repository = new GetCurrentFiscalYearCodeProcedure
            {
                _Catalog = this._Catalog,
                _LoginId = this._LoginId,
                _UserId  = this._UserId
            };
        }
Esempio n. 2
0
        public IndustryController()
        {
            this._LoginId  = AppUsers.GetCurrent().View.LoginId.ToLong();
            this._UserId   = AppUsers.GetCurrent().View.UserId.ToInt();
            this._OfficeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
            this._Catalog  = AppUsers.GetCurrentUserDB();

            this.IndustryRepository = new MixERP.Net.Schemas.Core.Data.Industry
            {
                _Catalog = this._Catalog,
                _LoginId = this._LoginId,
                _UserId  = this._UserId
            };
        }
Esempio n. 3
0
        public CultureController()
        {
            this._LoginId  = AppUsers.GetCurrent().View.LoginId.ToLong();
            this._UserId   = AppUsers.GetCurrent().View.UserId.ToInt();
            this._OfficeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
            this._Catalog  = AppUsers.GetCurrentUserDB();

            this.CultureRepository = new MixERP.Net.Schemas.Localization.Data.Culture
            {
                _Catalog = this._Catalog,
                _LoginId = this._LoginId,
                _UserId  = this._UserId
            };
        }
Esempio n. 4
0
        public GetCashFlowStatementController()
        {
            this._LoginId  = AppUsers.GetCurrent().View.LoginId.ToLong();
            this._UserId   = AppUsers.GetCurrent().View.UserId.ToInt();
            this._OfficeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
            this._Catalog  = AppUsers.GetCurrentUserDB();

            this.repository = new GetCashFlowStatementProcedure
            {
                _Catalog = this._Catalog,
                _LoginId = this._LoginId,
                _UserId  = this._UserId
            };
        }
Esempio n. 5
0
        public OfficeWorkCenterController()
        {
            this._LoginId  = AppUsers.GetCurrent().View.LoginId.ToLong();
            this._UserId   = AppUsers.GetCurrent().View.UserId.ToInt();
            this._OfficeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
            this._Catalog  = AppUsers.GetCurrentUserDB();

            this.WorkCenterRepository = new MixERP.Net.Schemas.Office.Data.WorkCenter
            {
                _Catalog = this._Catalog,
                _LoginId = this._LoginId,
                _UserId  = this._UserId
            };
        }
        public SalesTaxExemptController()
        {
            this._LoginId  = AppUsers.GetCurrent().View.LoginId.ToLong();
            this._UserId   = AppUsers.GetCurrent().View.UserId.ToInt();
            this._OfficeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
            this._Catalog  = AppUsers.GetCurrentUserDB();

            this.SalesTaxExemptRepository = new MixERP.Net.Schemas.Core.Data.SalesTaxExempt
            {
                _Catalog = this._Catalog,
                _LoginId = this._LoginId,
                _UserId  = this._UserId
            };
        }
        public MenuPolicyController()
        {
            this._LoginId  = AppUsers.GetCurrent().View.LoginId.ToLong();
            this._UserId   = AppUsers.GetCurrent().View.UserId.ToInt();
            this._OfficeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
            this._Catalog  = AppUsers.GetCurrentUserDB();

            this.MenuPolicyRepository = new MixERP.Net.Schemas.Policy.Data.MenuPolicy
            {
                _Catalog = this._Catalog,
                _LoginId = this._LoginId,
                _UserId  = this._UserId
            };
        }
        public GetFlagBackgroundColorController()
        {
            this._LoginId  = AppUsers.GetCurrent().View.LoginId.ToLong();
            this._UserId   = AppUsers.GetCurrent().View.UserId.ToInt();
            this._OfficeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
            this._Catalog  = AppUsers.GetCurrentUserDB();

            this.repository = new GetFlagBackgroundColorProcedure
            {
                _Catalog = this._Catalog,
                _LoginId = this._LoginId,
                _UserId  = this._UserId
            };
        }
Esempio n. 9
0
        public IsCashAccountIdController()
        {
            this._LoginId  = AppUsers.GetCurrent().View.LoginId.ToLong();
            this._UserId   = AppUsers.GetCurrent().View.UserId.ToInt();
            this._OfficeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
            this._Catalog  = AppUsers.GetCurrentUserDB();

            this.repository = new IsCashAccountIdProcedure
            {
                _Catalog = this._Catalog,
                _LoginId = this._LoginId,
                _UserId  = this._UserId
            };
        }
        public TaxRateTypeSelectorViewController()
        {
            this._LoginId  = AppUsers.GetCurrent().View.LoginId.ToLong();
            this._UserId   = AppUsers.GetCurrent().View.UserId.ToInt();
            this._OfficeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
            this._Catalog  = AppUsers.GetCurrentUserDB();

            this.TaxRateTypeSelectorViewRepository = new MixERP.Net.Schemas.Core.Data.TaxRateTypeSelectorView
            {
                _Catalog = this._Catalog,
                _LoginId = this._LoginId,
                _UserId  = this._UserId
            };
        }
Esempio n. 11
0
        public AutoVerifyController()
        {
            this._LoginId  = AppUsers.GetCurrent().View.LoginId.ToLong();
            this._UserId   = AppUsers.GetCurrent().View.UserId.ToInt();
            this._OfficeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
            this._Catalog  = AppUsers.GetCurrentUserDB();

            this.repository = new AutoVerifyProcedure
            {
                _Catalog = this._Catalog,
                _LoginId = this._LoginId,
                _UserId  = this._UserId
            };
        }
Esempio n. 12
0
        private void CheckAccessLevel()
        {
            var    login     = AppUsers.GetCurrent();
            bool   hasAccess = true;
            string userName  = string.Empty;
            string ipAddress = string.Empty;

            if (login == null || login.View == null)
            {
                hasAccess = false;
            }
            else
            {
                userName  = AppUsers.GetCurrent().View.UserName;
                ipAddress = AppUsers.GetCurrent().View.IpAddress;

                string isDevelopmentModeString = DbConfig.GetMixERPParameter(AppUsers.GetCurrentUserDB(), "Mode")
                                                 .ToUpperInvariant();

                bool isDevelopmentMode = isDevelopmentModeString.Equals("DEVELOPMENT");


                bool isLocalHost = PageUtility.IsLocalhost(this.Page);
                bool adminOnly   = (this.AccessLevel.Equals(AccessLevel.AdminOnly) ||
                                    this.AccessLevel.Equals(AccessLevel.LocalhostAdmin));


                if (adminOnly)
                {
                    hasAccess = AppUsers.GetCurrent().View.IsAdmin.ToBool();
                }

                if (hasAccess && isDevelopmentMode)
                {
                    if (this.AccessLevel.Equals(AccessLevel.LocalhostAdmin) && !isLocalHost)
                    {
                        hasAccess = false;
                    }
                }
            }

            if (!hasAccess)
            {
                Log.Information("Access to {Control} is denied to {User} from {IP}.", this,
                                userName, ipAddress);

                this.Page.Server.Transfer("~/Site/AccessIsDenied.aspx");
            }
        }
Esempio n. 13
0
        public Collection <ListItem> GetItemGroups()
        {
            Collection <ListItem> values = new Collection <ListItem>();

            foreach (ItemGroup item in ItemGroups.GetItemGroups(AppUsers.GetCurrentUserDB()))
            {
                values.Add(new ListItem
                {
                    Text  = item.ItemGroupCode + " (" + item.ItemGroupName + ")",
                    Value = item.ItemGroupId.ToString(CultureInfo.InvariantCulture)
                });
            }

            return(values);
        }
Esempio n. 14
0
        public Collection <ListItem> GetCashRepositoriesByAccountNumber(string accountNumber)
        {
            Collection <ListItem> values = new Collection <ListItem>();

            if (AccountHelper.IsCashAccount(AppUsers.GetCurrentUserDB(), accountNumber))
            {
                int officeId = AppUsers.GetCurrentLogin().View.OfficeId.ToInt();
                foreach (CashRepository cashRepository in CashRepositories.GetCashRepositories(AppUsers.GetCurrentUserDB(), officeId))
                {
                    values.Add(new ListItem(cashRepository.CashRepositoryName, cashRepository.CashRepositoryCode));
                }
            }

            return(values);
        }
Esempio n. 15
0
        public bool SaveExchangeRates(List <Data.Models.ExchangeRate> exchangeRates)
        {
            if (exchangeRates == null || exchangeRates.Count().Equals(0))
            {
                return(false);
            }

            string catalog      = AppUsers.GetCurrentUserDB();
            int    officeId     = AppUsers.GetCurrentLogin().View.OfficeId.ToInt();
            string baseCurrency = AppUsers.GetCurrentLogin().View.CurrencyCode;


            ExchangeRates.SaveExchangeRates(catalog, officeId, baseCurrency, exchangeRates);
            return(true);
        }
Esempio n. 16
0
        public Collection <ListItem> GetStores()
        {
            int userId   = AppUsers.GetCurrentLogin().View.UserId.ToInt();
            int officeId = AppUsers.GetCurrentLogin().View.OfficeId.ToInt();
            Collection <ListItem> values = new Collection <ListItem>();

            IEnumerable <Store> stores = Stores.GetStores(AppUsers.GetCurrentUserDB(), officeId, userId);

            foreach (Store store in stores)
            {
                values.Add(new ListItem(store.StoreName, store.StoreId.ToString(CultureInfo.InvariantCulture)));
            }

            return(values);
        }
Esempio n. 17
0
        public Collection <ListItem> GetCurrenciesByAccountNumber(string accountNumber)
        {
            Collection <ListItem> values = new Collection <ListItem>();

            if (string.IsNullOrWhiteSpace(accountNumber))
            {
                return(values);
            }

            string currencyCode = Currencies.GetCurrencyCode(AppUsers.GetCurrentUserDB(), accountNumber);

            values.Add(new ListItem(currencyCode, currencyCode));

            return(values);
        }
Esempio n. 18
0
        public Collection <ListItem> GetCashRepositories()
        {
            Collection <ListItem> values = new Collection <ListItem>();

            int officeId = AppUsers.GetCurrent().View.OfficeId.ToInt();

            foreach (
                CashRepository cashRepository in
                CashRepositories.GetCashRepositories(AppUsers.GetCurrentUserDB(), officeId))
            {
                values.Add(new ListItem(cashRepository.CashRepositoryName,
                                        cashRepository.CashRepositoryId.ToString(CultureInfo.InvariantCulture)));
            }
            return(values);
        }
Esempio n. 19
0
        private void AddGridView()
        {
            int officeId = AppUsers.GetCurrentLogin().View.OfficeId.ToInt();

            using (GridView grid = new GridView())
            {
                grid.GridLines = GridLines.None;
                this.CreateColumns(grid);
                grid.DataSource          = Data.Transactions.Reorder.GetReorderView(AppUsers.GetCurrentUserDB(), officeId);
                grid.ID                  = "ReorderGrid";
                grid.AutoGenerateColumns = false;
                grid.DataBind();
                this.Placeholder1.Controls.Add(grid);
            }
        }
Esempio n. 20
0
        private void LoadWidgets()
        {
            string group = this.WidgetDropDownList.SelectedValue;

            this.SelectedWidgetPlaceholder.Controls.Clear();
            this.OtherWidgetPlaceholder.Controls.Clear();

            var selected = Data.Core.Widget.GetWidgetSetupView(AppUsers.GetCurrentUserDB(), group).ToList();

            this.LoadSelectedWidgets(selected, this.SelectedWidgetPlaceholder, this.Page);

            var other = Data.Core.Widget.GetNonSelectedWidgets(AppUsers.GetCurrentUserDB(), group).ToList();

            this.LoadOtherWidgets(other, this.OtherWidgetPlaceholder, this.Page);
        }
Esempio n. 21
0
        private void Flag_Updated(object sender, FlagUpdatedEventArgs e)
        {
            int flagTypeId = e.FlagId;

            const string resource    = "account_statement";
            const string resourceKey = "transaction_code";

            int userId = AppUsers.GetCurrent().View.UserId.ToInt();

            Flags.CreateFlag(AppUsers.GetCurrentUserDB(), userId, flagTypeId, resource, resourceKey,
                             this.GetSelectedValues());

            this.BindGridView();
            this.CreateAccountOverviewPanel(this.accountOverviewTab);
        }
Esempio n. 22
0
        public override void OnControlLoad(object sender, EventArgs e)
        {
            using (StockTransactionForm product = new StockTransactionForm())
            {
                product.Book           = TranBook.Purchase;
                product.SubBook        = SubTranBook.Receipt;
                product.Text           = Titles.GoodsReceiptNote;
                product.ShowStore      = true;
                product.ShowCostCenter = true;
                product.Catalog        = AppUsers.GetCurrentUserDB();
                product.OfficeId       = AppUsers.GetCurrent().View.OfficeId.ToInt();

                this.Placeholder1.Controls.Add(product);
            }
        }
Esempio n. 23
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            int userId   = Conversion.TryCastInteger(this.userSelect.SelectedValue);
            int officeId = Conversion.TryCastInteger(this.officeSelect.SelectedValue);

            string menus = this.selectedMenusHidden.Value;

            if (userId.Equals(0) || officeId.Equals(0))
            {
                return;
            }

            Menu.SaveMenuPolicy(AppUsers.GetCurrentUserDB(), userId, officeId, menus);
            this.BindGrid();
        }
Esempio n. 24
0
        public long Save(DateTime valueDate, int storeId, string partyCode, int priceTypeId, string referenceNumber,
                         string data, string statementReference, string transactionType, int paymentTermId, int salespersonId,
                         int shipperId, string shippingAddressCode, decimal shippingCharge, int costCenterId, string transactionIds,
                         string attachmentsJSON, bool nonTaxable)
        {
            try
            {
                Collection <StockDetail> details = CollectionHelper.GetStockMasterDetailCollection(data, storeId);

                Collection <Attachment> attachments = CollectionHelper.GetAttachmentCollection(attachmentsJSON);

                bool isCredit = transactionType != null && !transactionType.ToUpperInvariant().Equals("CASH");

                if (!Stores.IsSalesAllowed(AppUsers.GetCurrentUserDB(), storeId))
                {
                    throw new InvalidOperationException("Sales is not allowed here.");
                }

                foreach (StockDetail model in details)
                {
                    if (Items.IsStockItem(AppUsers.GetCurrentUserDB(), model.ItemCode))
                    {
                        decimal available = Items.CountItemInStock(AppUsers.GetCurrentUserDB(),
                                                                   model.ItemCode, model.UnitName, model.StoreId);

                        if (available < model.Quantity)
                        {
                            throw new InvalidOperationException(string.Format(CultureManager.GetCurrent(),
                                                                              Warnings.InsufficientStockWarning, available, model.UnitName, model.ItemCode));
                        }
                    }
                }

                int  officeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
                int  userId   = AppUsers.GetCurrent().View.UserId.ToInt();
                long loginId  = AppUsers.GetCurrent().View.LoginId.ToLong();

                return(Data.Transactions.DirectSales.Add(AppUsers.GetCurrentUserDB(), officeId, userId, loginId,
                                                         valueDate, storeId, isCredit, paymentTermId, partyCode, salespersonId, priceTypeId, details,
                                                         shipperId, shippingAddressCode, shippingCharge, costCenterId, referenceNumber, statementReference,
                                                         attachments, nonTaxable));
            }
            catch (Exception ex)
            {
                Log.Warning("Could not save direct sales entry. {Exception}", ex);
                throw;
            }
        }
Esempio n. 25
0
        public void InstallUpdates()
        {
            if (!this.IsValidRequest())
            {
                this.Notify("Cannot Update", Warnings.AccessIsDenied);
                return;
            }

            string downloadUrl = string.Empty;

            string[] toBackup =
            {
                DbConfig.GetAttachmentParameter(AppUsers.GetCurrentUserDB(), "AttachmentsDirectory"),
                ConfigurationHelper.GetDbServerParameter("DatabaseBackupDirectory")
            };

            Release release = new Release();

            try
            {
                UpdateManager updater = new UpdateManager();
                Task          task    = Task.Run(async() => { release = await updater.GetLatestReleaseAsync(); });
                task.Wait();
            }
            catch
            {
                this.Notify("Cannot Update", "Cannot start the update because no release was found.");
                return;
            }


            string keyword = Config.UpdateKeyword;

            Asset ass = release.Assets.FirstOrDefault(a => a.Name.ToUpperInvariant().Contains(keyword.ToUpperInvariant()));

            if (ass != null)
            {
                downloadUrl = ass.DownloadUrl;
            }

            if (string.IsNullOrWhiteSpace(downloadUrl))
            {
                this.Notify("Cannot Update", "Cannot start the update because no download was found on the release.");
                return;
            }

            this.InstallUpdate(downloadUrl, toBackup);
        }
Esempio n. 26
0
        private static string ProcessEmailMessage(long tranId)
        {
            string template = EmailTemplateHelper.GetTemplateFileContents("/Static/Templates/Email/Sales/Delivery.html");

            List <object> dictionary = new List <object>
            {
                AppUsers.GetCurrent().View,
                          Data.Transactions.Delivery.GetSalesDeliveryView(AppUsers.GetCurrentUserDB(), tranId)
            };

            var processor = new EmailTemplateProcessor(template, dictionary);

            template = processor.Process();

            return(template);
        }
Esempio n. 27
0
        private static LoggerConfiguration GetConfiguration()
        {
            string minimumLogLevel = DbConfig.GetMixERPParameter(AppUsers.GetCurrentUserDB(), "MinimumLogLevel");

            LoggingLevelSwitch levelSwitch = new LoggingLevelSwitch();

            LogEventLevel logLevel;

            Enum.TryParse(minimumLogLevel, out logLevel);

            levelSwitch.MinimumLevel = logLevel;

            return
                (new LoggerConfiguration().MinimumLevel.ControlledBy(levelSwitch)
                 .WriteTo.RollingFile(GetLogFileName()));
        }
Esempio n. 28
0
        private static string GetLogDirectory()
        {
            string path = DbConfig.GetMixERPParameter(AppUsers.GetCurrentUserDB(), "ApplicationLogDirectory");

            if (string.IsNullOrWhiteSpace(path))
            {
                return(HostingEnvironment.MapPath("~/Resource/Temp"));
            }

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            return(path);
        }
Esempio n. 29
0
        private static string GetDisplayFields()
        {
            List <string> displayFields = new List <string>();

            ScrudHelper.AddDisplayField(displayFields, "core.recurrence_types.recurrence_type_id",
                                        DbConfig.GetDbParameter(AppUsers.GetCurrentUserDB(), "RecurrenceTypeDisplayField"));
            ScrudHelper.AddDisplayField(displayFields, "core.frequencies.frequency_id",
                                        DbConfig.GetDbParameter(AppUsers.GetCurrentUserDB(), "FrequencyDisplayField"));
            ScrudHelper.AddDisplayField(displayFields, "core.items.item_id",
                                        DbConfig.GetDbParameter(AppUsers.GetCurrentUserDB(), "ItemDisplayField"));
            ScrudHelper.AddDisplayField(displayFields, "core.payment_terms.payment_term_id",
                                        DbConfig.GetDbParameter(AppUsers.GetCurrentUserDB(), "PaymentTermDisplayField"));
            ScrudHelper.AddDisplayField(displayFields, "core.accounts.account_id",
                                        DbConfig.GetDbParameter(AppUsers.GetCurrentUserDB(), "AccountDisplayField"));
            return(string.Join(",", displayFields));
        }
Esempio n. 30
0
        private void CreateList(Control container)
        {
            DbGetWorkflowModelResult model = Workflow.GetWorkflowModel(AppUsers.GetCurrentUserDB());

            using (HtmlGenericControl ul = new HtmlGenericControl("ul"))
            {
                HtmlControlHelper.AddListItem(ul, Titles.FlaggedTransactions, model.FlaggedTransactions);
                HtmlControlHelper.AddListItem(ul, Titles.InVerificationStack, model.InVerificationStack);
                HtmlControlHelper.AddListItem(ul, Titles.AutomaticallyApprovedByWorkflow, model.AutoApproved);
                HtmlControlHelper.AddListItem(ul, Titles.ApprovedTransactions, model.Approved);
                HtmlControlHelper.AddListItem(ul, Titles.RejectedTransactions, model.Rejected);
                HtmlControlHelper.AddListItem(ul, Titles.ClosedTransactions, model.Closed);
                HtmlControlHelper.AddListItem(ul, Titles.WithdrawnTransactions, model.Withdrawn);
                container.Controls.Add(ul);
            }
        }