Exemplo n.º 1
0
        private void barButtonItem3_ItemClick(object sender, ItemClickEventArgs e)
        {
            QLTK themca = new QLTK();

            themca.Show();
            this.Hide();
        }
Exemplo n.º 2
0
        private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
        {
            DialogResult r;

            r = MessageBox.Show("Bạn có muốn lưu?", "Lưu thông tin", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (r == DialogResult.Yes)
            {
                string pass   = txtpass.Text.Trim();
                string repass = txtrepass.Text.Trim();
                if (pass == "")
                {
                    MessageBox.Show("Không được để trống mật khẩu");
                }
                else if (repass == "")
                {
                    MessageBox.Show("Không được để trống xác nhận mật khẩu");
                }
                else if (pass != repass)
                {
                    MessageBox.Show("Xác nhận mật khẩu không trùng khớp");
                }
                else
                {
                    MySqlConnection conn = getDB.getData();
                    conn.Open();
                    try
                    {
                        string       sql = "update taikhoan set MK = '" + pass + "' where TK = '" + tendn + "'";
                        MySqlCommand cmd = new MySqlCommand(sql, conn);
                        if (cmd.ExecuteNonQuery() == 1)
                        {
                            MessageBox.Show("Thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Fails", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Lỗi", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        conn.Close();
                        conn.Dispose();
                        QLTK themca = new QLTK();
                        themca.Show();
                        this.Hide();
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void bbiNew_ItemClick(object sender, ItemClickEventArgs e)
        {
            string tendn = txttk.Text.Trim();
            string mk    = txtpass.Text.Trim();
            string xnmk  = txtxn.Text.Trim();
            int    manv  = int.Parse(cbtennv.SelectedValue.ToString());
            string macv  = "NVPV";
            int    makh  = 0;
            string img   = "user.png";

            DialogResult r;

            r = MessageBox.Show("Bạn có muốn lưu?", "Lưu thông tin", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (r == DialogResult.Yes)
            {
                if (tendn == "")
                {
                    MessageBox.Show("Không được để trống tên đăng nhập");
                }
                else if (mk == "")
                {
                    MessageBox.Show("Không được để trống mật khẩu");
                }
                else if (xnmk == "")
                {
                    MessageBox.Show("Không được để trống xác nhận mật khẩu");
                }
                else if (xnmk != mk)
                {
                    MessageBox.Show("Xác nhận mật khẩu không trùng khớp");
                }
                else
                {
                    MySqlConnection conn = getDB.getData();
                    conn.Open();
                    try
                    {
                        string       sql = "insert into taikhoan(TK,MK,MaCV,MaNV,MaKH,IMG) values ('" + tendn + "','" + mk + "','" + macv + "','" + manv + "','" + makh + "','" + img + "')";
                        MySqlCommand cmd = new MySqlCommand(sql, conn);
                        if (cmd.ExecuteNonQuery() == 1)
                        {
                            MessageBox.Show("Thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Fails", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Lỗi", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        conn.Close();
                        conn.Dispose();
                        QLTK themca = new QLTK();
                        themca.Show();
                        this.Hide();
                    }
                }
            }
        }