private void save_Click(object sender, EventArgs e) { string name = name_txt.Text; string type = type_combo.SelectedItem.ToString(); string email = email_txt.Text; if (name != "" && type != "") { if (cases == 1) { string insert_query = "INSERT INTO customer (cust_name,cust_type,cust_email) VALUES('" + name + "','" + type + "','" + email + "')"; if (db.insertDB(insert_query)) { int id = db.SelectID("SELECT cust_id FROM customer WHERE cust_name='" + name + "'"); for (int i = 0; i < phone_list.Items.Count; i++) { string p = phone_list.Items[i].Text; string query = "INSERT INTO phones VALUES('" + p + "'," + id + ")"; if (db.insertDB(query)) { } } MessageBox.Show("تم اضافه الزبون"); this.Close(); form.RefreshCust(form.cust_query); } } else if (cases == 2) { string update_query = "UPDATE customer SET cust_name='" + name + "',cust_type='" + type + "',cust_email='" + email + "' WHERE cust_id=" + id; if (db.updateDB(update_query)) { db.deleteDB("DELETE FROM phones WHERE cust_id=" + id); for (int i = 0; i < phone_list.Items.Count; i++) { string p = phone_list.Items[i].Text; string query = "INSERT INTO phones VALUES('" + p + "'," + id + ")"; if (db.insertDB(query)) { } } MessageBox.Show("تم تعديل معلومات الزبون الزبون"); this.Close(); form.RefreshCust(form.cust_query); } } } else { MessageBox.Show("ادخل معلومات صحيحه"); } }
private void del_teeth_Click(object sender, EventArgs e) { if (teeth_gridview.SelectedCells.Count > 0) { string type = teeth_gridview.Rows[teeth_gridview.SelectedCells[0].RowIndex].Cells[0].Value.ToString(); if (db.deleteDB("DELETE from teeth_type WHERE type='" + type + "'")) { RefreshTeeth(); } } }