private void button1_Click(object sender, EventArgs e) { DbClients db = new DbClients(); WindowsFormsApplication1.Client w = new WindowsFormsApplication1.Client(); try { w.Id = int.Parse(textBox1.Text); if (db.ClientExist(w.Id) == true) { DialogResult dialogResult = MessageBox.Show("Are You Sure To Delete Client?", "Delete", MessageBoxButtons.YesNoCancel); if (dialogResult == DialogResult.Yes) { db.DeleteClient(w); MessageBox.Show("Delete Client"); } } else { MessageBox.Show("Client with similar ID wat not found , try again", "Error"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }
private void button3_Click(object sender, EventArgs e) { WindowsFormsApplication1.Client w = new WindowsFormsApplication1.Client(); DbClients db = new DbClients(); DataSet ds = new DataSet(); try { w.Id = int.Parse(textBox1.Text); if (db.ClientExist(w.Id) == true) { ds = db.GetClientInfo(w); textBox1.Text = ds.Tables[0].Rows[0]["ClientId"].ToString(); textBox3.Text = ds.Tables[0].Rows[0]["FirstName"].ToString(); textBox2.Text = ds.Tables[0].Rows[0]["LastName"].ToString(); textBox4.Text = ds.Tables[0].Rows[0]["Address"].ToString(); textBox5.Text = ds.Tables[0].Rows[0]["Phone"].ToString(); } else { textBox1.Text = "Client not found "; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { DbClients db = new DbClients(); try { if (comboBox1.SelectedIndex == 0) { WindowsFormsApplication1.Client w = new WindowsFormsApplication1.Client(); w.Id = int.Parse(textBox1.Text); if (db.ClientExist(w.Id) == true) { dataGridView1.DataSource = db.SearchClientbyId(w.Id).Tables[0]; } } else { dataGridView1.DataSource = db.SearchClientbyName(textBox3.Text).Tables[0]; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }
private void button1_Click(object sender, EventArgs e) { WindowsFormsApplication1.Client w = new WindowsFormsApplication1.Client(); DbClients db = new DbClients(); w.Id = int.Parse(textBox1.Text); w.FirstName = textBox3.Text; w.LastName = textBox2.Text; w.Address = textBox4.Text; w.Phone = textBox5.Text; db.UpdateClient(w); MessageBox.Show("Successfully updated client"); }