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); }
public static List <OfferMenu> GetAll(int OfferTitleId) { DBCon dBCon = new DBCon(); SqlCommand cmd = null; SqlDataReader SDR = null; List <OfferMenu> TmpList = new List <OfferMenu>(); string Query = "SELECT * FROM OfferMenu where OfferTitleId=" + OfferTitleId; try { cmd = new SqlCommand(Query, dBCon.Con); SDR = cmd.ExecuteReader(); while (SDR.Read()) { int index = 0; OfferMenu ObjTmp = new OfferMenu(); ObjTmp.MenuId = SDR.GetInt32(index++); ObjTmp.Name = SDR.GetString(index++); ObjTmp.IsComplementry = SDR.GetBoolean(index++); ObjTmp.CBID = SDR.GetInt32(index++); ObjTmp.OfferTitleId = SDR.GetInt32(index++); ObjTmp.Min = SDR.GetInt32(index++); ObjTmp.Max = SDR.GetInt32(index++); ObjTmp.itemOffers = ItemOffer.GetAll("Select *, dbo.GetItemName(ItemId),dbo.GetItemPrice(ItemId) FROM ItemOffer where MenuId=" + ObjTmp.MenuId + " and IsDeleted=0"); ObjTmp.TotalItmPrice = ObjTmp.itemOffers.Sum(x => x.TotalItemPrice); TmpList.Add(ObjTmp); } } catch (Exception e) { e.ToString(); } finally { dBCon.Close(); } return(TmpList); }