private void btnAdd_Click(object sender, EventArgs e) { try { byte[] Picture; if (pbox.Image == null) { Picture = new byte[0]; cust.ADD_CUSTOMER(txtFirstName.Text, txtLastName.Text, txtTel.Text, txtEmail.Text, Picture, "without_image", CustName.Text, CustPass.Text); MessageBox.Show("تمت الإضافة بنجاح", "الإضافة", MessageBoxButtons.OK, MessageBoxIcon.Information); this.dgList.DataSource = cust.GET_ALL_CUSTOMERS(); CustName.ReadOnly = true; CustPass.ReadOnly = true; txtTel.ReadOnly = true; txtEmail.ReadOnly = true; txtFirstName.ReadOnly = true; txtLastName.ReadOnly = true; CustName.Clear(); CustPass.Clear(); txtFirstName.Clear(); txtLastName.Clear(); txtTel.Clear(); txtEmail.Clear(); } else { MemoryStream ms = new MemoryStream(); pbox.Image.Save(ms, pbox.Image.RawFormat); Picture = ms.ToArray(); cust.ADD_CUSTOMER(txtFirstName.Text, txtLastName.Text, txtTel.Text, txtEmail.Text, Picture, "with_image", CustName.Text, CustPass.Text); MessageBox.Show("تمت الإضافة بنجاح", "الإضافة", MessageBoxButtons.OK, MessageBoxIcon.Information); this.dgList.DataSource = cust.GET_ALL_CUSTOMERS(); CustName.ReadOnly = true; CustPass.ReadOnly = true; txtTel.ReadOnly = true; txtEmail.ReadOnly = true; txtFirstName.ReadOnly = true; txtLastName.ReadOnly = true; CustName.Clear(); CustPass.Clear(); txtFirstName.Clear(); txtLastName.Clear(); txtTel.Clear(); txtEmail.Clear(); } } catch { return; } finally { btnAdd.Enabled = false; btnNew.Enabled = true; btnEdit.Enabled = true; btnDelete.Enabled = true; button1.Enabled = true; } }
private void btnDelete_Click(object sender, EventArgs e) { if (ID == 0) { MessageBox.Show("يرجئ تحديد العميل"); return; } if (MessageBox.Show("هل تريد حذف هذا العميل؟", "الحذف", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { cust.DELETE_CUSTOMER(ID); MessageBox.Show("تم الحذف بنجاح", "الحذف", MessageBoxButtons.OK, MessageBoxIcon.Information); CustName.Clear(); CustPass.Clear(); txtTel.Clear(); txtEmail.Clear(); pbox.Image = null; txtFirstName.Clear(); txtLastName.Clear(); this.dgList.DataSource = cust.GET_ALL_CUSTOMERS(); } }
private void btnNew_Click(object sender, EventArgs e) { CustName.Clear(); CustPass.Clear(); txtFirstName.Clear(); txtLastName.Clear(); txtTel.Clear(); txtEmail.Clear(); CustName.Focus(); btnAdd.Enabled = true; btnNew.Enabled = false; btnEdit.Enabled = false; btnDelete.Enabled = false; button1.Enabled = false; txtFirstName.ReadOnly = false; txtLastName.ReadOnly = false; txtTel.ReadOnly = false; txtEmail.ReadOnly = false; CustName.ReadOnly = false; CustPass.ReadOnly = false; }