Ejemplo n.º 1
0
        private void BindFields()
        {
            if (dgv_Orders.SelectedRows.Count == 1)
            {
                //binding customer who made the order
                SqlCommand getCustomer = new SqlCommand("select * from customer where customer_id = (select cast(customer_id as int) from customer_orders where order_id = '" + dgv_Orders.CurrentRow.Cells[0].Value + "')", FormControls.DbConnection);
                FormControls.BindData(dgv_Customer, command: getCustomer);
                FormControls.HideDGVColumns(dgv_Customer.Columns[0], dgv_Customer.Columns[6], dgv_Customer.Columns[7]);

                //binding products from order
                SqlCommand getProducts = new SqlCommand("select * from product where product_id = (select product_id from order_products where order_id = '" + dgv_Orders.CurrentRow.Cells[0].Value + "')", FormControls.DbConnection);
                FormControls.BindData(dgv_Products, command: getProducts);
                FormControls.HideDGVColumns(dgv_Products.Columns[1], dgv_Products.Columns[11]);
                UpdateProductAmount();

                //binding order status
                gb_Status.Controls.OfType <RadioButton>().Where(r => r.Text == dgv_Orders.CurrentRow.Cells[3].Value.ToString().Trim()).FirstOrDefault().Checked = true;
            }
        }