Exemplo n.º 1
0
    public AidsTypestruct getAidsBrandList()
    {
        AidsTypestruct returnValue = new AidsTypestruct();

        returnValue.HearingList = new List <CreateAidsBrand>();
        returnValue.FMList      = new List <CreateAidsBrand>();
        returnValue.eEarList    = new List <CreateAidsBrand>();
        DataBase Base = new DataBase();

        using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString()))
        {
            try
            {
                Sqlconn.Open();
                string        sql = "SELECT * FROM AidsBrandTable ORDER BY ID ";
                SqlCommand    cmd = new SqlCommand(sql, Sqlconn);
                SqlDataReader dr  = cmd.ExecuteReader();
                while (dr.Read())
                {
                    CreateAidsBrand addValue = new CreateAidsBrand();
                    addValue.ID        = dr["ID"].ToString();
                    addValue.brandName = dr["Brand"].ToString();
                    addValue.brandType = dr["Category"].ToString();
                    if (addValue.brandType == "1")
                    {
                        returnValue.HearingList.Add(addValue);
                    }
                    else if (addValue.brandType == "2")
                    {
                        returnValue.eEarList.Add(addValue);
                    }
                    else if (addValue.brandType == "3")
                    {
                        returnValue.FMList.Add(addValue);
                    }
                }
                dr.Close();
                Sqlconn.Close();
            }
            catch (Exception e)
            {
                returnValue.checkNo  = "-1";
                returnValue.errorMsg = e.Message;
            }
        }
        return(returnValue);
    }
    public AidsTypestruct getAidsBrandList()
    {
        AidsTypestruct returnValue = new AidsTypestruct();
        returnValue.HearingList = new List<CreateAidsBrand>();
        returnValue.FMList = new List<CreateAidsBrand>();
        returnValue.eEarList = new List<CreateAidsBrand>();
        DataBase Base = new DataBase();
        using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString()))
        {
            try
            {
                Sqlconn.Open();
                string sql = "SELECT * FROM AidsBrandTable ORDER BY ID ";
                SqlCommand cmd = new SqlCommand(sql, Sqlconn);
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    CreateAidsBrand addValue = new CreateAidsBrand();
                    addValue.ID = dr["ID"].ToString();
                    addValue.brandName = dr["Brand"].ToString();
                    addValue.brandType = dr["Category"].ToString();
                    if (addValue.brandType == "1")
                    {
                        returnValue.HearingList.Add(addValue);
                    }
                    else if (addValue.brandType == "2")
                    {
                        returnValue.eEarList.Add(addValue);
                    }
                    else if (addValue.brandType == "3")
                    {
                        returnValue.FMList.Add(addValue);
                    }

                }
                dr.Close();
                Sqlconn.Close();
            }
            catch (Exception e)
            {
                returnValue.checkNo = "-1";
                returnValue.errorMsg = e.Message;
            }
        }
        return returnValue;
    }