public void productAdd(product product) { createConnection(); connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "productAdd"; command.Parameters.Add("@name", SqlDbType.NVarChar, 50); command.Parameters["@name"].Value = product.name; command.Parameters.Add("@grup", SqlDbType.NVarChar, 50); command.Parameters["@grup"].Value = product.grup; command.Parameters.Add("@price", SqlDbType.Money, 50); command.Parameters["@price"].Value = product.price; command.Parameters.Add("@brand", SqlDbType.NVarChar, 50); command.Parameters["@brand"].Value = product.brand; command.Parameters.Add("@discount", SqlDbType.Int, 50); command.Parameters["@discount"].Value = product.discount; command.ExecuteNonQuery(); connection.Close(); connection.Dispose(); }
private void btnOk_Click(object sender, EventArgs e) { bool isInteger; isInteger= control.integerControl(textBox9.Text); if (isInteger) { isInteger = control.integerControl(textBox11.Text); if (isInteger) { if (newProduct) { if (textBox11.Text != String.Empty ) { if (textBox9.Text != String.Empty) { product product = new product(); product.name = textBox7.Text.ToString(); product.grup = textBox8.Text.ToString(); product.price = Convert.ToDecimal(textBox9.Text); product.brand = Convert.ToString(comboBox1.Text); product.discount = Convert.ToInt32(textBox11.Text); productOP.productAdd(product); MessageBox.Show("Kayıt işlemi başarıyla gerçelşeştirildi", "Kayıt işlemi"); formLoad(); grb1.Visible = true; grb2.Visible = false; } else { errorProvider1.SetError(textBox9, "Sayı Giriniz"); } } else { errorProvider1.SetError(textBox11, "Sayı Giriniz"); } } else { product product = new product(); product.code = Convert.ToInt32(textBox6.Text); product.name = textBox7.Text.ToString(); product.grup = textBox8.Text.ToString(); product.price = Convert.ToDecimal(textBox9.Text); product.brand = Convert.ToString(comboBox1.Text); product.discount = Convert.ToInt32(textBox11.Text); productOP.productUpdate(product); MessageBox.Show("Güncelleme işlemi başarıyla gerçekleştirildi", "Güncelleme işlemi"); formLoad(); grb1.Visible = true; } } else { errorProvider1.SetError(textBox11, "Sayı Giriniz"); } } else { errorProvider1.SetError(textBox9, "Sayı giriniz"); } }
public List<product> productListByProductOrderID(int productListCode) { productOrderID = productListCode; listtable.Clear(); List<product> productList=new List<product>(); createConnection(); SqlDataAdapter adapter = new SqlDataAdapter("Select * from productListView", connection); adapter.Fill(listtable); for (int i = 0; i < listtable.Rows.Count ; i++) { if (productListCode == Convert.ToInt32(listtable.Rows[i][7])) { product product = new product(); product.code = Convert.ToInt32(listtable.Rows[i][0]); product.price = Convert.ToDecimal(listtable.Rows[i][1]); product.discount = Convert.ToInt32(listtable.Rows[i][2]); product.amount = Convert.ToInt32(listtable.Rows[i][3]); product.productOrderId = Convert.ToInt32(listtable.Rows[i][7]); product.name = listtable.Rows[i][4].ToString(); product.grup = listtable.Rows[i][5].ToString(); product.brand = listtable.Rows[i][6].ToString(); productList.Add(product); } } return productList; }