private void button3_Click(object sender, EventArgs e) { WindowsFormsApplication1.KindTreatment w = new WindowsFormsApplication1.KindTreatment(); DbKindTreatments db = new DbKindTreatments(); DataSet ds = new DataSet(); try { w.Id = int.Parse(textBox1.Text); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); if (db.KindTreatmentExist(w.Id) == true) { ds = db.getKindTreatmentInfo(w); textBox1.Text = ds.Tables[0].Rows[0]["Number"].ToString(); textBox3.Text = ds.Tables[0].Rows[0]["KindTreatment"].ToString(); textBox2.Text = ds.Tables[0].Rows[0]["Price"].ToString(); } else { textBox1.Text = "Id does not exist"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { DbKindTreatments db = new DbKindTreatments(); WindowsFormsApplication1.KindTreatment w = new WindowsFormsApplication1.KindTreatment(); try { w.Id = int.Parse(textBox1.Text); w.Kind = textBox3.Text; w.Price = int.Parse(textBox2.Text); } catch (Exception exception) { MessageBox.Show("Invalid parameters", "Error"); return; } if (db.KindTreatmentExist(w.Id)) { MessageBox.Show("Treatment Kind already exist"); return; } db.insertTreatmentKind(w); MessageBox.Show("add Treatment Kind Success"); }
private void button1_Click(object sender, EventArgs e) { DbKindTreatments db = new DbKindTreatments(); WindowsFormsApplication1.KindTreatment w = new WindowsFormsApplication1.KindTreatment(); try { w.Id = int.Parse(textBox1.Text); if (db.KindTreatmentExist(w.Id) == true) { DialogResult dialogResult = MessageBox.Show("Are You Sure To Delete Treatment Kind?", "Delete", MessageBoxButtons.YesNoCancel); if (dialogResult == DialogResult.Yes) { db.DeleteKindTreatment(w); MessageBox.Show("Treatment Kind was deleted Successfully"); } } else { MessageBox.Show("Treatment Kind with similar ID was not found , try again", "Error"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }
private void button1_Click(object sender, EventArgs e) { DbKindTreatments db = new DbKindTreatments(); try { WindowsFormsApplication1.KindTreatment w = new WindowsFormsApplication1.KindTreatment(); if (comboBox1.SelectedIndex == 0) { w.Id = int.Parse(textBox1.Text); dataGridView1.DataSource = db.SearchKindTreatmentByKindTreatmentId(w.Id).Tables[0]; } else if (comboBox1.SelectedIndex == 1) { dataGridView1.DataSource = db.SearchKindTreatmentByName(textBox1.Text).Tables[0]; } else { } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }
private void button1_Click(object sender, EventArgs e) { WindowsFormsApplication1.KindTreatment w = new WindowsFormsApplication1.KindTreatment(); DbKindTreatments db = new DbKindTreatments(); w.Id = int.Parse(textBox1.Text); w.Kind = textBox3.Text; w.Price = int.Parse(textBox2.Text); db.UpdateKindTreatment(w); MessageBox.Show("Successfully updated Treatment Kind"); }