示例#1
0
        public List <HG_Items> GetAll(int OrgId = 0, int Type = 1)
        {
            var           CurrOrgID = HttpContext.Current.Request.Cookies["UserInfo"];
            SqlConnection Con       = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Con"].ToString());

            Con.Open();
            SqlCommand      cmd     = null;
            SqlDataReader   SDR     = null;
            List <HG_Items> ListTmp = new List <HG_Items>();
            string          Query   = "SELECT * FROM  HG_Items where Type=" + Type.ToString() + " ORDER BY ItemID DESC";

            if (OrgId > 0)
            {
                Query = "SELECT * FROM  HG_Items where OrgID=" + OrgId.ToString() + " and Type=" + Type.ToString() + " ORDER BY ItemID DESC";
            }
            else if (CurrOrgID != null && int.Parse(CurrOrgID["OrgId"]) > 0)
            {
                Query = "SELECT * FROM  HG_Items where OrgID=" + CurrOrgID["OrgId"] + "and Type=" + Type.ToString() + " ORDER BY ItemID DESC";
            }
            try
            {
                cmd = new SqlCommand(Query, Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    HG_Items ObjTmp = new HG_Items();
                    ObjTmp.ItemID          = SDR.GetInt32(0);
                    ObjTmp.CategoryID      = SDR.GetInt32(1);
                    ObjTmp.OrgID           = SDR.GetInt32(2);
                    ObjTmp.Items           = SDR.GetString(3);
                    ObjTmp.Price           = SDR.GetDouble(4);
                    ObjTmp.Qty             = SDR.GetString(5);
                    ObjTmp.ItemMode        = SDR.GetString(6);
                    ObjTmp.Tax             = SDR.GetDouble(7);
                    ObjTmp.UpdateDate      = SDR.GetDateTime(10);
                    ObjTmp.Status          = SDR.GetBoolean(11);
                    ObjTmp.Image           = SDR.GetString(12);
                    ObjTmp.ApplyAddOn      = SDR.GetInt32(13);
                    ObjTmp.CostPrice       = SDR.GetDouble(14) == 0?SDR.GetDouble(4): SDR.GetDouble(14);
                    ObjTmp.AddOnCatId      = SDR.GetInt32(15);
                    ObjTmp.Type            = SDR.GetInt32(16);
                    ObjTmp.AddOnType       = SDR.GetInt32(17);
                    ObjTmp.ItemDiscription = SDR.GetString(18);
                    ObjTmp.ItemAvaibility  = SDR.GetInt32(19);
                    ObjTmp.MultiServing    = SDR.GetInt32(20);
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (Exception e) { e.ToString(); }
            finally { Con.Close(); }

            return(ListTmp);
        }
示例#2
0
        public HG_Items GetOne(Int64 ItemID)
        {
            SqlConnection Con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Con"].ToString());

            Con.Open();
            SqlCommand    cmd    = null;
            SqlDataReader SDR    = null;
            HG_Items      ObjTmp = new HG_Items();

            try
            {
                string Query = "SELECT * FROM  HG_Items where ItemID=@ItemID";
                cmd = new SqlCommand(Query, Con);
                cmd.Parameters.AddWithValue("@ItemID", ItemID);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ObjTmp.ItemID          = SDR.GetInt32(0);
                    ObjTmp.CategoryID      = SDR.GetInt32(1);
                    ObjTmp.OrgID           = SDR.GetInt32(2);
                    ObjTmp.Items           = SDR.GetString(3);
                    ObjTmp.Price           = SDR.GetDouble(4);
                    ObjTmp.Qty             = SDR.GetString(5);
                    ObjTmp.ItemMode        = SDR.GetString(6);
                    ObjTmp.Tax             = SDR.GetDouble(7);
                    ObjTmp.Status          = SDR.GetBoolean(11);
                    ObjTmp.Image           = SDR.GetString(12);
                    ObjTmp.ApplyAddOn      = SDR.GetInt32(13);
                    ObjTmp.CostPrice       = SDR.GetDouble(14) == 0 ? SDR.GetDouble(4) : SDR.GetDouble(14);
                    ObjTmp.AddOnCatId      = SDR.GetInt32(15);
                    ObjTmp.Type            = SDR.GetInt32(16);
                    ObjTmp.AddOnType       = SDR.GetInt32(17);
                    ObjTmp.ItemDiscription = SDR.GetString(18);
                    ObjTmp.ItemAvaibility  = SDR.GetInt32(19);
                    ObjTmp.MultiServing    = SDR.GetInt32(20);
                }
            }
            catch (Exception e)
            { e.ToString(); }

            finally { Con.Close(); }

            return(ObjTmp);
        }