Exemplo n.º 1
0
        public Model.Home GetHomeFromId(int id)
        {
            SqlConnection conn = new SqlConnection(DBConnectionString);

            Model.Home _home = new Model.Home();

            try {
                conn.Open();

                SqlCommand cmd = new SqlCommand("GetHomeFromId", conn);

                cmd.CommandType = CommandType.StoredProcedure;
                SqlParameter parameter = new SqlParameter();
                cmd.Parameters.Add(new SqlParameter("@id", id));
                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    _home = new Model.Home(int.Parse(reader["ID"].ToString()), reader["Street_Address"].ToString(), int.Parse(reader["Postcode"].ToString()), reader["Region"].ToString());
                }
                reader.Close();
            }
            catch (SqlException e) {
                System.Windows.MessageBox.Show(e.Message);
            }
            finally {
                conn.Close();
                conn.Dispose();
            }
            return(_home);
        }
Exemplo n.º 2
0
 public Book.Model.Home GetCount()
 {
     Book.Model.Home      home     = new Model.Home();
     Book.DAL.T_Base_Book book_dal = new DAL.T_Base_Book();
     home.BookCount = book_dal.GetCount();
     Book.DAL.T_Base_Provider provider_dal = new DAL.T_Base_Provider();
     home.ProviderCount = provider_dal.GetCount();
     Book.DAL.T_Base_Customer customer_dal = new DAL.T_Base_Customer();
     home.CustomerCount = customer_dal.GetCount();
     Book.DAL.T_Stock_In in_dal = new DAL.T_Stock_In();
     home.InHeadCount = in_dal.GetCount();
     Book.DAL.T_Stock_Out out_dal = new DAL.T_Stock_Out();
     home.OutHeadCount = in_dal.GetCount();
     return(home);
 }