private void Loginbtn_Click(object sender, EventArgs e)
        {
            if (EmailInput.Text == "Admin" && PasswordInput.Text == "123")
            {
                busobj.busname   = "Ajanata Travels";
                busobj.departure = "12:20";
                busobj.fare      = 1200;
                busobj.seatcount = 20;
                busobj.from      = "Indore";
                busobj.to        = "Bangalore";
                busobj.sendbus_details(Resources.Resource1.FilePathBus, busobj);
                MessageBox.Show("Admin");
                return;
            }
            BLL obj1 = new BLL();
            gl  cat  = obj1.get_details(obj1, Resources.Resource1.FilePathData);

            // MessageBox.Show(Convert.ToString(cat.Count));
            string pass = "";

            for (int i = 0; i < cat.temp.Count; i++)
            {
                if (cat.temp[i].Email == EmailInput.Text)
                {
                    pass = cat.temp[i].Password;
                }
            }
            if (pass == PasswordInput.Text && pass != "")
            {
                DashBoard db = new DashBoard();
                this.Hide();
                this.Parent.Controls.Add(db);
            }
            else
            {
                Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
                Match match = regex.Match(EmailInput.Text);
                if (!(match.Success))
                {
                    errorProvider1.SetError(EmailInput, "Invalid Email");
                }

                else
                {
                    errorProvider1.SetError(EmailInput, "");
                }
                if (String.IsNullOrEmpty(PasswordInput.Text))
                {
                    errorProvider2.SetError(PasswordInput, "Enter Password ");
                }

                else
                {
                    errorProvider2.SetError(PasswordInput, "");
                }
            }
        }
Exemple #2
0
        public void FinalPay_Click(object sender, EventArgs e)
        {
            if (f == 1)
            {
                obj.Customername = NameINput.Text;
                obj.BusName      = busname;
                obj.From         = from;
                obj.to           = to;
                obj.number       = Contactinput.Text;
                obj.Date         = my_date;
                obj.fare         = sendfare;
                obj.dep          = depa;
                obj.seat         = Convert.ToInt32(Passcountinput.Text);
                obj.sendcontact_details(Resources.Resource1.FilePathTickets, obj);

                DashBoard ud = new DashBoard();
                this.Hide();
                this.Parent.Controls.Add(ud);
            }
            else
            {
                if (String.IsNullOrEmpty(Passcountinput.Text))
                {
                    errorProvider1.SetError(Passcountinput, "Name Field Can't Be Empty");
                }
                else if (Convert.ToInt32(Passcountinput.Text) - seats < 0)
                {
                    errorProvider1.SetError(Passcountinput, "Only" + seats + "Available");
                }
                else
                {
                    errorProvider1.SetError(Passcountinput, "");
                    errorProvider1.Clear();
                }

                int num = 1;
                if (String.IsNullOrEmpty(Ageinput.Text) || (!int.TryParse(Ageinput.Text, out num)))
                {
                    errorProvider2.SetError(Ageinput, "Invalid Age");
                }
                else
                {
                    errorProvider2.SetError(Ageinput, "");
                }
                if (!(Regex.Match(Contactinput.Text, @"^[0-9]{10}").Success))
                {
                    errorProvider5.SetError(Contactinput, "Contact Invalid");
                }
                else
                {
                    errorProvider5.SetError(Contactinput, "");
                    errorProvider5.Clear();
                }

                Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
                Match match = regex.Match(Emailinput.Text);
                if (!(match.Success))
                {
                    errorProvider4.SetError(Emailinput, "Email Invalid");
                }
                else
                {
                    errorProvider4.SetError(Emailinput, "");
                    errorProvider4.Clear();
                }
                if (String.IsNullOrEmpty(NameINput.Text))
                {
                    errorProvider3.SetError(NameINput, "Field Can't Be Empty");
                }
                else
                {
                    errorProvider3.SetError(NameINput, "");
                    errorProvider3.Clear();
                }
            }
        }