示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            DBTools       db = new DBTools(".", "wkdl", true, "sa", "wdxg");
            SqlDataReader b  = db.getResult("Select * from userlogin where uname='" + textBox1.Text.Trim() + "'and uPassword='******'");

            try
            {
                if (b.Read())
                {
                    db.Disconnect();

                    DBTools       dc = new DBTools(".", "wkdl", true, "sa", "wdxg");
                    SqlDataReader bb = db.getResult("Select * from userlogin where uname='" + textBox1.Text.Trim() + "'and usa='admin'");

                    DLname c = DLname.getInstance();
                    c.Str = textBox1.Text;

                    if (bb.Read())
                    {
                        dc.Disconnect();
                        MessageBox.Show("Hello administrator.", "Hello", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MainForm mfa = new MainForm();
                        mfa.Text = "Administrator System";
                        mfa.Show();
                    }
                    else
                    {
                        dc.Disconnect();
                        MessageBox.Show("Hello VIP member", "Hello", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MainForm mfb = new MainForm();
                        mfb.Text = "Member System";
                        mfb.Show();
                    }
                    dc.Disconnect();
                    this.Hide();
                }
                else
                {
                    db.Disconnect();
                    MessageBox.Show("Login failed! Please check your input.", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void button4_Click_1(object sender, EventArgs e)
        {
            String id    = dataGridView1.Rows[x].Cells[0].Value.ToString();
            String stock = dataGridView1.Rows[x].Cells[5].Value.ToString();

            if (int.Parse(stock) == 0)
            {
                MessageBox.Show("Inventory is empty. Please select others.");
            }
            else
            {
                string name    = DLname.getInstance().Str;
                string command = "select uReservation from userlogin where uName =" + name;

                DBTools       db = new DBTools(".", "wkdl", true, "sa", "wdxg");
                SqlDataReader b  = db.getResult("select * from userlogin where uName ='" + name + "' and uReservation != ''");
                //MessageBox.Show(b.Read().ToString());
                if (b.Read())
                {
                    MessageBox.Show("Sorry! Each member can only reserve one vechicle.", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    db.Disconnect();
                    return;
                }
                db.Disconnect();
                string update  = "update ware set stocks = " + (int.Parse(stock) - 1) + " where [id]=" + id;
                string reserve = "; update userlogin set uReservation = 'Model: " + dataGridView1.Rows[x].Cells[1].Value + ", Price: $" + dataGridView1.Rows[x].Cells[2].Value + "/mouth, Zip: " + dataGridView1.Rows[x].Cells[3].Value + ", Reserve time: " + DateTime.Now.ToLocalTime() + "' where [uName] = '" + DLname.getInstance().Str + "'";
                da.InsertCommand             = con.CreateCommand();
                da.InsertCommand.CommandText = update + reserve;
                //MessageBox.Show(update + reserve);
                con.Open();
                da.InsertCommand.ExecuteNonQuery();
                con.Close();
                MessageBox.Show("Reserve successfully, please wait for agent response.");
                LoadDGV();
            }
        }
示例#3
0
        private void Pwd_Load(object sender, EventArgs e)
        {
            DLname c = DLname.getInstance();

            textBox1.Text = c.Str;
        }