Exemplo n.º 1
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        //实例化数据访问类
        NorthwindDataAccess nda = new NorthwindDataAccess();

        GridView1.DataSource = nda.GetCustOrdersDetails(10248);
        GridView1.DataBind();
    }
Exemplo n.º 2
0
        private void countButton_Click(object sender, EventArgs e)
        {
            int count;

            try
            {
                count = NorthwindDataAccess.CountShippers();

                shipperCountLabel.Text = count.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        //实例化数据访问类
        NorthwindDataAccess nda = new NorthwindDataAccess();

        //获取数据源
        GridView1.DataSource = nda.GetProducts();
        //数据绑定
        try
        {
            GridView1.DataBind();
        }
        catch (SqlException ex)
        {
            Label1.Text = "数据访问出错,错误消息是:" + ex.Message;
        }
    }
Exemplo n.º 4
0
        /// <summary>
        /// This method shows the use of the datareader
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void fillButton_Click(object sender, EventArgs e)
        {
            try
            {
                //set the cursor to the hour glass
                this.Cursor = Cursors.WaitCursor;

                customerComboBox.DataSource = NorthwindDataAccess.GetCustomers("");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                //reset cursor
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 5
0
        private void add1Button_Click(object sender, EventArgs e)
        {
            int rowsInserted;

            try
            {
                rowsInserted = NorthwindDataAccess.AddShipper(companyNameTextBox.Text, phoneTextBox.Text);
                if (rowsInserted == 1)
                {
                    MessageBox.Show("You have successfully added a Shipper.");
                    //clear the text from the textboxes
                    companyNameTextBox.Clear();
                    phoneTextBox.Clear();
                }
                else
                {
                    MessageBox.Show("Your Shipper has NOT been added to the database.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public virtual int GetIntId(T entity)
        {
            var newId = NorthwindDataAccess.LoadData <int>(SqlQuery).FirstOrDefault();

            return(newId);
        }
 public virtual int Delete(int id)
 {
     return(NorthwindDataAccess.ExecuteQuery(SqlQuery, id));
 }
 public virtual async Task <IEnumerable <T> > GetAllAsync()
 {
     return(await NorthwindDataAccess.LoadDataAsync <T>(SqlQuery));
 }
 public virtual IEnumerable <T> GetAll()
 {
     return(NorthwindDataAccess.LoadData <T>(SqlQuery));
 }
        public virtual async Task <T> GetAsync(int id)
        {
            var data = await NorthwindDataAccess.LoadDataAsync <T>(SqlQuery);

            return(data.FirstOrDefault());
        }
 public virtual T Get(int id)
 {
     return(NorthwindDataAccess.LoadData <T>(SqlQuery).FirstOrDefault());
 }
 public virtual int Add(T entity)
 {
     return(NorthwindDataAccess.ExecuteQuery <T>(SqlQuery, entity));
 }