Exemplo n.º 1
0
        public void LoadData()
        {
            MDI m1 = new MDI();

            // this.Size = m1.Size;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            id = Master.getme;
            if (id == 0)
            {
                id = 1;
            }
            con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=Bus_System;Integrated Security=True");
            con.Open();
            cmd = new SqlCommand("Select Fullname From Newuser where ID='" + id + "'", con);
            dr  = cmd.ExecuteReader();
            dr.Read();
            Label2.Text = Convert.ToString(dr.GetValue(0));
            dr.Close();
            Route.Text        = Master.AddCount("Rno", "Route");
            Bus.Text          = Master.AddCount("BusSno", "Bus");
            Passenger.Text    = Master.AddCount("Pno", "Passenger");
            Driver.Text       = Master.AddCount("Did", "Driver");
            Staff.Text        = Master.AddCount("Sid", "Staff");
            Office.Text       = Master.AddCount("Oid", "Office");
            Current.Text      = Master.AddCount("BookingNo", "PaymentPassenger");
            Cancellation.Text = Master.AddCount("BookingNo", "Cancellation");
            Completed.Text    = Master.AddCount("BookingNo", "CompletedPP");
            Advance.Text      = Master.AddCount("BookingNo", "APaymentPassenger", "WaitingNo", "0");
            Waiting.Text      = Master.AddCount("BookingNo", "APaymentPassenger", "Not WaitingNo", "0");
        }
Exemplo n.º 2
0
        private void btnLogin_Click_1(System.Object sender, System.EventArgs e)
        {
            //Connection
            SqlConnection con = new SqlConnection();

            con.ConnectionString = "Data Source=.\\SQLEXPRESS;Initial Catalog=Bus_System;Integrated Security=True";
            con.Open();

            //command
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = con;
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select username,password from Newuser where username='******' and password='******'";

            //data reader
            SqlDataReader dr = null;

            dr = cmd.ExecuteReader();
            dr.Read();

            if (string.IsNullOrEmpty(txtusername.Text) & string.IsNullOrEmpty(txtpassword.Text))
            {
                MessageBox.Show("Plz Enter Username and Password.. Press OK");
                txtpassword.Clear();
                txtusername.Clear();
                txtusername.Focus();
            }
            else if (dr.HasRows)
            {
                dr.Close();
                cmd = new SqlCommand("select ID from Newuser where username='******' and password='******'", con);
                dr  = cmd.ExecuteReader();
                dr.Read();
                a = Convert.ToInt32(dr.GetValue(0));
                dr.Close();
                Master.LI(a);
                MessageBox.Show("You Are Connecting To Bus Reservation System... Press OK");
                this.Hide();
                MDI m1 = new MDI();
                m1.Show();
            }
            else
            {
                MessageBox.Show("Wrong User.. Plz Enter Valid Username and Password Again.. Press OK");
                txtpassword.Clear();
                txtusername.Clear();
                txtusername.Focus();
            }
            dr.Close();
            con.Close();
        }