//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_user = db.TB_Users.Where(x => x.ID == id).FirstOrDefault(); db.Entry(tb_user).State = EntityState.Deleted; db.SaveChanges(); toast.labl_caption.Text = "تم حذف مستخدم"; toast.Show(); this.Close(); //renew tale update_data(); } } catch { MessageBox.Show("لا يمكنك اتمام عملية الحذف "); } }
private void btn_add_Click(object sender, EventArgs e) { Toast toast = new Toast(); //check if (txt_username.Text == "" || txt_pass.Text == "") { toast.labl_caption.Text = "يجيب ان تدخل البيانات المطلوبة"; toast.Show(); } else { //Login tb_user = db.TB_Users.Where(x => x.User_Name == txt_username.Text && x.User_Password == txt_pass.Text).FirstOrDefault(); if (tb_user != null) { tb_user.User_State = "True"; db.Entry(tb_user).State = System.Data.Entity.EntityState.Modified; main.label_username.Text = tb_user.User_Name; main.label_rol.Text = tb_user.User_Rol; main.Enabled = true; db.SaveChanges(); main.Show(); this.Close(); } else { MessageBox.Show("your username or your password not correct.. "); } } }
private void btn_add_Click(object sender, EventArgs e) { Toast toast = new Toast(); //check if (txt_username.Text == "" || txt_pass.Text == "") { toast.labl_caption.Text = "يجيب ان تدخل البيانات المطلوبة"; toast.Show(); } else { if (id == 0) { //add tb_user.User_Name = txt_username.Text; tb_user.User_Password = txt_pass.Text; tb_user.User_Rol = txt_rol.Text; tb_user.User_State = "false"; db.TB_Users.Add(tb_user); db.SaveChanges(); toast.labl_caption.Text = "تم اضافة مستخدم جديد"; toast.Show(); this.Close(); } else { //edit tb_user.ID = id; tb_user.User_Name = txt_username.Text; tb_user.User_Password = txt_pass.Text; tb_user.User_Rol = txt_rol.Text; tb_user.User_State = "false"; db.Entry(tb_user).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); toast.labl_caption.Text = "تم تعديل المستخدم"; toast.Show(); this.Close(); } } }