Пример #1
0
        public static OfferTitle GetOneByItems(int CBID)
        {
            DBCon         dBCon = new DBCon();
            SqlCommand    cmd   = null;
            SqlDataReader SDR   = null;
            OfferTitle    Tmp   = new OfferTitle();

            Tmp.TotalItemPrice = 0.00;
            string Query = "SELECT * FROM  OfferTitle where CBID=" + CBID.ToString();

            try
            {
                cmd = new SqlCommand(Query, dBCon.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    int        index  = 0;
                    OfferTitle ObjTmp = new OfferTitle();
                    ObjTmp.TitleId        = SDR.GetInt32(index++);
                    ObjTmp.CBID           = SDR.GetInt32(index++);
                    ObjTmp.Name           = SDR.GetString(index++);
                    ObjTmp.Discription    = SDR.GetString(index++);
                    ObjTmp.MaxOrdQty      = SDR.GetInt32(index++);
                    ObjTmp.FinalPrice     = SDR.GetDouble(index++);
                    ObjTmp.Tax            = SDR.GetDouble(index++);
                    ObjTmp.itemOffers     = ItemOffer.GetAll("Select *, dbo.GetItemName(ItemId),dbo.GetItemPrice(ItemId)  FROM  ItemOffer where CashBkId=" + ObjTmp.CBID + " and IsDeleted=0");
                    ObjTmp.TotalItemPrice = ObjTmp.itemOffers.Sum(x => x.TotalItemPrice);
                    Tmp = ObjTmp;
                }
            }
            catch (Exception e) { e.ToString(); }
            finally { dBCon.Close(); }

            return(Tmp);
        }
Пример #2
0
        public static OfferTitle GetOne(int CBID, int Type)
        {
            DBCon         dBCon = new DBCon();
            SqlCommand    cmd   = null;
            SqlDataReader SDR   = null;
            OfferTitle    Tmp   = new OfferTitle();
            string        Query = "SELECT * FROM  OfferTitle where CBID=" + CBID.ToString() + " and Type=" + Type;

            try
            {
                cmd = new SqlCommand(Query, dBCon.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    int        index  = 0;
                    OfferTitle ObjTmp = new OfferTitle();
                    ObjTmp.TitleId        = SDR.GetInt32(index++);
                    ObjTmp.CBID           = SDR.GetInt32(index++);
                    ObjTmp.Name           = SDR.GetString(index++);
                    ObjTmp.Discription    = SDR.GetString(index++);
                    ObjTmp.MaxOrdQty      = SDR.GetInt32(index++);
                    ObjTmp.FinalPrice     = SDR.GetDouble(index++);
                    ObjTmp.Tax            = SDR.GetDouble(index++);
                    ObjTmp.Type           = SDR.GetInt32(index++);
                    ObjTmp.KeepFixPrice   = SDR.GetBoolean(index++);
                    ObjTmp.OfferMenus     = OfferMenu.GetAll(ObjTmp.TitleId);
                    ObjTmp.TotalItemPrice = ObjTmp.OfferMenus.Sum(x => x.TotalItmPrice);
                    Tmp = ObjTmp;
                }
            }
            catch (Exception e) { e.ToString(); }
            finally { dBCon.Close(); }

            return(Tmp);
        }