Example #1
0
        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.. ");
                }
            }
        }
Example #2
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_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("لا يمكنك اتمام عملية الحذف ");
            }
        }
Example #3
0
        //edit
        private void btn_edit_Click(object sender, EventArgs e)
        {
            FRM_USERS_ADD frm_add = new FRM_USERS_ADD();

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

            frm_add.txt_username.Text = tb_user.User_Name;
            frm_add.txt_pass.Text     = tb_user.User_Password;
            frm_add.txt_rol.Text      = tb_user.User_Rol;

            frm_add.id           = id;
            frm_add.btn_add.Text = "تعديل";
            frm_add.Show();
        }
Example #4
0
        private void btn_logout_Click_1(object sender, EventArgs e)
        {
            FRM_LOGIN login = new FRM_LOGIN();


            tb_user = db.TB_Users.Where(x => x.User_State == "True").FirstOrDefault();

            tb_user.User_State      = "Fales";
            db.Entry(tb_user).State = System.Data.Entity.EntityState.Modified;

            db.SaveChanges();

            this.Enabled = false;
            login.Show();
            this.Hide();
        }
Example #5
0
 private void timer1_Tick_1(object sender, EventArgs e)
 {
     tb_user = db.TB_Users.Where(x => x.User_State == "True").FirstOrDefault();
     if (tb_user != null)
     {
         main.label_username.Text = tb_user.User_Name;
         main.label_rol.Text      = tb_user.User_Rol;
         main.Show();
     }
     else
     {
         login.Show();
     }
     this.Hide();
     timer1.Enabled = false;
 }