Ejemplo n.º 1
0
 public DishTypeData GetDishTypeByID(int dishTypeID)
 {
     try
     {
         string       SpName   = "dbo.DishType_GetByID";
         DishTypeData dishType = null;
         using (SqlConnection SqlConn = new SqlConnection())
         {
             SqlConn.ConnectionString = SystemConfigurations.EateryConnectionString;
             SqlConn.Open();
             SqlCommand SqlCmd = new SqlCommand(SpName, SqlConn);
             SqlCmd.CommandType = CommandType.StoredProcedure;
             SqlCmd.Parameters.Add(new SqlParameter("@DishTypeID", dishTypeID));
             using (SqlDataReader Reader = SqlCmd.ExecuteReader())
             {
                 if (Reader.HasRows)
                 {
                     Reader.Read();
                     dishType              = new DishTypeData();
                     dishType.DishTypeID   = Convert.ToInt32(Reader["DishTypeID"]);
                     dishType.DishTypeName = Convert.ToString(Reader["DishTypeName"]);
                 }
             }
             SqlConn.Close();
         }
         return(dishType);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
 public List <DishTypeData> GetDishTypeList()
 {
     try
     {
         string SpName = "dbo.DishType_Get";
         List <DishTypeData> ListDishType = new List <DishTypeData>();
         using (SqlConnection SqlConn = new SqlConnection())
         {
             SqlConn.ConnectionString = SystemConfigurations.EateryConnectionString;
             SqlConn.Open();
             SqlCommand SqlCmd = new SqlCommand(SpName, SqlConn);
             SqlCmd.CommandType = CommandType.StoredProcedure;
             using (SqlDataReader Reader = SqlCmd.ExecuteReader())
             {
                 if (Reader.HasRows)
                 {
                     while (Reader.Read())
                     {
                         DishTypeData dishType = new DishTypeData();
                         dishType.DishTypeID   = Convert.ToInt32(Reader["DishTypeID"]);
                         dishType.DishTypeName = Convert.ToString(Reader["DishTypeName"]);
                         ListDishType.Add(dishType);
                     }
                 }
             }
             SqlConn.Close();
         }
         return(ListDishType);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 3
0
        //通过菜系ID返回菜系
        public static DishTypeData GetTypeData(int DtId)
        {
            String connectStr = ConnectorInfo.connectStr;
            MySqlConnection conn = new MySqlConnection(connectStr);
            conn.Open();

            String sql = "select * from dishtypeinfo where DtId="+DtId;
            MySqlCommand mySqlCommand = new MySqlCommand(sql, conn);
            MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader();
            mySqlDataReader.Read();
            DishTypeData dish = new DishTypeData(DtId, mySqlDataReader.GetString("DtTitle"));
            return dish;
        }
Ejemplo n.º 4
0
 /*
  * 返回所有菜系
  * */
 public static List<DishTypeData> GetDishTypeDatas()
 {
     String connectStr = ConnectorInfo.connectStr;
     MySqlConnection conn = new MySqlConnection(connectStr);
     conn.Open();
     List<DishTypeData> dishTypeDatas = new List<DishTypeData>();
     DishTypeData dishTypeData;
     String sql = "select * from dishtypeinfo";
     MySqlCommand mySqlCommand = new MySqlCommand(sql, conn);
     MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader();
     while (mySqlDataReader.Read())
     {
         dishTypeData = new DishTypeData(mySqlDataReader.GetInt32("DtId"), mySqlDataReader.GetString("DtTitle"));
         dishTypeDatas.Add(dishTypeData);
     }
     return dishTypeDatas;
 }