コード例 #1
0
        public static bool Delete(Product entity)
        {
            SqlCommand command = new SqlCommand("DeleteProduct", Helper.Connection);
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@id", entity.ProductID);

            return Helper.MyExecuteNonQuery(command);
        }
コード例 #2
0
        public static bool Add(Product entity)
        {
            SqlCommand command = new SqlCommand("AddProduct", Helper.Connection);
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@n", entity.ProductName);
            command.Parameters.AddWithValue("@p", entity.UnitPrice);
            command.Parameters.AddWithValue("@s", entity.UnitsInStock);

            return Helper.MyExecuteNonQuery(command);
        }
コード例 #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0) return;

            Product deleted = new Product();
            deleted.ProductID = (int)dataGridView1.CurrentRow.Cells["ProductID"].Value;
            if (!Products.Delete(deleted))
                MessageBox.Show("Ürün Silenemedi");

            dataGridView1.DataSource = Products.getList();
        }
コード例 #4
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Product updated = new Product();
            updated.ProductID = (int)txtProductName.Tag;
            updated.ProductName = txtProductName.Text;
            updated.UnitPrice = nudPrice.Value;
            updated.UnitsInStock = (short)nudPrice.Value;
            if (!Products.Update(updated))
                MessageBox.Show("Ürün Güncellenemedi");

            dataGridView1.DataSource = Products.getList();
        }
コード例 #5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Product entity = new Product();
            entity.ProductName = txtProductName.Text;
            entity.UnitPrice = nudPrice.Value;
            entity.UnitsInStock = (short)nudStock.Value;
            if (!Products.Add(entity))
                MessageBox.Show("Ürün Eklenemedi");

            //ekledikten sonra listelemeyi yeniden yapıyoruz.
            dataGridView1.DataSource = Products.getList();
        }