private void btn_delete_Click(object sender, EventArgs e) { Toast toast = new Toast(); Dialog dialog = new Dialog(); id = Convert.ToInt32(tileView1.GetFocusedRowCellValue("ID")); if (id > 0) { try { var rs = MessageBox.Show("عملية حذف", "هل انت متاكد من هذه العملية", MessageBoxButtons.YesNo); if (rs == DialogResult.Yes) { tb_sup = db.TB_SUP.Where(x => x.ID == id).FirstOrDefault(); db.Entry(tb_sup).State = EntityState.Deleted; db.SaveChanges(); toast.txt_caption.Text = "تم حذف المورد"; toast.Show(); update_data(); } } catch { } } else { dialog.txt_caption.Text = "لا يوجد مورد لحذفه"; dialog.Width = this.Width; dialog.Show(); } }
//edit private void btn_edit_Click(object sender, EventArgs e) { PL.FRM_SUP_ADD frm_add = new FRM_SUP_ADD(); id = Convert.ToInt32(tileView1.GetFocusedRowCellValue("ID")); tb_sup = db.TB_SUP.Where(x => x.ID == id).FirstOrDefault(); frm_add.edt_name.Text = tb_sup.Sup_Name.ToString(); frm_add.edt_phone.Text = tb_sup.Sup_Phone.ToString(); frm_add.edt_email.Text = tb_sup.Sup_Email.ToString(); methods.by = tb_sup.Sup_image; frm_add.pic_cover.Image = Image.FromStream(methods.convert_image()); frm_add.id = id; frm_add.btn_add.Text = "تعديل"; frm_add.Show(); }