Ejemplo n.º 1
0
    public List <storeData> getStoreData()
    {
        List <storeData> storeDataList = new List <storeData>();

        using (SqlCommand cmd = new SqlCommand("getStoreData", _sqlConn))
        {
            cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                _sqlConn.Open();
                using (var data = cmd.ExecuteReader())
                {
                    while (data.Read())
                    {
                        if (data[0].Equals(DBNull.Value))
                        {
                            break;
                        }

                        storeData sd = new storeData();
                        sd.storeId   = Convert.ToInt32(data["storeId"]);
                        sd.storeName = data["storeName"].ToString();
                        sd.storeName = sd.storeName.Replace(" ", string.Empty);
                        sd.storeNo   = data["storeNo"].ToString();
                        sd.storeNo   = sd.storeNo.Replace(" ", string.Empty);

                        storeDataList.Add(sd);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex.GetBaseException();
            }
            finally
            {
                _sqlConn.Close();
                cmd.Dispose();
            }

            return(storeDataList);
        }
    }
Ejemplo n.º 2
0
 public void addStoreData(storeData storeData)
 {
     using (SqlCommand cmd = new SqlCommand("addStoreData", _sqlConn))
     {
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.Add("@storeNo", SqlDbType.NChar).Value   = storeData.storeNo;
         cmd.Parameters.Add("@storeName", SqlDbType.NChar).Value = storeData.storeName;
         try
         {
             _sqlConn.Open();
             cmd.ExecuteNonQuery();
         }
         catch (Exception ex)
         {
             throw ex.GetBaseException();
         }
         finally
         {
             _sqlConn.Close();
             cmd.Dispose();
         }
     }
 }