Пример #1
0
        //delete

        private void btn_delete_Click(object sender, EventArgs e)
        {
            Toast toast = new Toast();

            try
            {
                id = Convert.ToInt32(gridView1.GetFocusedRowCellValue("ID"));
                var res = MessageBox.Show("هل انت متاكد من عملية الحذف", "حذف", MessageBoxButtons.YesNo);
                if (res == DialogResult.Yes)
                {
                    tb_sup = db.TB_SUP.Where(x => x.ID == id).FirstOrDefault();
                    db.Entry(tb_sup).State = EntityState.Deleted;
                    db.SaveChanges();
                    toast.labl_caption.Text = "تم حذف المورد بنجاح";
                    toast.Show();
                    this.Close();
                    //renew tale
                    update_data();
                }
            }
            catch
            {
                MessageBox.Show("يجب تحديد مورد للحذف");
            }
        }
Пример #2
0
        //edit
        private void btn_edit_Click(object sender, EventArgs e)
        {
            FRM_SUP_ADD frm_add = new FRM_SUP_ADD();

            id     = Convert.ToInt32(gridView1.GetFocusedRowCellValue("ID"));
            tb_sup = db.TB_SUP.Where(x => x.ID == id).FirstOrDefault();

            frm_add.txt_name.Text         = tb_sup.Sup_Name.ToString();
            frm_add.txt_phone.Text        = tb_sup.Sup_Phone.ToString();
            frm_add.dateTimePicker1.Value = tb_sup.Sup_Start_Date.Value;

            frm_add.id           = id;
            frm_add.btn_add.Text = "تعديل";
            frm_add.Show();
        }