Beispiel #1
0
        public Model.CompanyType GetCompanyType(string id)
        {
            SqlConnection conn = new SqlConnection(DBConnectionString);

            Model.CompanyType _CompanyType = new Model.CompanyType();

            try {
                conn.Open();

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

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

                while (reader.Read())
                {
                    _CompanyType = new Model.CompanyType(int.Parse(reader["ID"].ToString()), reader["Name"].ToString());
                }
                reader.Close();
            }
            catch (SqlException e) {
                System.Windows.MessageBox.Show(e.Message);
            }
            finally {
                conn.Close();
                conn.Dispose();
            }
            return(_CompanyType);
        }
 public void Remove(Model.CompanyType entity)
 {
     if (entity == null)
     {
         throw new ArgumentNullException("entity");
     }
     Remove(entity.CompanyTypeId);
 }
        public void Update(Model.CompanyType entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            string update = string.Format(@"update  CompanyType set CompanyTypeName= @CompanyTypeName,Description= @Description where CompanyTypeId = @CompanyTypeId");

            Connection.Execute(update, entity, transaction: Transaction);
        }
        public void Add(Model.CompanyType entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            string insert = string.Format(@"insert into CompanyType(CompanyTypeName,Description) values (@CompanyTypeName,@Description)");

            Connection.Execute(insert, entity, Transaction);
        }