private DbDeleteStatement GetQuery_DeleteQuery(ProfessionalSaleLine _obj)
        {
            DbDeleteStatement clause = DbMgr.CreateDeleteClause();

            clause.DeleteFrom("ProfessionalSaleLines").Criteria.IsEqual("ProfessionalSaleLines", "ProfessionalSaleLineID", _obj.ProfessionalSaleLineID);

            return(clause);
        }
        protected override OpResult _Delete(ProfessionalSaleLine _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyDeleteAction(OpResult.ResultStatus.ObjectIsNull, _obj, "ProfessionalSaleLine object cannot be deleted as it is null"));
            }

            if (Exists(_obj))
            {
                ExecuteNonQuery(GetQuery_DeleteQuery(_obj));
                return(OpResult.NotifyDeleteAction(OpResult.ResultStatus.ExistsAndDeleted, _obj));
            }

            return(OpResult.NotifyDeleteAction(OpResult.ResultStatus.NotExists, _obj, "ProfessionalSaleLine object cannot be deleted as it does not exist"));
        }
        public BOProfessionalSaleLine(Accountant accountant, Sale _sale, ProfessionalSaleLine _line, BOContext context)
            : base(accountant, _sale, _line, context)
        {
            mObjectID                  = BOType.BOProfessionalSaleLine;
            mProfessionalSaleLine      = _line.Clone() as ProfessionalSaleLine;
            mProfessionalSaleLine.Sale = _sale;

            if (mProfessionalSaleLine.Sale.IsTaxInclusive == "Y")
            {
                mAmount = mProfessionalSaleLine.TaxInclusiveAmount;
            }
            else
            {
                mAmount = mProfessionalSaleLine.TaxExclusiveAmount;
            }
        }
        private void StoreLines(Sale _obj)
        {
            IList <SaleLine> lines = _obj.SaleLines;

            foreach (SaleLine line in lines)
            {
                RepositoryMgr.SaleLineMgr.Store(line);
                int?purchase_id      = line.SaleID;
                int?purchase_line_id = line.SaleLineID;
                if (line is ItemSaleLine)
                {
                    ItemSaleLine _line = line as ItemSaleLine;
                    _line.SaleID         = purchase_id;
                    _line.ItemSaleLineID = purchase_line_id;
                    RepositoryMgr.ItemSaleLineMgr.Store(_line);
                }
                else if (line is MiscSaleLine)
                {
                    MiscSaleLine _line = line as MiscSaleLine;
                    _line.SaleID         = purchase_id;
                    _line.MiscSaleLineID = purchase_line_id;
                    RepositoryMgr.MiscSaleLineMgr.Store(_line);
                }
                else if (line is ProfessionalSaleLine)
                {
                    ProfessionalSaleLine _line = line as ProfessionalSaleLine;
                    _line.SaleID = purchase_id;
                    _line.ProfessionalSaleLineID = purchase_line_id;
                    RepositoryMgr.ProfessionalSaleLineMgr.Store(_line);
                }
                else if (line is ServiceSaleLine)
                {
                    ServiceSaleLine _line = line as ServiceSaleLine;
                    _line.SaleID            = purchase_id;
                    _line.ServiceSaleLineID = purchase_line_id;
                    RepositoryMgr.ServiceSaleLineMgr.Store(_line);
                }
                else if (line is TimeBillingSaleLine)
                {
                    TimeBillingSaleLine _line = line as TimeBillingSaleLine;
                    _line.SaleID = purchase_id;
                    _line.TimeBillingSaleLineID = purchase_line_id;
                    RepositoryMgr.TimeBillingSaleLineMgr.Store(_line);
                }
            }
        }
        protected override OpResult _Store(ProfessionalSaleLine _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "ProfessionalSaleLine object cannot be created as it is null"));
            }

            if (Exists(_obj))
            {
                ExecuteNonQuery(GetQuery_UpdateQuery(_obj));
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj));
            }

            ExecuteNonQuery(GetQuery_InsertQuery(_obj));
            if (_obj.ProfessionalSaleLineID == null)
            {
                _obj.ProfessionalSaleLineID = DbMgr.GetLastInsertID();
            }
            _obj.FromDb = true;
            return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj));
        }
示例#6
0
        private Dictionary <string, DbFieldEntry> GetQueryMap_StoreProfessionalSaleLines(Sale _sale, ProfessionalSaleLine _line)
        {
            bool is_header = (_line == null);
            Dictionary <string, DbFieldEntry> query_map = new Dictionary <string, DbFieldEntry>();

            bool multi_currency_support = _sale.RepositoryMgr.CurrencyMgr.SupportMultiCurrency;

            #region Populate Sale Information
            query_map.Add("FirstName", DbMgr.CreateStringFieldEntry(is_header && _sale.Customer != null ? _sale.Customer.FirstName : ""));
            query_map.Add("CoLastName", DbMgr.CreateStringFieldEntry(is_header && _sale.Customer != null ? _sale.Customer.LastName : ""));
            query_map.Add("CardID", DbMgr.CreateStringFieldEntry(is_header && _sale.Customer != null ? _sale.Customer.CardIdentification : ""));
            query_map.Add("InvoiceNumber", DbMgr.CreateStringFieldEntry(is_header ? _sale.InvoiceNumber : ""));
            query_map.Add("Memo", DbMgr.CreateStringFieldEntry(is_header ? _sale.Memo : ""));
            query_map.Add("Inclusive", DbMgr.CreateStringFieldEntry(is_header && _sale.IsTaxInclusive == "Y" ? "1" : ""));
            query_map.Add("SaleDate", _sale.InvoiceDate != null && is_header ? (DbFieldEntry)DbMgr.CreateDateTimeFieldEntry(_sale.InvoiceDate) : (DbFieldEntry)DbMgr.CreateStringFieldEntry(""));
            query_map.Add("DeliveryStatus", DbMgr.CreateStringFieldEntry(is_header & _sale.InvoiceDelivery != null ? _sale.InvoiceDelivery.InvoiceDeliveryID : ""));
            query_map.Add("PromisedDate", is_header && _sale.PromisedDate != null ? (DbFieldEntry)DbMgr.CreateDateTimeFieldEntry(_sale.PromisedDate) : (DbFieldEntry)DbMgr.CreateStringFieldEntry(""));
            query_map.Add("Comment", DbMgr.CreateStringFieldEntry(is_header && _sale.Comment != null ? _sale.Comment : ""));
            query_map.Add("SalespersonLastName", DbMgr.CreateStringFieldEntry(is_header && _sale.SalesPerson != null ? _sale.SalesPerson.LastName : ""));
            query_map.Add("SalespersonFirstName", DbMgr.CreateStringFieldEntry(is_header && _sale.SalesPerson != null ? _sale.SalesPerson.FirstName : ""));

            string sale_status_text = "";
            Status sale_status      = _sale.InvoiceStatus;
            if (is_header && sale_status != null)
            {
                if (sale_status.Type == Status.StatusType.Quote)
                {
                    sale_status_text = "Q";
                }
                else if (sale_status.Type == Status.StatusType.Order)
                {
                    sale_status_text = "O";
                }
                else if (sale_status.Type == Status.StatusType.Open)
                {
                    sale_status_text = "I";
                }
            }
            query_map.Add("SaleStatus", DbMgr.CreateStringFieldEntry(sale_status_text));

            if (_sale.InvoiceStatus.Type == Accounting.Core.Definitions.Status.StatusType.Order ||
                _sale.InvoiceStatus.Type == Accounting.Core.Definitions.Status.StatusType.Open
                )
            {
                //sqlArray.Add("AmountPaid", DbMgr.CreateDoubleFieldEntry(_obj.AmountPaid));
            }
            if (multi_currency_support)
            {
                query_map.Add("CurrencyCode", DbMgr.CreateStringFieldEntry(is_header && RepositoryMgr.IsMultiUserVersion && _sale.Currency != null ? _sale.Currency.CurrencyCode : ""));
                query_map.Add("ExchangeRate", DbMgr.CreateDoubleFieldEntry(is_header && RepositoryMgr.IsMultiUserVersion ? _sale.TransactionExchangeRate : 0));
            }
            query_map.Add("PaymentIsDue", DbMgr.CreateIntFieldEntry(is_header && _sale.Terms != null ? _sale.Terms.PaymentIsDue : 0));
            query_map.Add("DiscountDays", DbMgr.CreateIntFieldEntry(is_header && _sale.Terms != null ? _sale.Terms.DiscountDays : 0));
            query_map.Add("BalanceDueDays", DbMgr.CreateIntFieldEntry(is_header && _sale.Terms != null ? _sale.Terms.BalanceDueDays : 0));
            query_map.Add("PercentDiscount", DbMgr.CreateDoubleFieldEntry(is_header && _sale.Terms != null ? _sale.Terms.EarlyPaymentDiscountPercent : 0));
            query_map.Add("PercentMonthlyCharge", DbMgr.CreateDoubleFieldEntry(is_header && _sale.Terms != null ? _sale.Terms.LatePaymentChargePercent : 0));
            query_map.Add("ReferralSource", DbMgr.CreateStringFieldEntry(is_header && _sale.ReferralSource != null ? _sale.ReferralSource.Description : ""));
            #endregion

            #region Populate Line Information
            query_map.Add("AccountNumber", !is_header ? GetAccountNumber(_line.Account) : DbMgr.CreateStringFieldEntry(""));
            query_map.Add("Description", DbMgr.CreateStringFieldEntry(!is_header ? _line.Description : ""));
            query_map.Add("ExTaxAmount", DbMgr.CreateDoubleFieldEntry(!is_header ? _line.TaxExclusiveAmount : 0));
            query_map.Add("IncTaxAmount", DbMgr.CreateDoubleFieldEntry(!is_header ? _line.TaxInclusiveAmount : 0));
            query_map.Add("Job", DbMgr.CreateStringFieldEntry(!is_header && _line.Job != null ? _line.Job.JobName : ""));
            query_map.Add("TaxCode", DbMgr.CreateStringFieldEntry(!is_header && _line.TaxCode != null ? _line.TaxCode.Code : ""));
            query_map.Add("DetailDate", !is_header && _line.LineDate != null ? (DbFieldEntry)DbMgr.CreateDateTimeFieldEntry(_line.LineDate) : (DbFieldEntry)DbMgr.CreateStringFieldEntry(""));
            #endregion

            return(query_map);
        }
 private DbUpdateStatement GetQuery_UpdateQuery(ProfessionalSaleLine _obj)
 {
     return(DbMgr.CreateUpdateClause("ProfessionalSaleLines", GetFields(_obj), "ProfessionalSaleLineID", _obj.ProfessionalSaleLineID));
 }
        private DbInsertStatement GetQuery_InsertQuery(ProfessionalSaleLine _obj)
        {
            Dictionary <string, DbFieldEntry> fields = GetFields(_obj);

            return(DbMgr.CreateInsertClause("ProfessionalSaleLines", fields));
        }