Beispiel #1
0
        //修改某个商品信息页面
        private void alterProductButton_Click(object sender, EventArgs e)
        {
            try
            {
                //获取将要修改的商品信息
                int row       = this.productDataGridView.CurrentRow.Index;
                int productId = Int32.Parse(
                    this.productDataGridView.Rows[row].Cells[0].Value.ToString()
                    );
                int amount = Int32.Parse(
                    this.productDataGridView.Rows[row].Cells[2].Value.ToString()
                    );
                int price = Int32.Parse(
                    this.productDataGridView.Rows[row].Cells[1].Value.ToString()
                    );

                //调用数据库操作
                DBOperation.UpdateProductAmount(this.orderId, productId, amount, price);

                //更新表格
                this.productDataGridView.DataSource = DBOperation.GetProductData(orderId);
            }
            catch (FormatException exception)
            {
                MessageBox.Show(exception.Message, "ERROR", MessageBoxButtons.OK);
            }
        }
Beispiel #2
0
        private void orderDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                //获取选中的订单的订单号
                int row     = this.orderDataGridView.CurrentRow.Index;
                int orderId = Int32.Parse(
                    this.orderDataGridView.Rows[row].Cells[0].Value.ToString()
                    );

                //调用数据库操作
                this.productDataGridView.DataSource = DBOperation.GetProductData(orderId);
                this.productDataGridView.DataMember = "products";
            }
            catch (FormatException exception)
            {
                MessageBox.Show(exception.Message, "ERROR", MessageBoxButtons.OK);
            }
        }
Beispiel #3
0
        public alterForm(int orderId, string recPerson, string recAddress)
        {
            InitializeComponent();
            this.orderId = orderId;
            this.RecPersonTextBox.Text  = this.recPerson = recPerson;
            this.RecAddressTextBox.Text = this.recAddress = recAddress;

            //设置表格属性
            this.productBindingSource_1.DataSource = DBOperation.GetProductData(orderId);
            this.productDataGridView.DataSource    = this.productBindingSource_1;
            this.productDataGridView.DataMember    = "products";

            //除了商品数量列外均设置为只读
            this.productDataGridView.Columns[0].ReadOnly = true;
            this.productDataGridView.Columns[1].ReadOnly = true;
            this.productDataGridView.Columns[3].ReadOnly = true;
            this.productDataGridView.Columns[4].ReadOnly = true;
            this.productDataGridView.Columns[5].ReadOnly = true;
        }
Beispiel #4
0
        //删除选中的商品
        private void deleteProductButton_Click(object sender, EventArgs e)
        {
            try
            {
                //获取选中的商品的信息
                int row       = this.productDataGridView.CurrentRow.Index;
                int productId = Int32.Parse(
                    this.productDataGridView.Rows[row].Cells[0].Value.ToString()
                    );

                //调用数据库操作删除商品
                DBOperation.DeleteProduct(orderId, productId);

                //刷新表格
                this.productDataGridView.DataSource = DBOperation.GetProductData(this.orderId);
            }
            catch (FormatException exception)
            {
                MessageBox.Show(exception.Message, "ERROR", MessageBoxButtons.OK);
            }
        }
Beispiel #5
0
        //添加商品
        private void Button_Click(object sender, EventArgs e)
        {
            try
            {
                //根据输入的信息添加商品
                string name  = this.productNameTextBox.Text;
                double price = Double.Parse(
                    this.priceTextBox.Text);
                int amount = Int32.Parse(
                    this.amountTextBox.Text);
                int productId = Int32.Parse(
                    this.productIdtextBox.Text);

                //调用数据库操作
                DBOperation.AddProduct(productId, price, amount, name, this.orderId);

                //刷新表格
                data.DataSource = DBOperation.GetProductData(this.orderId);
            }catch (FormatException exception)
            {
                MessageBox.Show(exception.Message, "ERROR", MessageBoxButtons.OK);
            }
        }