private void button3_Click(object sender, EventArgs e) { DataRow dr = GetSelectedRow(); if (dr == null) { return; } DbItem db = new DbItem(); if (MessageBox.Show("למחוק את הרשומה?", "", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { db.Delete(Convert.ToInt32(dr["ItemId"])); dataGridView1.DataSource = db.GetAllItems().Tables[0]; } }
private void sales_Load(object sender, EventArgs e) { db = new DbItem(); // dataGridView1.DataSource = db.GetAllItems().Tables[0]; //מכניס ערך של ההזמנה הכי חדשה. textBox1.Text = db.GetQuery("SELECT Count(*) FROM Sales").Tables[0].Rows[0][0].ToString(); textBox1.Text = (int.Parse(textBox1.Text) + 1).ToString(); DataTable dt = db.GetQuery("select * from client").Tables[0]; comboBox1.DataSource = db.GetQuery("select * from client").Tables[0]; //fill combo comboBox1.ValueMember = "clientId"; //שם הטור שיוצג comboBox2.DataSource = db.GetQuery("select * from item").Tables[0]; //fill combo comboBox2.ValueMember = "itemName"; //שם הטור שיוצג dt = db.GetQuery("select * from worker").Tables[0]; comboBox3.DataSource = db.GetQuery("select * from worker").Tables[0]; //fill combo comboBox3.ValueMember = "id"; //שם הטור שיוצג }
private void button4_Click(object sender, EventArgs e) { DbItem db = new DbItem(); item editItem = new item(); editItem.ItemId = Convert.ToInt32(textBox1.Text); editItem.Itemname = textBox2.Text; editItem.ItemPrice = Convert.ToInt32(textBox3.Text); editItem.Quantity = Convert.ToInt32(textBox4.Text); editItem.idSup = Convert.ToInt32(comboBox1.Text); DialogResult result = System.Windows.Forms.DialogResult.OK; if (result == System.Windows.Forms.DialogResult.OK) { db.Update(editItem); MessageBox.Show("update item"); dataGridView1.DataSource = db.GetAllItems().Tables[0]; } }