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); }
public static List <ItemOffer> GetAll(string Query) { DBCon dBCon = new DBCon(); SqlCommand cmd = null; SqlDataReader SDR = null; List <ItemOffer> ListTmp = new List <ItemOffer>(); try { cmd = new SqlCommand(Query, dBCon.Con); SDR = cmd.ExecuteReader(); while (SDR.Read()) { int index = 0; ItemOffer ObjTmp = new ItemOffer(); ObjTmp.ItemOfferId = SDR.GetInt32(index++); ObjTmp.ItemId = SDR.GetInt32(index++); ObjTmp.Min = SDR.GetInt32(index++); ObjTmp.Max = SDR.GetInt32(index++); ObjTmp.CashBkId = SDR.GetInt32(index++); ObjTmp.MenuId = SDR.GetInt32(index++); ObjTmp.MenuId = SDR.GetInt32(index++); ObjTmp.ItemName = SDR.GetString(index++); ObjTmp.TotalItemPrice = SDR.GetDouble(index++); ListTmp.Add(ObjTmp); } } catch (Exception e) { e.ToString(); } finally { dBCon.Close(); } return(ListTmp); }
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); }
public static OfferObj GetAll(int CBID) { DBCon dBCon = new DBCon(); SqlCommand cmd = null; SqlDataReader SDR = null; OfferObj offerObj = new OfferObj(); offerObj.CBID = CBID; List <ItemOffer> ListTmp = new List <ItemOffer>(); string Query = "SELECT ItemOfferId,ItemId,Min,Max,CashBkId,dbo.GetItemName(ItemId),dbo.GetItemPrice(ItemId) FROM ItemOffer where CashBkId=" + CBID.ToString() + " and IsDeleted=0"; try { cmd = new SqlCommand(Query, dBCon.Con); SDR = cmd.ExecuteReader(); while (SDR.Read()) { int index = 0; ItemOffer ObjTmp = new ItemOffer(); ObjTmp.ItemOfferId = SDR.GetInt32(index++); ObjTmp.ItemId = SDR.GetInt32(index++); ObjTmp.Min = SDR.GetInt32(index++); ObjTmp.Max = SDR.GetInt32(index++); ObjTmp.CashBkId = SDR.GetInt32(index++); ObjTmp.ItemName = SDR.GetString(index++); ObjTmp.TotalItemPrice = SDR.GetDouble(index++); offerObj.Min = ObjTmp.Min; offerObj.Max = ObjTmp.Max; ListTmp.Add(ObjTmp); } offerObj.itemOffers = ListTmp; } catch (Exception e) { e.ToString(); } finally { dBCon.Close(); } return(offerObj); }