Пример #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);
            }
        }
Пример #2
0
        private void Update_Load(object sender, EventArgs e)
        {
            db = new DBTools(".", "wkdl", true, "sa", "wdxg");
            SqlDataReader b = db.getResult("Select * from ware where id=" + c.Num);

            while (b.Read())
            {
                textBox1.Text = b["id"].ToString();
                textBox2.Text = b["warename"].ToString();
                textBox3.Text = b["price"].ToString();
                textBox4.Text = b["type"].ToString();
                textBox5.Text = b["zip"].ToString();
                textBox6.Text = b["stocks"].ToString();
            }

            db.Disconnect();
        }
        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();
            }
        }
Пример #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         db = new DBTools(".", "wkdl", true, "sa", "wdxg");
         if (textBox1.Text.Trim().Length == 0 || textBox2.Text.Trim().Length == 0 || textBox3.Text.Trim().Length == 0 || textBox4.Text.Trim().Length == 0)
         {
             MessageBox.Show("不能有任何一项为空!", "系统提示");
         }
         if (textBox2.Text.Trim().Equals('0'))
         {
             MessageBox.Show("入库数量不能为0", "系统提示");
             return;
         }
         else
         {
             if (IsNumeric(textBox2.Text.Trim()) && IsNumeric(textBox3.Text.Trim()) && IsNumeric(textBox4.Text.Trim()))
             {
                 string oth = "select id,warename,price,type,zip,stocks from ware where warename='" + textBox1.Text.Trim().ToString() + "'";
                 da = new SqlDataAdapter(oth, con);
                 ds = new DataSet();
                 da.Fill(ds);
                 string str;
                 if (ds.Tables[0].Rows.Count == 0)
                 {
                     str = "insert into ware (warename ,price,type,zip,stocks) values('" + textBox1.Text.Trim().ToString() + "'," + int.Parse(textBox4.Text.Trim()) + "," + 0 + "," + int.Parse(textBox3.Text.Trim()) + "," + int.Parse(textBox2.Text.Trim()) + ")";
                 }
                 else
                 {
                     str = "update ware set price=" + int.Parse(textBox4.Text.Trim()) + ",zip=" + int.Parse(textBox3.Text.Trim()) + ",stocks=stocks+" + int.Parse(textBox2.Text.Trim()) + " where [warename]='" + textBox1.Text.Trim().ToString() + "'";
                 }
                 da.InsertCommand             = con.CreateCommand();
                 da.InsertCommand.CommandText = str;
                 con.Open();
                 da.InsertCommand.ExecuteNonQuery();
                 con.Close();
                 MessageBox.Show("增加新商品成功!");
                 ListViewItem l = new ListViewItem();
                 l.Text = textBox1.Text.ToString();
                 l.Tag  = l.Text;
                 bid.Add(l.Tag.ToString());
                 l.SubItems.Add(textBox2.Text.ToString());
                 l.SubItems.Add(textBox3.Text.ToString());
                 l.SubItems.Add(textBox4.Text.ToString());
                 l.SubItems.Add(label6.Text.ToString());
                 listView1.Items.Add(l);
                 textBox1.Text = "";
                 textBox2.Text = "";
                 textBox3.Text = "";
                 textBox4.Text = "";
             }
             else
             {
                 MessageBox.Show("除商品名称都只能是数字", "系统提示");
                 textBox2.Text = "";
                 textBox3.Text = "";
                 textBox4.Text = "";
             }
         }
         db.Disconnect();
     }
     catch (Exception ec)
     {
         MessageBox.Show(ec.Message);
     }
 }