コード例 #1
0
 //创建订单
 private void createButton_Click(object sender, EventArgs e)
 {
     //调用数据库操作
     DBOperation.CreateOrder(this.recAddressTextBox.Text, this.recPersonTextBox.Text);
     DBOperation.OrderCount++;
     data.DataSource = DBOperation.GetOrderData();
 }
コード例 #2
0
        Form alterForm;       //修改订单信息窗口

        public MainForm()
        {
            InitializeComponent();

            //创建订单管理对象,并且绑定数据
            this.orderDataGridView.DataSource = DBOperation.GetOrderData();
            this.orderDataGridView.DataMember = "orders";

            //设置表格属性为只读,防止数据错误
            this.orderDataGridView.ReadOnly   = true;
            this.productDataGridView.ReadOnly = true;
        }
コード例 #3
0
        //删除某个选中的订单项
        private void deleteButton_Click(object sender, EventArgs e)
        {
            try
            {
                //获取选中的订单的订单号
                int row     = this.orderDataGridView.CurrentRow.Index;
                int orderId = Int32.Parse(
                    this.orderDataGridView.Rows[row].Cells[0].Value.ToString()
                    );

                //调用数据库操作
                DBOperation.DeleteOrder(orderId);

                //刷新表格
                this.orderDataGridView.DataSource = DBOperation.GetOrderData();
            }
            catch (FormatException exception)
            {
                MessageBox.Show(exception.Message, "ERROR", MessageBoxButtons.OK);
            }
        }
コード例 #4
0
 //返回主界面
 private void backButton_Click(object sender, EventArgs e)
 {
     data.DataSource = DBOperation.GetOrderData();
     this.Close();
 }
コード例 #5
0
 //查询结果后返回或者刷新表格
 private void backButton_Click(object sender, EventArgs e)
 {
     this.orderDataGridView.DataSource = DBOperation.GetOrderData();
 }
コード例 #6
0
 //还原数据库
 private void importButton_Click(object sender, EventArgs e)
 {
     //调用数据库操作并更新表格
     DBOperation.ImportFromSql();
     this.orderDataGridView.DataSource = DBOperation.GetOrderData();
 }