public PaymentReceipt(Payment payment) { ReceiptDate = BusinessDomain.GetFormattedDate(payment.Date); long number = payment.Id; if (payment.ParentOperation == null) { payment.ParentOperation = Operation.GetById((OperationType)payment.OperationType, payment.OperationId); } if (payment.ParentOperation != null) { number = payment.ParentOperation.Id; } ReceiptNumber = number.ToString(CultureInfo.InvariantCulture).PadLeft(BusinessDomain.AppConfiguration.DocumentNumberLength, '0'); FillRecipient(payment.PartnerId); FillSupplier(); Location = payment.LocationName; double debt = 0; if (payment.ParentOperation != null) { debt = payment.ParentOperation.TotalPlusVAT; } Debt = Currency.ToString(debt, PriceType.SaleTotal); Total = payment.Quantity; Balance = Currency.ToString(-Partner.GetDebt(payment.PartnerId), PriceType.SaleTotal); }
protected static string GetFieldText(DataType fieldType, object value) { switch (fieldType) { case DataType.Date: return(BusinessDomain.GetFormattedDate((DateTime)value)); case DataType.DateTime: return(BusinessDomain.GetFormattedDateTime((DateTime)value)); case DataType.Quantity: return(Quantity.ToEditString((double)value)); case DataType.CurrencyIn: return(Currency.ToEditString((double)value, PriceType.Purchase)); case DataType.CurrencyOut: return(Currency.ToEditString((double)value)); case DataType.Currency: return(Currency.ToEditString((double)value, PriceType.Unknown)); case DataType.Percent: return(Percent.ToEditString((double)value)); default: return(value.ToString()); } }
public override DataQueryResult ExecuteReport(DataQuery dataQuery) { string date = string.Empty; DataQuery qSet = dataQuery; foreach (DataFilter filter in qSet.Filters.Where(filter => filter.IsValid)) { if (filter.FilteredFields.Any(field => field == DataField.OperationDate)) { date = BusinessDomain.GetFormattedDate((DateTime)filter.Values [0]); } if (!string.IsNullOrEmpty(date)) { break; } } if (string.IsNullOrEmpty(date)) { date = BusinessDomain.GetFormattedDate(BusinessDomain.Today); } return(BusinessDomain.DataAccessProvider.ReportItemsAvailabilityAtDate(qSet, date)); }
public override Report GetPrintData(string title) { return(new Report { ReportDetails = grid.ToDataTable(true), ReportHasFooter = TotalsShown, ReportDate = BusinessDomain.GetFormattedDate(BusinessDomain.Now), ReportName = title }); }
private static void ChooseDate(Entry txtDate) { using (ChooseDate chooseDate = new ChooseDate()) { if (chooseDate.Run() != ResponseType.Ok) { txtDate.GrabFocus(); return; } txtDate.Text = BusinessDomain.GetFormattedDate(chooseDate.Selection); } }
protected void OnRemainingDaysValueChanged(object sender, EventArgs args) { if (changingDueDate) { return; } changingDueDate = true; txtDueDate.Text = BusinessDomain.GetFormattedDate(GetDueDate().AddDays(spbRemainingDays.ValueAsInt)); changingDueDate = false; }
public void SetData(DateTime from, DateTime to, DateRanges range = DateRanges.Custom) { fromDateString = BusinessDomain.GetFormattedDate(from); fromTimeString = BusinessDomain.GetFormattedTime(from); fromDate = from.Date; fromTime = from.TimeOfDay; toDateString = BusinessDomain.GetFormattedDate(to); toTimeString = BusinessDomain.GetFormattedTime(to); toDate = to.Date; toTime = to.TimeOfDay; timeRange = range; }
public override void ClearFilter() { FilterDateTimeRange f = (FilterDateTimeRange)filter; f.SetData(f.FromDate.Add(new TimeSpan(spbHoursFrom.ValueAsInt, spbMinutesFrom.ValueAsInt, 0)), f.ToDate.Add(new TimeSpan(spbHoursTo.ValueAsInt, spbMinutesTo.ValueAsInt, 0)), f.TimeRange); base.ClearFilter(); txtFrom.Text = filter.FromDate == DateTime.MinValue ? string.Empty : BusinessDomain.GetFormattedDate(filter.FromDate); txtTo.Text = filter.ToDate == DateTime.MinValue ? string.Empty : BusinessDomain.GetFormattedDate(filter.ToDate); }
public ProductionProtocol(ComplexProduction production) : this() { ProtocolDate = BusinessDomain.GetFormattedDate(production.Date); ProtocolNumber = production.FormattedOperationNumber; Note = production.Note; CompanyRecord company = CompanyRecord.GetDefault(); CompanyName = company.Name; CompanyNumber = company.Bulstat; CompanyCity = company.City; CompanyAddress = company.Address; CompanyTelephone = company.Telephone; CompanyLiablePerson = company.LiablePerson; Location = production.Location2; double vat = production.VAT; if (BusinessDomain.AppConfiguration.VATIncluded) { Total = Currency.ToString(production.Total - vat, PriceType.Purchase); Vat = Currency.ToString(vat, PriceType.Purchase); TotalPlusVat = production.Total; } else { Total = Currency.ToString(production.Total, PriceType.Purchase); Vat = Currency.ToString(vat, PriceType.Purchase); TotalPlusVat = production.Total + vat; } int i = 1; foreach (ComplexProductionDetail detail in production.Details) { ProtocolDetailsMaterials.Add(new ProtocolDetail(i++, detail)); } i = 1; foreach (ComplexProductionDetail detail in production.DetailsProd) { ProtocolDetailsProducts.Add(new ProtocolDetail(i++, detail)); } }
private void InitializeEntries() { txtNumber.Text = document.NumberString; List <KeyValuePair <long, string> > paymentPairs = PaymentType.GetAll().Select(p => new KeyValuePair <long, string> (p.Id, p.Name)).ToList(); if (IsEditable) { cboPaymentType.Load(paymentPairs, "Key", "Value", BusinessDomain.AppConfiguration.LastDocumentPaymentMethodId); Operation operation = operations.Last(); cbeRecipient.Load(DocumentBase.GetRecipientSuggestions(operation.PartnerId), null, null); cbeEGN.Load(DocumentBase.GetEGNSuggestions(operation.PartnerId), null, null); cbeProvider.Load(DocumentBase.GetProviderSuggestions(), null, null); cbeReason.Load(DocumentBase.GetReasonSuggestions(), null, null); cbeDescription.Load(DocumentBase.GetDescriptionSuggestions(), null, null); cbeLocation.Load(DocumentBase.GetLocationSuggestions(), null, null); txtDate.Text = BusinessDomain.GetFormattedDate(BusinessDomain.Today); txtTaxDate.Text = BusinessDomain.GetFormattedDate(operation.Date); Partner partner = Partner.GetById(partnerId); if (partner != null) { lblPartnerValue.SetText(partner.Name); } txtNumber.GrabFocus(); } else { txtRefNumber.Text = document.ReferenceNumberString; txtRefDate.Text = document.ReferenceDateString; cboPaymentType.Load(paymentPairs, "Key", "Value", document.PaymentMethod); cbeRecipient.Entry.Text = document.Recipient; cbeEGN.Entry.Text = document.RecipientEGN; cbeProvider.Entry.Text = document.Provider; cbeReason.Entry.Text = document.Reason; cbeDescription.Entry.Text = document.Description; lblPartnerValue.SetText(document.RecipientName); cbeLocation.Entry.Text = document.Location; txtDate.Text = document.DateString; txtTaxDate.Text = document.TaxDateString; hboPartner.Sensitive = false; fraMain.Sensitive = false; fraAdditional.Sensitive = false; } }
public StockTakingProtocol(StockTaking stockTaking) : this() { ProtocolDate = BusinessDomain.GetFormattedDate(stockTaking.Date); ProtocolNumber = stockTaking.FormattedOperationNumber; Note = stockTaking.Note; CompanyRecord company = CompanyRecord.GetDefault(); CompanyName = company.Name; CompanyNumber = company.Bulstat; CompanyCity = company.City; CompanyAddress = company.Address; CompanyTelephone = company.Telephone; CompanyLiablePerson = company.LiablePerson; Location = stockTaking.Location2; double vat = stockTaking.VAT; if (BusinessDomain.AppConfiguration.VATIncluded) { Total = Currency.ToString(stockTaking.Total - vat); Vat = Currency.ToString(vat); TotalPlusVat = stockTaking.Total; } else { Total = Currency.ToString(stockTaking.Total); Vat = Currency.ToString(vat); TotalPlusVat = stockTaking.Total + vat; } int i = 1; foreach (StockTakingDetail detail in stockTaking.Details) { StockTakingProtocolDetail stockTakingProtocolDetail = new StockTakingProtocolDetail(i++, detail, false); stockTakingProtocolDetail.ExpectedQuantity = Quantity.ToString(detail.ExpectedQuantity); stockTakingProtocolDetail.EnteredQuantity = Quantity.ToString(detail.EnteredQuantity); StockTakingProtocolDetails.Add(stockTakingProtocolDetail); } TotalQuantity = Quantity.ToString(stockTaking.Details.Sum(d => d.EnteredQuantity)); }
public WasteProtocol(Waste waste) : this() { ProtocolDate = BusinessDomain.GetFormattedDate(waste.Date); ProtocolNumber = waste.FormattedOperationNumber; Note = waste.Note; CompanyRecord company = CompanyRecord.GetDefault(); CompanyName = company.Name; CompanyNumber = company.Bulstat; CompanyCity = company.City; CompanyAddress = company.Address; CompanyTelephone = company.Telephone; CompanyLiablePerson = company.LiablePerson; Location = waste.Location2; bool usePriceIn = !BusinessDomain.LoggedUser.HideItemsPurchasePrice; PriceType priceType = usePriceIn ? PriceType.PurchaseTotal : PriceType.SaleTotal; double vat = waste.VAT; if (BusinessDomain.AppConfiguration.VATIncluded) { Total = Currency.ToString(waste.Total - vat, priceType); Vat = Currency.ToString(vat, priceType); TotalPlusVat = waste.Total; } else { Total = Currency.ToString(waste.Total, priceType); Vat = Currency.ToString(vat, priceType); TotalPlusVat = waste.Total + vat; } int i = 1; foreach (WasteDetail detail in waste.Details) { ProtocolDetails.Add(new ProtocolDetail(i++, detail, usePriceIn)); } TotalQuantity = Quantity.ToString(waste.Details.Sum(d => d.Quantity)); }
public PurchaseReceipt(Purchase purchase) : this() { ReceiptDate = BusinessDomain.GetFormattedDate(purchase.Date); ReceiptNumber = purchase.FormattedOperationNumber; Note = purchase.Note; Invoice invoice = Invoice.GetReceivedForOperation(purchase.Id); if (invoice != null) { InvoiceDate = invoice.DateString; InvoiceNumber = invoice.NumberString; } FillRecipient(); FillSupplier(purchase.PartnerId); Location = purchase.Location2; double vat = purchase.VAT; if (BusinessDomain.AppConfiguration.VATIncluded) { Total = purchase.Total - vat; Vat = Currency.ToString(vat, PriceType.Purchase); TotalPlusVat = purchase.Total; } else { Total = purchase.Total; Vat = Currency.ToString(vat, PriceType.Purchase); TotalPlusVat = purchase.Total + vat; } int i = 1; foreach (PurchaseDetail detail in purchase.Details) { ReceiptDetails.Add(new ReceiptDetail(i++, detail)); } TotalQuantity = Quantity.ToString(purchase.Details.Sum(d => d.Quantity)); }
public TransferReceipt(Transfer transfer) : this() { ReceiptDate = BusinessDomain.GetFormattedDate(transfer.Date); ReceiptNumber = transfer.FormattedOperationNumber; Note = transfer.Note; FillSupplier(); SourceLocation = transfer.SourceLocation2; TargetLocation = transfer.TargetLocation2; Transfer clone = transfer.Clone <Transfer, TransferDetail> (); if (BusinessDomain.AppConfiguration.AlwaysPrintTransfersUsingSalePrices) { clone.SetUsePriceIn(false); } int i = 1; foreach (TransferDetail detail in clone.Details) { detail.TotalEvaluate(); ReceiptDetails.Add(new ReceiptDetail(i++, detail, clone.GetUsePriceIn())); } double vat = clone.VAT; if (BusinessDomain.AppConfiguration.VATIncluded) { Total = Currency.ToString(clone.Total - vat, clone.TotalsPriceType); Vat = Currency.ToString(vat, clone.TotalsPriceType); TotalPlusVat = clone.Total; } else { Total = Currency.ToString(clone.Total, clone.TotalsPriceType); Vat = Currency.ToString(vat, clone.TotalsPriceType); TotalPlusVat = clone.Total + vat; } TotalQuantity = Quantity.ToString(clone.Details.Sum(d => d.Quantity)); }
public ChooseDateInterval(DateTime?dateFrom, DateTime?dateTo) : this() { if (dateFrom == null) { chkDateFrom.Active = false; } else { txtDateFrom.Text = BusinessDomain.GetFormattedDate(dateFrom.Value); } if (dateTo == null) { chkDateTo.Active = false; } else { txtDateTo.Text = BusinessDomain.GetFormattedDate(dateTo.Value); } }
private void ChooseDate() { DateTime selectedDate = BusinessDomain.GetDateValue(txtDueDate.Text.Trim()); if (selectedDate == DateTime.MinValue) { selectedDate = BusinessDomain.Today; } using (ChooseDate chooseDate = new ChooseDate(selectedDate)) if (chooseDate.Run() == ResponseType.Ok) { if (chooseDate.Selection.Date >= operation.Date) { txtDueDate.Text = BusinessDomain.GetFormattedDate(chooseDate.Selection); } else { ShowMessageTooEarlyDate(); } } }
protected override void InitializeForm() { XML form = FormHelper.LoadGladeXML("Dialogs.EditNewPayment.glade", "dlgEditNewPayment"); form.Autoconnect(this); dlgEditNewPayment.Icon = FormHelper.LoadImage("Icons.TradePoint32.png").Pixbuf; btnOK.SetChildImage(FormHelper.LoadImage("Icons.Ok24.png")); btnCancel.SetChildImage(FormHelper.LoadImage("Icons.Cancel24.png")); txtDueDate.Text = BusinessDomain.GetFormattedDate(GetDueDate()); base.InitializeForm(); InitializeFormStrings(); paymentWidget.RefreshGrid(); chkUseAdvances.Visible = operation.UseAdvancePayments && operation.Id < 0; if (!chkUseAdvances.Visible) { return; } advances.AddRange(Payment.GetAdvances(operation.PartnerId)); foreach (Payment payment in advances) { payment.Type.BaseType = BasePaymentType.Advance; } if (advances.Count == 0) { chkUseAdvances.Visible = false; } else { chkUseAdvances.Label = string.Format("{0} {1}", Translator.GetString("Use Advance Payments"), string.Format(Translator.GetString("(total: {0})"), Currency.ToString(advances.Sum(p => p.Quantity), operation.TotalsPriceType))); } }
protected DocumentDetail(int detailNumber, OperationDetail detail, bool usePriceIn = true) { this.usePriceIn = usePriceIn; Number = Data.Number.ToEditString(detailNumber); Item item = Item.GetById(detail.ItemId); ItemCode = item.Code; ItemName = item.Name2; MUnit = detail.MUnitName; Quantity = Entities.Quantity.ToString(detail.Quantity); Discount = Percent.ToString(detail.Discount); DiscountValue = Entities.Currency.ToString(detail.DiscountValue); Price = Entities.Currency.ToString(usePriceIn ? detail.PriceIn : detail.PriceOut, usePriceIn ? PriceType.Purchase : PriceType.Sale); Total = Entities.Currency.ToString(detail.Total, usePriceIn ? PriceType.Purchase : PriceType.Sale); Lot = detail.Lot; SerialNumber = detail.SerialNumber; ExpirationDate = detail.ExpirationDate.HasValue ? BusinessDomain.GetFormattedDate(detail.ExpirationDate.Value) : String.Empty; ProductionDate = detail.ProductionDate.HasValue ? BusinessDomain.GetFormattedDate(detail.ProductionDate.Value) : String.Empty; LotLocation = detail.LotLocation; Note = detail.Note; }
public SaleReceipt(Sale sale) : this() { ReceiptDate = BusinessDomain.GetFormattedDate(sale.Date); ReceiptNumber = sale.FormattedOperationNumber; Note = sale.Note; FillRecipient(sale.PartnerId); FillSupplier(); Location = sale.Location2; double vat = sale.VAT; if (BusinessDomain.AppConfiguration.VATIncluded) { Total = sale.Total - vat; Vat = Currency.ToString(vat); TotalPlusVat = sale.Total; } else { Total = sale.Total; Vat = Currency.ToString(vat); TotalPlusVat = sale.Total + vat; } int i = 1; foreach (SaleDetail detail in sale.Details) { ReceiptDetails.Add(new ReceiptDetail(i++, detail, false)); } TotalQuantity = Quantity.ToString(sale.Details.Sum(d => d.Quantity)); }
public override void Commit() { bool editMode = true; using (DbTransaction transaction = new DbTransaction(BusinessDomain.DataAccessProvider)) { transaction.SnapshotObject(this); // Create a new operation Id if needed); OperationState operationState = State; if (operationState == OperationState.New || operationState == OperationState.NewDraft || operationState == OperationState.NewPending) { id = CreateNewId(); editMode = false; } LotsEvaluate(Details); BusinessDomain.DataAccessProvider.AddUpdateWaste(this, details.ToArray(), BusinessDomain.AppConfiguration.AllowNegativeAvailability); if (editMode && Total.IsZero()) { BusinessDomain.DataAccessProvider.DeleteOperationId(Data.OperationType.Waste, id); ApplicationLogEntry.AddNew(string.Format(Translator.GetString("Void waste No.{0} from {1}"), GetFormattedOperationNumber(id), BusinessDomain.GetFormattedDate(date))); } else if (editMode) { ApplicationLogEntry.AddNew(string.Format(Translator.GetString("Edit waste No.{0} from {1}"), GetFormattedOperationNumber(id), BusinessDomain.GetFormattedDate(date))); } if (editMode) { RemoveAllEmptyDetails(); } transaction.Complete(); } }
public static ResponseType ChooseDataFieldValue(DbField field, ref object value) { DataType fieldType = ReportProvider.GetDataFieldType(field); ChooseEdit dlgChooseEdit = null; ChooseDate dlgChooseDate = null; switch (field.StrongField) { case DataField.PartnerName: dlgChooseEdit = new ChooseEditPartner(true, string.Empty); break; case DataField.PartnersGroupsName: dlgChooseEdit = new ChooseEditPartnersGroup(); break; case DataField.ItemName: dlgChooseEdit = new ChooseEditItem(true); break; case DataField.ItemsGroupName: dlgChooseEdit = new ChooseEditItemsGroup(); break; case DataField.LocationName: case DataField.SourceLocationName: case DataField.TargetLocationName: dlgChooseEdit = new ChooseEditLocation(true, string.Empty); break; case DataField.LocationsGroupsName: dlgChooseEdit = new ChooseEditLocationsGroup(); break; case DataField.UserName: case DataField.OperationsUserName: case DataField.OperationsOperatorName: dlgChooseEdit = new ChooseEditUser(true, string.Empty); break; case DataField.UsersGroupsName: case DataField.OperationsUsersGroupsName: case DataField.OperationsOperatorsGroupsName: dlgChooseEdit = new ChooseEditUsersGroup(); break; default: if (fieldType == DataType.Date || fieldType == DataType.DateTime) { DateTime selectedDate = BusinessDomain.GetDateValue((string)value); dlgChooseDate = new ChooseDate { Selection = selectedDate == DateTime.MinValue ? BusinessDomain.Today : selectedDate }; } break; } value = null; ResponseType ret = ResponseType.Cancel; if (dlgChooseEdit != null) { using (dlgChooseEdit) { ret = dlgChooseEdit.Run(); string [] selection = dlgChooseEdit.SelectedItemsText; if (ret == ResponseType.Ok && selection.Length > 0) { value = selection [0]; } } } else if (dlgChooseDate != null) { using (dlgChooseDate) { ret = dlgChooseDate.Run(); value = BusinessDomain.GetFormattedDate(dlgChooseDate.Selection); } } return(ret); }
public override string ToString() { string condition = formula; long id; switch (type) { case PriceRule.ConditionType.Partner: if (values [0] == null) { condition = null; break; } var partner = Partner.Cache.GetById(Convert.ToInt64(values [0])); condition = partner != null ? partner.Name : null; break; case PriceRule.ConditionType.PartnerGroup: if (values [0] == null) { condition = null; break; } var partnersGroup = Int64.TryParse((string)values [0], out id) ? PartnersGroup.Cache.GetById(id) : PartnersGroup.Cache.GetByCode((string)values [0]); condition = partnersGroup != null ? partnersGroup.Name : null; break; case PriceRule.ConditionType.Object: if (values [0] == null) { condition = null; break; } var location = Location.Cache.GetById(Convert.ToInt64(values [0])); condition = location != null ? location.Name : null; break; case PriceRule.ConditionType.ObjectGroup: if (values [0] == null) { condition = null; break; } var locationsGroup = Int64.TryParse((string)values [0], out id) ? LocationsGroup.Cache.GetById(id) : LocationsGroup.Cache.GetByCode((string)values [0]); condition = locationsGroup != null ? locationsGroup.Name : null; break; case PriceRule.ConditionType.User: if (values [0] == null) { condition = null; break; } var user = User.Cache.GetById(Convert.ToInt64(values [0])); condition = user != null ? user.Name : null; break; case PriceRule.ConditionType.UserGroup: if (values [0] == null) { condition = null; break; } var usersGroup = Int64.TryParse((string)values [0], out id) ? UsersGroup.Cache.GetById(id) : UsersGroup.Cache.GetByCode((string)values [0]); condition = usersGroup != null ? usersGroup.Name : null; break; case PriceRule.ConditionType.Good: case PriceRule.ConditionType.ContainsGood: if (values [0] == null) { condition = null; break; } var item = Item.Cache.GetById(Convert.ToInt64(values [0])); condition = item != null ? item.Name : null; break; case PriceRule.ConditionType.GoodGroup: case PriceRule.ConditionType.ContainsGGroup: if (values [0] == null) { condition = null; break; } var itemsGroup = Int64.TryParse((string)values [0], out id) ? ItemsGroup.Cache.GetById(id) : ItemsGroup.Cache.GetByCode((string)values [0]); condition = itemsGroup != null ? itemsGroup.Name : null; break; case PriceRule.ConditionType.Time: DateTime?timeFrom = (DateTime?)values [0]; DateTime?timeTo = (DateTime?)values [1]; string timeFromString = timeFrom != null? String.Format("{0} {1}", Translator.GetString("from"), BusinessDomain.GetFormattedTime(timeFrom.Value)) : null; string timeToString = timeTo != null? String.Format("{0} {1}", Translator.GetString("to"), BusinessDomain.GetFormattedTime(timeTo.Value)) : null; if (timeFrom != null && timeTo != null) { condition = String.Format("{0} {1}", timeFromString, timeToString); } else if (timeFrom != null) { condition = timeFromString; } else if (timeTo != null) { condition = timeToString; } else { condition = null; } break; case PriceRule.ConditionType.Date: DateTime?dateFrom = (DateTime?)values [0]; DateTime?dateTo = (DateTime?)values [1]; string dateFromString = dateFrom != null? String.Format("{0} {1}", Translator.GetString("from"), BusinessDomain.GetFormattedDate(dateFrom.Value)) : null; string dateToString = dateTo != null? String.Format("{0} {1}", Translator.GetString("to"), BusinessDomain.GetFormattedDate(dateTo.Value)) : null; if (dateFrom != null && dateTo != null) { condition = String.Format("{0} {1}", dateFromString, dateToString); } else if (dateFrom != null) { condition = dateFromString; } else if (dateTo != null) { condition = dateToString; } else { condition = null; } break; case PriceRule.ConditionType.DocumentSum: case PriceRule.ConditionType.TurnoverSum: case PriceRule.ConditionType.GoodQttySum: case PriceRule.ConditionType.PaymentSum: case PriceRule.ConditionType.UnpaidDocumentsSum: double?from = values [0] == null ? (double?)null : Convert.ToDouble(values [0]); double?to = values [1] == null ? (double?)null : Convert.ToDouble(values [1]); string fromString; string toString; if (from != null) { fromString = String.Format("{0} {1}", Translator.GetString("from"), type == PriceRule.ConditionType.GoodQttySum ? Quantity.ToString(from.Value) : Currency.ToString(from.Value, PriceType.Unknown)); } else { fromString = null; } if (to != null) { toString = String.Format("{0} {1}", Translator.GetString("to"), type == PriceRule.ConditionType.GoodQttySum ? Quantity.ToString(to.Value) : Currency.ToString(to.Value, PriceType.Unknown)); } else { toString = null; } if (from != null && to != null) { condition = String.Format("{0} {1}", fromString, toString); } else if (from != null) { condition = fromString; } else if (to != null) { condition = toString; } else { condition = null; } break; case PriceRule.ConditionType.Weekdays: condition = String.Join(" ", ((IList <DayOfWeek>)values [0]) .Select(DateTimeFormatInfo.CurrentInfo.GetAbbreviatedDayName) .ToArray()); break; case PriceRule.ConditionType.PaymentTypeUsed: condition = String.Join(" ", ((IList <BasePaymentType>)values [0]) .Select(PaymentType.GetBasePaymentTypeName) .ToArray()); break; case PriceRule.ConditionType.DatabaseUpdated: DateTime now = DateTime.Now; condition = String.Format(Translator.GetString("Sooner than {0}"), now.AddMinutes(-30).ToFriendlyTimeAgoString(now)); break; } if (condition == null) { error = true; } return(String.Format("{0}: {1}", TypeToString(type), condition ?? AllMissingErrors [type])); }
public void CommitChanges(bool increaseStoreAvailability = true, bool increaseStoreAvailabilityOnAnnull = true) { bool editMode = true; try { using (DbTransaction transaction = new DbTransaction(BusinessDomain.DataAccessProvider)) { transaction.SnapshotObject(this); if (BusinessDomain.AppConfiguration.AutoProduction) { AutomaticProduction(); } // Create a new operation Id if needed); OperationState operationState = State; if (operationState == OperationState.New || operationState == OperationState.NewDraft || operationState == OperationState.NewPending) { id = CreateNewId(); editMode = false; } LotsEvaluate(Details); // Save the output transfer in the database OperationType = OperationType.TransferOut; LocationId = SourceLocationId; bool annulling = editMode && Total.IsZero(); foreach (TransferDetail detail in details) { detail.Sign = annulling && !increaseStoreAvailabilityOnAnnull ? 0 : -1; detail.DetailId = detail.SourceDetailId; } BusinessDomain.DataAccessProvider.AddUpdateTransferOut(this, details.ToArray(), BusinessDomain.AppConfiguration.AllowNegativeAvailability); foreach (TransferDetail detail in details) { detail.SourceDetailId = detail.DetailId; } // Save the input transfer in the database OperationType = OperationType.TransferIn; LocationId = TargetLocationId; foreach (TransferDetail detail in details) { detail.Sign = 1; detail.DetailId = detail.TargetDetailId; } BusinessDomain.DataAccessProvider.AddUpdateTransferIn(this, details.ToArray(), BusinessDomain.AppConfiguration.AllowNegativeAvailability, increaseStoreAvailability); foreach (TransferDetail detail in details) { detail.TargetDetailId = detail.DetailId; } InvalidateItemsCache(); if (annulling) { BusinessDomain.DataAccessProvider.DeleteOperationId(OperationType.TransferIn, id); ApplicationLogEntry.AddNew(string.Format(Translator.GetString("Void transfer No.{0} from {1}"), GetFormattedOperationNumber(id), BusinessDomain.GetFormattedDate(date))); } else if (editMode) { ApplicationLogEntry.AddNew(string.Format(Translator.GetString("Edit transfer No.{0} from {1}"), GetFormattedOperationNumber(id), BusinessDomain.GetFormattedDate(date))); } if (editMode) { RemoveAllEmptyDetails(); } transaction.Complete(); } } finally { LocationId = SourceLocationId; } }
public void SetDateRange(DateRanges dateRange) { DateTime today = BusinessDomain.Today; DayOfWeek dow = today.DayOfWeek; int dayOfWeek = dow == DayOfWeek.Sunday ? 7 : (int)dow; DateTime?from = null; DateTime?to = null; switch (dateRange) { case DateRanges.Today: from = today; to = today; break; case DateRanges.Yesterday: from = today.AddDays(-1); to = today.AddDays(-1); break; case DateRanges.ThisWeek: from = today.AddDays(1 - dayOfWeek); to = today.AddDays(7 - dayOfWeek); break; case DateRanges.PastWeek: from = today.AddDays(-7); to = today; break; case DateRanges.LastWeek: from = today.AddDays(1 - 7 - dayOfWeek); to = today.AddDays(7 - 7 - dayOfWeek); break; case DateRanges.ThisMonth: from = new DateTime(today.Year, today.Month, 1); to = new DateTime(today.Year, today.Month, DateTime.DaysInMonth(today.Year, today.Month)); break; case DateRanges.PastMonth: from = today.AddMonths(-1); to = today; break; case DateRanges.LastMonth: today = today.AddMonths(-1); from = new DateTime(today.Year, today.Month, 1); to = new DateTime(today.Year, today.Month, DateTime.DaysInMonth(today.Year, today.Month)); break; case DateRanges.ThisYear: from = new DateTime(today.Year, 1, 1); to = new DateTime(today.Year, 12, DateTime.DaysInMonth(today.Year, 12)); break; case DateRanges.PastYear: from = today.AddYears(-1); to = today; break; case DateRanges.LastYear: today = today.AddYears(-1); from = new DateTime(today.Year, 1, 1); to = new DateTime(today.Year, 12, DateTime.DaysInMonth(today.Year, 12)); break; } if (from.HasValue) { fromDateString = BusinessDomain.GetFormattedDate(from.Value); fromDate = from; } if (to.HasValue) { toDateString = BusinessDomain.GetFormattedDate(to.Value); toDate = to; } }
public ComplexRecipe CommitChanges() { bool editMode = true; try { using (DbTransaction transaction = new DbTransaction(BusinessDomain.DataAccessProvider)) { // Create a new operation Id if needed if (State == OperationState.New || State == OperationState.NewDraft) { id = CreateNewId(); editMode = false; } // Save the output ComplexRecipe in the database OperationType = OperationType.ComplexRecipeMaterial; foreach (ComplexRecipeDetail detail in DetailsMat) { detail.Note = name; } BusinessDomain.DataAccessProvider.AddUpdateComplexRecipeMat(this, DetailsMat.ToArray()); // Save the input ComplexRecipe in the database OperationType = OperationType.ComplexRecipeProduct; foreach (ComplexRecipeDetail detail in DetailsProd) { detail.Note = name; } BusinessDomain.DataAccessProvider.AddUpdateComplexRecipeProd(this, DetailsProd.ToArray()); if (editMode && Total.IsZero()) { BusinessDomain.DataAccessProvider.DeleteOperationId(OperationType.ComplexRecipeMaterial, id); string format = Translator.GetString("Void recipe No.{0} from {1}"); ApplicationLogEntry.AddNew(string.Format(format, GetFormattedOperationNumber(id), BusinessDomain.GetFormattedDate(date))); } else if (editMode) { string format = Translator.GetString("Edit recipe No.{0} from {1}"); ApplicationLogEntry.AddNew(string.Format(format, GetFormattedOperationNumber(id), BusinessDomain.GetFormattedDate(date))); } if (editMode) { RemoveAllEmptyDetails(); } transaction.Complete(); } } catch { if (!editMode) { id = -1; } throw; } return(this); }
public override void Commit() { bool editMode = true; using (DbTransaction transaction = new DbTransaction(BusinessDomain.DataAccessProvider)) { transaction.SnapshotObject(this); if (BusinessDomain.AppConfiguration.AutoProduction) { if (AutomaticProduction()) { RecalculatePrices(); } } // Create a new operation Id if needed); OperationState operationState = State; if (operationState == OperationState.New || operationState == OperationState.NewDraft || operationState == OperationState.NewPending) { id = CreateNewId(); editMode = false; if (BusinessDomain.AppConfiguration.ItemsManagementUseLots) { foreach (ComplexProductionDetail detail in DetailsProd) { if (detail.ProductionDate == null) { detail.ProductionDate = Date; } } } } LotsEvaluate(DetailsMat); // Save the output ComplexProduction in the database OperationType = OperationType.ComplexProductionMaterial; foreach (ComplexProductionDetail detail in DetailsMat) { detail.ReferenceDocumentId = id; detail.ResetSign(-1); } BusinessDomain.DataAccessProvider.AddUpdateComplexProductionMat(this, DetailsMat.ToArray(), BusinessDomain.AppConfiguration.AllowNegativeAvailability); // Save the input ComplexProduction in the database OperationType = OperationType.ComplexProductionProduct; foreach (ComplexProductionDetail detail in DetailsProd) { detail.ReferenceDocumentId = id; detail.ResetSign(1); } BusinessDomain.DataAccessProvider.AddUpdateComplexProductionProd(this, DetailsProd.ToArray(), BusinessDomain.AppConfiguration.AllowNegativeAvailability); Item.Cache.Clear(DetailsProd.Select(d => d.ItemId)); if (editMode && Total.IsZero()) { BusinessDomain.DataAccessProvider.DeleteOperationId(OperationType.ComplexProductionMaterial, id); ApplicationLogEntry.AddNew(string.Format(Translator.GetString("Void production No.{0} from {1}"), GetFormattedOperationNumber(id), BusinessDomain.GetFormattedDate(date))); } else if (editMode) { ApplicationLogEntry.AddNew(string.Format(Translator.GetString("Edit production No.{0} from {1}"), GetFormattedOperationNumber(id), BusinessDomain.GetFormattedDate(date))); } if (editMode) { RemoveAllEmptyDetails(); } transaction.Complete(); } }
public override void CommitChanges(bool logChanges = false, bool logNewDetailChanges = false, long?mainAvailabilityLocation = null, bool checkAvailability = false) { using (DbTransaction transaction = new DbTransaction(BusinessDomain.DataAccessProvider)) { // Create a new operation Id if needed); bool editMode = true; OperationState operationState = State; if (operationState == OperationState.New || operationState == OperationState.NewDraft || operationState == OperationState.NewPending) { id = CreateNewId(); // Set the new operation id editMode = false; } // Save the order in the database RestaurantOrderDetail reservationDetail = new RestaurantOrderDetail { ReferenceDocumentId = referenceDocumentId, Note = Note }; BusinessDomain.DataAccessProvider.AddUpdateReservation(this, reservationDetail); RestaurantOrder order = GetRestaurantOrder(); if (order.Details.Count > 0) { order.Id = id; order.CommitChanges(logChanges, logNewDetailChanges, mainAvailabilityLocation, checkAvailability); } // We have to delete the payment records if there is nothing left if (editMode && Persons.IsZero()) { BusinessDomain.DataAccessProvider.DeleteOperationId(OperationType.Reservation, id); ApplicationLogEntry.AddNew(string.Format(Translator.GetString("Void reservation No.{0} from {1}"), GetFormattedOperationNumber(id), BusinessDomain.GetFormattedDate(date))); } else if (!Persons.IsZero()) { // Don't update the amount paid if this is not a new sale if (editMode) { ApplicationLogEntry.AddNew(string.Format(Translator.GetString("Edit reservation No.{0} from {1}"), GetFormattedOperationNumber(id), BusinessDomain.GetFormattedDate(date))); } } IsDirty = false; transaction.Complete(); } }