Example #1
0
        public static ServingSize GetOne(int ID)
        {
            SqlConnection Con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Con"].ToString());

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

            try
            {
                string Query = "SELECT * FROM  HG_ServingSize where ServingId=" + ID;
                cmd = new SqlCommand(Query, Con);
                cmd.Parameters.AddWithValue("@ServingId", ID);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ObjTmp.ServingId = SDR.GetInt32(0);
                    ObjTmp.Name      = SDR.GetString(1);
                    ObjTmp.OrgId     = SDR.GetInt32(2);
                }
            }
            catch (Exception e)
            { e.ToString(); }

            finally { Con.Close(); }

            return(ObjTmp);
        }
Example #2
0
        public static List <ServingSize> GetAll(int OrgId)
        {
            DBCon              con       = new DBCon();
            SqlCommand         cmd       = null;
            SqlDataReader      SDR       = null;
            List <ServingSize> listOrgId = new List <ServingSize>();

            try
            {
                string Quary = "Select * from HG_ServingSize where OrgId=" + OrgId;
                cmd = new SqlCommand(Quary, con.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ServingSize OBJINT = new ServingSize();
                    OBJINT.ServingId = SDR.GetInt32(0);
                    OBJINT.Name      = SDR.GetString(1);
                    OBJINT.OrgId     = SDR.GetInt32(2);
                    listOrgId.Add(OBJINT);
                }
            }
            catch (Exception e) { e.ToString(); }
            finally { cmd.Dispose(); con.Con.Close(); }
            return(listOrgId);
        }