Exemplo n.º 1
0
 public ActionResult DocumentReferenceSetting(SettingsDocReferenceViewModel model)
 {
     try
     {
         if (model.DocReferenceRule == null)
         {
             model.DocReferenceRule = "{D}_{SN}_{OC}_{DT}_{TM}_{SQ}";
         }
         if (!model.DocReferenceRule.Contains("{D}"))
         {
             model.DocReferenceRule = "{D}" + model.DocReferenceRule;
         }
         if (!model.DocReferenceRule.Contains("{SQ}"))
         {
             model.DocReferenceRule = model.DocReferenceRule + "{SQ}";
         }
         _agrimanagrSettingsViewModelBuilder.SaveDocumentReferenceSettings(model);
         ValidationSummary.DomainValidationErrors("Settings Successfully Saved", ModelState);
         return View(model);
     }
     catch (DomainValidationException ve)
     {
         ValidationSummary.DomainValidationErrors(ve, ModelState);
         TempData["msg"] = "Validation Errors, Unable to save settings\n" + ve.Message;
     }
     return View(model);
 }
        public void SaveDocumentReferenceSettings(SettingsDocReferenceViewModel setting)
        {
            var docOrderInitial = _settingsRepository.GetByKey(SettingsKeys.DocOrderInitial);
            if (docOrderInitial == null) docOrderInitial = new AppSettings(Guid.NewGuid());
            docOrderInitial.Key = SettingsKeys.DocOrderInitial;
            docOrderInitial.Value = setting.OrderInitial;
            _settingsRepository.Save(docOrderInitial);

            var docSaleInitial = _settingsRepository.GetByKey(SettingsKeys.DocSaleInitial);
            if (docSaleInitial == null) docSaleInitial = new AppSettings(Guid.NewGuid());
            docSaleInitial.Key = SettingsKeys.DocSaleInitial;
            docSaleInitial.Value = setting.SaleInitial;
            _settingsRepository.Save(docSaleInitial);

            var docInvoiceInitial = _settingsRepository.GetByKey(SettingsKeys.DocInvoiceInitial);
            if (docInvoiceInitial == null) docInvoiceInitial = new AppSettings(Guid.NewGuid());
            docInvoiceInitial.Key = SettingsKeys.DocInvoiceInitial;
            docInvoiceInitial.Value = setting.InvoiceInitial;
            _settingsRepository.Save(docInvoiceInitial);


            var docReceiptInitial = _settingsRepository.GetByKey(SettingsKeys.DocReceiptInitial);
            if (docReceiptInitial == null) docReceiptInitial = new AppSettings(Guid.NewGuid());
            docReceiptInitial.Key = SettingsKeys.DocReceiptInitial;
            docReceiptInitial.Value = setting.ReceiptInitial;
            _settingsRepository.Save(docReceiptInitial);


            var docReferenceRule = _settingsRepository.GetByKey(SettingsKeys.DocReferenceRule);
            if (docReferenceRule == null) docReferenceRule = new AppSettings(Guid.NewGuid());
            docReferenceRule.Key = SettingsKeys.DocReferenceRule;
            docReferenceRule.Value = setting.DocReferenceRule;
            _settingsRepository.Save(docReferenceRule);
        }
Exemplo n.º 3
0
        public ActionResult DocumentReferenceSetting()
        {
            var setting = new SettingsDocReferenceViewModel();
            var orderinitial = _settingsRepository.GetByKey(SettingsKeys.DocOrderInitial);
            if (orderinitial != null) setting.OrderInitial = orderinitial.Value;
            else
            {
                setting.OrderInitial = "O";
            }
            var salesintial = _settingsRepository.GetByKey(SettingsKeys.DocSaleInitial);
            if (salesintial != null) setting.SaleInitial = salesintial.Value;
            else
            {
                setting.SaleInitial = "S";
            }
            var invoiceintial = _settingsRepository.GetByKey(SettingsKeys.DocInvoiceInitial);
            if (invoiceintial != null) setting.InvoiceInitial = invoiceintial.Value;
            else
            {
                setting.InvoiceInitial = "I";
            }
            var receiptinitial = _settingsRepository.GetByKey(SettingsKeys.DocReceiptInitial);
            if (receiptinitial != null) setting.ReceiptInitial = receiptinitial.Value;
            else
            {
                setting.ReceiptInitial = "R";
            }
            var documentRefRule = _settingsRepository.GetByKey(SettingsKeys.DocReferenceRule);
            if (documentRefRule != null) setting.DocReferenceRule = documentRefRule.Value;
            else
            {
                setting.DocReferenceRule = "{D}_{SN}_{OC}_{DT}_{TM}_{SQ}";
            }

            return View(setting);
        }