Ejemplo n.º 1
0
        private void btnluu_Click(object sender, EventArgs e)
        {
            string matkhaucu = dataMatKhau.layMatKhau();
            if (txtmatkhaucu.Text != matkhaucu)
            {
                MessageBox.Show("Sai mật khẩu cũ!");
                return;
            }

            if (txtmkmoi.Text != txtmkmoi2.Text)
            {
                MessageBox.Show("Mật khẩu mới không khớp nhau!");
                return;
            }

            MATKHAU mkcu = new MATKHAU();
            mkcu.matkhau1 = txtmatkhaucu.Text;

            MATKHAU mkmoi = new MATKHAU();
            mkmoi.matkhau1 = txtmatkhaucu.Text;
            mkmoi = dataMatKhau.tim(mkmoi);
            mkmoi.matkhau1 = txtmkmoi.Text;

            dataMatKhau.suaMatKhau(mkcu, mkmoi);
            MessageBox.Show("Đã luu!");
            Close();
        }
Ejemplo n.º 2
0
 public void suaMatKhau(MATKHAU bef, MATKHAU aft)
 {
     SqlCommand sql = new SqlCommand();
     sql.CommandText = "update MATKHAU set matkhau = @mk, candangnhap = @tt where matkhau = @mk1";
     sql.CommandType = CommandType.Text;
     sql.Parameters.AddWithValue("@mk", aft.matkhau1);
     sql.Parameters.AddWithValue("@tt", aft.candangnhap);
     sql.Parameters.AddWithValue("mk1", bef.matkhau1);
     sql.Connection = DataProvider.con;
     sql.ExecuteNonQuery();
 }
Ejemplo n.º 3
0
 public MATKHAU tim(MATKHAU inf)
 {
     return data.tim(inf);
 }
Ejemplo n.º 4
0
 public void suaMatKhau(MATKHAU bef, MATKHAU aft)
 {
     data.suaMatKhau(bef, aft);
 }
Ejemplo n.º 5
0
 public MATKHAU tim(MATKHAU inf)
 {
     return data.MATKHAUs.Find(inf.matkhau1);
 }
Ejemplo n.º 6
0
        private void btnsua_Click(object sender, EventArgs e)
        {
            try
            {
                int x = Convert.ToInt32(txthandungthe.Text);
                int y = Convert.ToInt32(txtsolantrehen.Text);
                int z = Convert.ToInt32(txtsongaykhoathe.Text);
                int t = Convert.ToInt32(txtsongaymuon.Text);
                int w = Convert.ToInt32(txtsosachmuon.Text);

                THAMSO songaymuon = new THAMSO();
                songaymuon.tenthamso = "songaymuon";
                songaymuon = data.timThamSo(songaymuon);
                songaymuon.giatri = txtsongaymuon.Text;
                data.suaThamSo(songaymuon);

                THAMSO handungthe = new THAMSO();
                handungthe.tenthamso = "handungthe";
                handungthe = data.timThamSo(handungthe);
                handungthe.giatri = txthandungthe.Text;
                data.suaThamSo(handungthe);

                THAMSO solantrehen = new THAMSO();
                solantrehen.tenthamso = "solantrehen";
                solantrehen = data.timThamSo(solantrehen);
                if (cbsolantrehen.Checked == true)
                {
                    solantrehen.tinhtrang = true;
                    solantrehen.giatri = txtsolantrehen.Text;
                }
                else
                {
                    solantrehen.giatri = txtsolantrehen.Text;
                    solantrehen.tinhtrang = false;
                }
                data.suaThamSo(solantrehen);

                THAMSO songaykhoathe = new THAMSO();
                songaykhoathe.tenthamso = "songaykhoathe";
                songaykhoathe = data.timThamSo(songaykhoathe);
                if (cbsolantrehen.Checked == true)
                {
                    songaykhoathe.tinhtrang = true;
                    songaykhoathe.giatri = txtsongaykhoathe.Text;
                }
                else
                {
                    songaykhoathe.giatri = txtsolantrehen.Text;
                    songaykhoathe.tinhtrang = false;
                }
                data.suaThamSo(songaykhoathe);

                THAMSO sosachmuon = new THAMSO();
                sosachmuon.tenthamso = "sosachmuon";
                sosachmuon = data.timThamSo(sosachmuon);
                if (cbsosachmuon.Checked == true)
                {
                    sosachmuon.giatri = txtsosachmuon.Text;
                }
                else
                {
                    sosachmuon.giatri = txtsosachmuon.Text;
                    sosachmuon.tinhtrang = false;
                }
                data.suaThamSo(sosachmuon);

                string matkhau = dataMatKhau.layMatKhau();
                MATKHAU mkcu = new MATKHAU();
                mkcu.matkhau1 = matkhau;
                mkcu = dataMatKhau.tim(mkcu);

                MATKHAU mkmoi = new MATKHAU();
                mkmoi.matkhau1 = matkhau;
                if (cbcandangnhap.Checked == true)
                    mkmoi.candangnhap = true;
                else
                    mkmoi.candangnhap = false;
                dataMatKhau.suaMatKhau(mkcu, mkmoi);

                MessageBox.Show("Đã lưu!");
                Close();
                noticeUpdateThamSo();
            }
            catch (FormatException)
            {
                MessageBox.Show("Chỉnh sửa không hợp lệ!");
            }
        }