示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            DangNhapWeb DNW;

            DNW = new DangNhapWeb();
            string s = textBox1.Text;
            string a = textBox2.Text;

            textBox1.Text = DNW.ChuanHoa(s);
            textBox2.Text = DNW.ChuanHoa(a);

            KiemTraDangKy Kiemtra = new KiemTraDangKy();
            DangNhapWeb   KT1     = new DangNhapWeb();
            bool          KT      = Kiemtra.KiemTraDangKi(textBox1.Text, textBox2.Text);
            int           KQ      = KT1.KiemTraTK(textBox1.Text);

            if (textBox1.Text != "" && textBox2.Text != "" && KT == true && SDT.Text != "" && Email.Text != "" && DiaChi.Text != "" && HoTen.Text != "" && KQ == 0 && SDT.Text.Length == 10)
            {
                DangKy   Dk = new DangKy();
                DangNhap DN;
                DN           = new DangNhap();
                DN.DangNhap1 = textBox1.Text;
                DN.MatKhau   = textBox2.Text;
                Dk.ThemKH(HoTen.Text, DiaChi.Text, NgaySinh.Value.Date, Email.Text, SDT.Text);
                DN.MaKhachHang = TT.LayMaKH(HoTen.Text, SDT.Text);
                Dk.DangKyTK(DN);
                MessageBox.Show(" Dang Ky Thanh Cong");
                this.Hide();
                Form1 f = new Form1();
                f.ShowDialog();
                this.Close();
            }
            else if (SDT.Text == "" | Email.Text == "" | DiaChi.Text == "" | HoTen.Text == "" | textBox1.Text == "" | textBox2.Text == "")
            {
                MessageBox.Show(" Vui long dien vao tat ca thong tin");
            }
            else if (SDT.Text.Length < 10 | SDT.Text.Length > 10)
            {
                MessageBox.Show("SDT phai la 10 so");
            }

            else if (KT == false)
            {
                MessageBox.Show(" Mat Khau khong hop le phai co 1 chu hoa va 1 chu thuong va 1 chu so va co 8 ki tu tro len ");
            }
            else if (KQ == 1)
            {
                MessageBox.Show(" ten TK bi trung moi nhap Ten TK khac");
            }
        }
示例#2
0
        private void BtThanhToan_Click(object sender, EventArgs e)
        {
            if (txtHoTen.Text == "" || TXTdiachi.Text == "" || TXTEmail.Text == "" || TXTSDT.Text == "" || cbQuanHuyen.Text == "" || cbTinhThanh.Text == "")
            {
                MessageBox.Show("Xin vui long dien tat ca thong tin ");
            }
            if (TXTSDT.Text.Length != 10)
            {
                MessageBox.Show("SĐT phải 1 số");
            }
            else
            {
                int a = TT.TimKH(txtHoTen.Text, TXTSDT.Text);
                if (a == 0)
                {
                    Random ra   = new Random();
                    string KiTu = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                    string random;
                    int    c = ra.Next(0, KiTu.Length); //string.Lenght gets the size of string
                    random = KiTu.ElementAt(c).ToString();
                    Random rd      = new Random();
                    int    MaRadom = rd.Next(1000000, 9999999);
                    String MaDH    = random + MaRadom;
                    int    kq      = TT.TimMaDH(MaDH);
                    while (kq == 1)
                    {
                        c       = ra.Next(0, KiTu.Length);
                        random  = KiTu.ElementAt(c).ToString();
                        MaRadom = rd.Next(1000000, 9999999);
                        MaDH    = random + MaRadom;
                        kq      = TT.TimMaDH(MaDH);
                    }
                    DangKy DK = new DangKy();
                    DK.ThemKH(txtHoTen.Text, TXTdiachi.Text, TXTEmail.Text, TXTSDT.Text);
                    int MaKh = TT.LayMaKH(txtHoTen.Text, TXTSDT.Text);
                    TT.ThemDH(MaKh, MaDH, int.Parse(lbThanhTien.Text), dataGridView1, TXTdiachi.Text, cbTinhThanh.Text, cbQuanHuyen.Text);
                    MessageBox.Show("Thanh Toan Thanh Cong" + "Mã Đơn Hàng Của Bạn Là : " + MaDH);
                    Menu MN = new Menu();
                    MN.ShowDialog();
                    this.Close();
                }
                else
                {
                    Random ra   = new Random();
                    string KiTu = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                    string random;
                    int    c = ra.Next(0, KiTu.Length); //string.Lenght gets the size of string
                    random = KiTu.ElementAt(c).ToString();

                    Random rd      = new Random();
                    int    MaRadom = rd.Next(1000000, 9999999);
                    String MaDH    = random + MaRadom;
                    int    kq      = TT.TimMaDH(MaDH);
                    while (kq == 1)
                    {
                        c       = ra.Next(0, KiTu.Length);
                        random  = KiTu.ElementAt(c).ToString();
                        MaRadom = rd.Next(1000000, 9999999);
                        MaDH    = random + MaRadom;
                        kq      = TT.TimMaDH(MaDH);
                    }
                    int MaKh = TT.LayMaKH(txtHoTen.Text, TXTSDT.Text);
                    TT.ThemDH(MaKh, MaDH, int.Parse(lbThanhTien.Text), dataGridView1, TXTdiachi.Text, cbTinhThanh.Text, cbQuanHuyen.Text);
                    MessageBox.Show("Thanh Toán Thành Công" + "Mã Đơn Hàng Của Bạn Là : " + MaDH);
                    Menu MN = new Menu();
                    MN.ShowDialog();
                    this.Close();
                }
            }
        }