Exemplo n.º 1
0
        private void linkLabel1_Click(object sender, EventArgs e)
        {
            FormLogIn form2 = new FormLogIn();

            form2.ShowDialog();
            this.Close();
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            string        source = conSet.ConnectionString;
            SqlConnection cn     = new SqlConnection(source);

            while (true)
            {
                if (txtMatKhau.Text != txtNhapLai.Text)
                {
                    errorNhapSai.SetError(txtNhapLai, "Mật khẩu nhập lại không trùng khớp");
                    break;
                }
                cn.Open();
                string     qry = "UPDATE dbo.DangNhap SET matKhau = '" + txtNhapLai.Text + "' WHERE email = '" + email + "'";
                SqlCommand cmd = new SqlCommand(qry, cn);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Đổi mật khẩu thành công");
                cn.Close();
                this.Close();
                FormLogIn fli = new FormLogIn();
                fli.ShowDialog();
                break;
            }
        }
Exemplo n.º 3
0
        // Them thong tin cac o Text vao bang SQL
        private void btnSignUp_Click(object sender, EventArgs e)
        {
            string        source = conSet.ConnectionString;
            SqlConnection cn     = new SqlConnection(source);

            cn.Open();
            while (true)
            {
                if (txtDangNhap.Text == "Tên Đăng Nhập" || txtMatKhau.Text == "Mật Khẩu" || txtHoVaTen.Text == "Họ Và Tên" || cbxChucVu.Text == "Chức Vụ")
                {
                    MessageBox.Show("Điền đầy đủ những mục có dấu *");
                    break;
                }

                int dem_TenDangNhap = 0;



                #region Kiểm tra trùng email
                SqlCommand    cmd_CheckTenDangNhap = new SqlCommand("select * from DangNhap where email = '" + txtDangNhap.Text + "'", cn);
                SqlDataReader dr_CheckTenDangNhap;
                dr_CheckTenDangNhap = cmd_CheckTenDangNhap.ExecuteReader();
                while (dr_CheckTenDangNhap.Read())
                {
                    dem_TenDangNhap += 1;
                }
                if (dem_TenDangNhap >= 1)
                {
                    MessageBox.Show("Email đã được đăng kí");
                    cn.Close();
                    break;
                }
                dr_CheckTenDangNhap.Close();
                #endregion

                // Nếu k trùng email
                if (dem_TenDangNhap < 1)
                {
                    String     qry_1 = "insert into DangNhap (email,matKhau) values ('" + txtDangNhap.Text + "','" + txtMatKhau.Text + "')";
                    SqlCommand cmd_1 = new SqlCommand(qry_1, cn);
                    cmd_1.ExecuteNonQuery();

                    string[] maCV = cbxChucVu.Text.Split(new char[] { ' ' });

                    string   ngaySinh_Temp = dtNgaySinh.Value.ToShortDateString();
                    string[] nSinh         = ngaySinh_Temp.Split(new char[] { '/' });
                    string   namSinh       = string.Concat(nSinh[2], "-", nSinh[0]);
                    string   ngaySinh      = string.Concat(namSinh, "-", nSinh[1]);

                    string   ngayVaoLam_Temp = dtNgayVaoLam.Value.ToShortDateString();
                    string[] nVaoLam         = ngayVaoLam_Temp.Split(new char[] { '/' });
                    string   namVaoLam       = string.Concat(nVaoLam[2], "-", nVaoLam[0]);
                    string   ngayVaoLam      = string.Concat(namVaoLam, "-", nVaoLam[1]);

                    String qry_2 = "insert into dbo.NhanVien( MaNV ,HoTen ,Email ,NgaySinh ,QueQuan ,NgayVaoLam ,GioiTinh ,SDT ,MaChucVu) " +
                                   "VALUES  ('" + maNV + "',N'" + txtHoVaTen.Text + "','" + txtDangNhap.Text + "','" + ngaySinh + "', N'" + txtQueQuan.Text + "' ,'" + ngayVaoLam + "',N'" + cbxGioiTinh.Text + "','" + txtSDT.Text + "','" + maCV[0] + "')";
                    SqlCommand cmd_2 = new SqlCommand(qry_2, cn);
                    cmd_2.ExecuteNonQuery();

                    String     qry_3 = "INSERT INTO dbo.ThanhTich( maNV, soKH ) VALUES  ( '" + maNV + "', 0  )";
                    SqlCommand cmd_3 = new SqlCommand(qry_3, cn);
                    cmd_3.ExecuteNonQuery();
                    MessageBox.Show("Đăng kí thành công");
                    cn.Close();
                    this.Close();
                    FormLogIn fli = new FormLogIn();
                    fli.ShowDialog();
                    break;
                }
            }
        }