Exemple #1
0
        public DiscountModel GetDiscount(int id)
        {
            DiscountModel model       = null;
            string        commandText =
                @"SELECT d.ID AS DISCOUNT_ID
       , d.D_NAME
       , d.VALID_FROM_DATE
       , d.VALID_TO_DATE
       , d.DISCOUNT_KIND_ID
       , dk.DK_NAME
       , d.D_VALUE
 FROM DISCOUNT d
 LEFT JOIN DISCOUNT_KIND dk ON dk.ID = d.DISCOUNT_KIND_ID
 WHERE d.ID = " + SQLInt(id);

            using (DataTable dtDiscounts = FillDataTable(commandText))
            {
                if (dtDiscounts.Rows.Count > 0)
                {
                    DataRow drDiscount = dtDiscounts.Rows[0];
                    model = new DiscountModel()
                    {
                        DiscountId       = TryParse.ToInt32(drDiscount["DISCOUNT_ID"]),
                        Name             = TryParse.ToString(drDiscount["D_NAME"]),
                        DiscountKindId   = TryParse.ToInt32(drDiscount["DISCOUNT_KIND_ID"]),
                        DiscountKindName = TryParse.ToString(drDiscount["DK_NAME"]),
                        ValidFrom        = TryParse.ToDateTime(drDiscount["VALID_FROM_DATE"]),
                        ValidTo          = TryParse.ToDateTime(drDiscount["VALID_TO_DATE"]),
                        Value            = TryParse.ToDecimal(drDiscount["D_VALUE"]),
                    };
                }
            }
            return(model);
        }
Exemple #2
0
        public List <DiscountModel> GetDiscounts()
        {
            List <DiscountModel> model = new List <DiscountModel>();
            string commandText         =
                @"SELECT d.ID AS DISCOUNT_ID
       , d.D_NAME
       , d.VALID_FROM_DATE
       , d.VALID_TO_DATE
       , d.DISCOUNT_KIND_ID
       , dk.DK_NAME
       , d.D_VALUE
 FROM DISCOUNT d
 LEFT JOIN DISCOUNT_KIND dk ON dk.ID = d.DISCOUNT_KIND_ID
 ORDER BY d.D_NAME ";

            using (DataTable dtDiscounts = FillDataTable(commandText))
            {
                foreach (DataRow drDiscount in dtDiscounts.Rows)
                {
                    model.Add(new DiscountModel()
                    {
                        DiscountId       = TryParse.ToInt32(drDiscount["DISCOUNT_ID"]),
                        Name             = TryParse.ToString(drDiscount["D_NAME"]),
                        DiscountKindId   = TryParse.ToInt32(drDiscount["DISCOUNT_KIND_ID"]),
                        DiscountKindName = TryParse.ToString(drDiscount["DK_NAME"]),
                        ValidFrom        = TryParse.ToDateTime(drDiscount["VALID_FROM_DATE"]),
                        ValidTo          = TryParse.ToDateTime(drDiscount["VALID_TO_DATE"]),
                        Value            = TryParse.ToDecimal(drDiscount["D_VALUE"]),
                    });
                }
            }
            return(model);
        }
Exemple #3
0
        public List <CCardModel> GetCards()
        {
            List <CCardModel> model       = new List <CCardModel>();
            string            commandText =
                @"SELECT cc.ID
       , cc.C_NUMBER
       , cc.VALID_FROM_DATE
       , cc.VALID_TO_DATE
       , cc.IS_BLOCKED
       , cc.CONTRACTOR_ID
 FROM C_CARD cc
 ORDER BY cc.C_NUMBER ";

            using (DataTable dtCCards = FillDataTable(commandText))
            {
                foreach (DataRow drCCard in dtCCards.Rows)
                {
                    model.Add(new CCardModel()
                    {
                        CardId       = TryParse.ToInt32(drCCard["ID"]),
                        CNumber      = TryParse.ToString(drCCard["C_NUMBER"]),
                        ValidFrom    = TryParse.ToDateTime(drCCard["VALID_FROM_DATE"]),
                        ValidTo      = TryParse.ToDateTime(drCCard["VALID_TO_DATE"]),
                        IsBlocked    = (TryParse.ToInt32(drCCard["IS_BLOCKED"]) == 1),
                        ContractorId = TryParse.ToInt32(drCCard["CONTRACTOR_ID"])
                    });
                }
            }
            return(model);
        }
Exemple #4
0
        public CCardModel GetCard(int id)
        {
            CCardModel model       = null;
            string     commandText =
                @"SELECT cc.ID
       , cc.C_NUMBER
       , cc.VALID_FROM_DATE
       , cc.VALID_TO_DATE
       , cc.IS_BLOCKED
       , c.ID AS CONTRACTOR_ID
       , c.C_NAME AS CONTRACTOR_NAME
       , cc.DISCOUNT_GROUP_ID
       , cc.OWNER_NAME
       , cc.CAR_NUMBER
       , cc.IS_INVOICE
       , cc.IS_MANUAL_INPUT
       , cc.C_COMMENT
       , cc.S_PAYMENT_TYPE_ID
       , cc.C_PASSWORD
 FROM C_CARD cc
 LEFT JOIN CONTRACTOR c ON c.ID = cc.CONTRACTOR_ID
 WHERE cc.ID = " + SQLInt(id);

            using (DataTable dtCCards = FillDataTable(commandText))
            {
                foreach (DataRow drCCard in dtCCards.Rows)
                {
                    model = new CCardModel()
                    {
                        CardId          = TryParse.ToInt32(drCCard["ID"]),
                        CNumber         = TryParse.ToString(drCCard["C_NUMBER"]),
                        ValidFrom       = TryParse.ToDateTime(drCCard["VALID_FROM_DATE"]),
                        ValidTo         = TryParse.ToDateTime(drCCard["VALID_TO_DATE"]),
                        IsBlocked       = (TryParse.ToInt32(drCCard["IS_BLOCKED"]) == 1),
                        ContractorId    = TryParse.ToInt32(drCCard["CONTRACTOR_ID"]),
                        ContractorName  = TryParse.ToString(drCCard["CONTRACTOR_NAME"]),
                        DiscountGroupId = TryParse.ToInt32(drCCard["DISCOUNT_GROUP_ID"], -1),
                        OwnerName       = TryParse.ToString(drCCard["OWNER_NAME"]),
                        CarNumber       = TryParse.ToString(drCCard["CAR_NUMBER"]),
                        IsInvoice       = (TryParse.ToInt32(drCCard["IS_INVOICE"]) == 1),
                        IsManualInput   = (TryParse.ToInt32(drCCard["IS_MANUAL_INPUT"]) == 1),
                        Password        = TryParse.ToString(drCCard["C_PASSWORD"]),
                        Comment         = TryParse.ToString(drCCard["C_COMMENT"]),
                        PaymentTypeId   = TryParse.ToInt32(drCCard["S_PAYMENT_TYPE_ID"])
                    };
                }
            }
            return(model);
        }