private void shopButton_Click(object sender, EventArgs e)
        {
            if (listView1.Items.Count < 1)
            {
                MessageBox.Show("购物车里没有任何物品!");
            }
            float sumAmount = 0;

            foreach (ListViewItem item in this.listView1.Items)
            {
                float amount = float.Parse(item.SubItems[4].Text);
            }
            if (customer.Balance + customer.CustomerCreditLimit >= sumAmount)
            {
                DateTime datetime = DateTime.Now;
                int      orderId  = SqlManage.queryMaxOrderId() + 1;
                SqlManage.insertOrder(orderId, customer.CustomerId, datetime);
                foreach (ListViewItem item in this.listView1.Items)
                {
                    int    detailId = SqlManage.queryMaxDetailId() + 1;
                    int    goodsId  = Convert.ToInt32(item.SubItems[0].Text);
                    int    goodsNum = Convert.ToInt32(item.SubItems[3].Text);
                    float  amount   = float.Parse(item.SubItems[4].Text);
                    Detail detail   = new Detail(detailId, orderId, goodsId, goodsNum, amount, 0);
                    SqlManage.insertDetail(detail);
                }
                MessageBox.Show("下单成功!");
            }
            else
            {
                MessageBox.Show("已超出最大赊购限额!");
            }
        }
 private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (customer == null)
     {
         if (treeView1.SelectedNode.Name == "allColumnHeader")
         {
             myDataGridView.DataSource = SqlManage.showAllUserOrder(0).Tables[0];
         }
         else if (treeView1.SelectedNode.Name == "dealedHeader")
         {
             myDataGridView.DataSource = SqlManage.showAllUserOrder(1).Tables[0];
         }
         else if (treeView1.SelectedNode.Name == "undealedHeader")
         {
             myDataGridView.DataSource = SqlManage.showAllUserOrder(2).Tables[0];
         }
     }
     else
     {
         if (treeView1.SelectedNode.Name == "allColumnHeader")
         {
             myDataGridView.DataSource = SqlManage.showUserOrder(customer, 0).Tables[0];
         }
         else if (treeView1.SelectedNode.Name == "dealedHeader")
         {
             myDataGridView.DataSource = SqlManage.showUserOrder(customer, 1).Tables[0];
         }
         else if (treeView1.SelectedNode.Name == "undealedHeader")
         {
             myDataGridView.DataSource = SqlManage.showUserOrder(customer, 2).Tables[0];
         }
     }
 }
 private void orderQueryButton_Click(object sender, EventArgs e)
 {
     if (inputOrderIdTextBox.Text != "")
     {
         orderId             = Convert.ToInt32(this.inputOrderIdTextBox.Text);
         orderIdTextBox.Text = orderId.ToString();
         if (customer != null)
         {
             if (SqlManage.orderQuery(orderId).CustomerId == customer.CustomerId)
             {
                 customerIdTextBox.Text    = SqlManage.orderQuery(orderId).CustomerId.ToString();
                 customerNameTextBox.Text  = SqlManage.customerQuery(Convert.ToInt32(SqlManage.orderQuery(orderId).CustomerId)).Name;
                 myDataGridView.DataSource = SqlManage.detailQuery(orderId).Tables[0];
             }
             else
             {
                 MessageBox.Show("该用户没有此订单!");
             }
         }
         else
         {
             customerIdTextBox.Text    = SqlManage.orderQuery(orderId).CustomerId.ToString();
             customerNameTextBox.Text  = SqlManage.customerQuery(Convert.ToInt32(SqlManage.orderQuery(orderId).CustomerId)).Name;
             myDataGridView.DataSource = SqlManage.detailQuery(orderId).Tables[0];
         }
     }
     else
     {
         MessageBox.Show("订单号不能为空!");
     }
 }
示例#4
0
 private void okButton_Click(object sender, EventArgs e)
 {
     if (depositTextBox.Text != "")
     {
         customer.Balance += float.Parse(depositTextBox.Text);
         SqlManage.updateCustomer(customer);
         this.showCurrentBalanceLabel.Text = customer.Balance.ToString();
     }
 }
示例#5
0
 private void shuaXinButton_Click(object sender, EventArgs e)
 {
     myDataGridView.DataSource = SqlManage.goodsBrowse().Tables[0];
     for (int i = 0; i < myDataGridView.Rows.Count; i++)
     {
         int store   = int.Parse(myDataGridView.Rows[i].Cells[4].Value.ToString());
         int goodsId = int.Parse(myDataGridView.Rows[i].Cells[0].Value.ToString());
         if (store < SqlManage.goodsQuery(goodsId).MinStorage)
         {
             myDataGridView.Rows[i].Cells[0].Style.BackColor = Color.Red;
         }
     }
 }
 private void OrderQueryForm_Load(object sender, EventArgs e)
 {
     if (customer != null)
     {
         orderIdTextBox.Text       = orderId.ToString();
         customerIdTextBox.Text    = SqlManage.orderQuery(orderId).CustomerId.ToString();
         customerNameTextBox.Text  = SqlManage.customerQuery(Convert.ToInt32(SqlManage.orderQuery(orderId).CustomerId)).Name;
         myDataGridView.DataSource = SqlManage.detailQuery(orderId).Tables[0];
     }
     else
     {
         dealButton.Hide();
     }
 }
示例#7
0
 private void GoodsStatisticForm_Load(object sender, EventArgs e)
 {
     myDataGridView.DataSource = SqlManage.goodsBrowse().Tables[0];
     for (int i = 0; i < myDataGridView.Rows.Count - 1; i++)
     {
         int store   = int.Parse(myDataGridView.Rows[i].Cells[4].Value.ToString());
         int goodsId = int.Parse(myDataGridView.Rows[i].Cells[0].Value.ToString());
         if (store < SqlManage.goodsQuery(goodsId).MinStorage)
         {
             for (int j = 0; j < myDataGridView.ColumnCount; j++)
             {
                 myDataGridView.Rows[i].Cells[j].Style.BackColor = Color.Red;
             }
         }
     }
 }
        private void dealButton_Click(object sender, EventArgs e)
        {
            float    amount     = SqlManage.amountQuery(orderId);
            Order    order      = SqlManage.orderQuery(orderId);
            int      customerId = order.CustomerId;
            Customer customer   = SqlManage.customerQuery(customerId);

            order.IsDealed = true;
            if (amount < customer.Balance + customer.CustomerCreditLimit)
            {
                Bill     bill          = null;
                DateTime payDate       = DateTime.Now;
                float    amountPayable = amount;
                float    payAmount;
                int      billId = SqlManage.queryMaxBillId() + 1;
                if (customer.Balance < amount)
                {
                    payAmount = customer.Balance;
                }
                else
                {
                    payAmount = amount;
                }
                bill = new Bill(billId, orderId, amountPayable, payDate, payAmount);
                SqlManage.insertBill(bill);

                customer.Balance -= amount;
                if (SqlManage.updateCustomer(customer) &&
                    SqlManage.updateOrder(order))
                {
                    //更新库存
                    for (int i = 0; i < myDataGridView.RowCount - 1; i++)
                    {
                        int   goodsId  = Convert.ToInt32(myDataGridView[0, i].Value);
                        Goods goods    = SqlManage.goodsQuery(goodsId);
                        int   goodsNum = Convert.ToInt32(myDataGridView[1, i].Value);
                        goods.ActualStorage -= goodsNum;
                        SqlManage.updateGoods(goods);
                    }
                    MessageBox.Show("支付成功!");
                }
            }
            else
            {
                MessageBox.Show("已超出最大赊购限额!");
            }
        }
示例#9
0
        static void Main()
        {
            string connection = "Server = localhost;  Database = OrderDB; Integrated Security = SSPI;";

            if (SqlManage.connectToDatabase(connection))
            {
                //WordOperator word = new WordOperator();
                //word.CreateWord();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new LoginForm());
            }
            else
            {
                MessageBox.Show("数据库连接失败!");
            }
        }
示例#10
0
        private void registerButton_Click(object sender, EventArgs e)
        {
            string name            = userNameTextBox.Text;
            string password        = passwordTextBox.Text;
            string confirmPassword = confirmPasswordTextBox.Text;
            string address         = addressTextBox.Text;
            int    id = SqlManage.queryMaxCustomerId() + 1;

            if (password == confirmPassword)
            {
                Customer customer = new Customer(id, name, password, address);
                SqlManage.insertCustomer(customer);
            }
            else
            {
                MessageBox.Show("两次密码不一致!");
            }
        }
示例#11
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            int    id       = Convert.ToInt32(userNameTextBox.Text);
            string password = passwordTextBox.Text;

            if (customerRadioButton.Checked)
            {
                //查询客户表是否有用户名存在
                Customer customer = SqlManage.searchCustomer(id, password);
                if (customer != null)
                {
                    CustomerForm customerForm = new CustomerForm(customer);
                    customerForm.Visible = true;
                }
                else
                {
                    MessageBox.Show("用户名或密码错误!");
                }
            }
            else if (salesmanRadioButton.Checked)
            {
                //查询销售员表
                Salesman salesman = SqlManage.searchSalesman(id, password);
                if (salesman != null)
                {
                    SalesmanForm salesmanForm = new SalesmanForm(salesman);
                    salesmanForm.Visible = true;
                }
                else
                {
                    MessageBox.Show("用户名或密码错误!");
                }
            }
            else
            {
                MessageBox.Show("你未选择身份!");
            }
        }
 private void okButton_Click(object sender, EventArgs e)
 {
     if (customer.Password == oldPasswordTextBox.Text)
     {
         if (newPasswordTextBox.Text == "")
         {
             MessageBox.Show("新密码不能为空!");
         }
         else if (newPasswordTextBox.Text == confirmTextBox.Text)
         {
             customer.Password = newPasswordTextBox.Text;
             SqlManage.updateCustomer(customer);
             MessageBox.Show("修改成功!");
         }
         else
         {
             MessageBox.Show("确认密码与新密码不一致!");
         }
     }
     else
     {
         MessageBox.Show("原密码输入不正确!");
     }
 }