Example #1
0
        private void frmOrderDetails_Load(object sender, EventArgs e)
        {
            if (order_id == 0)
            {
                order = new Order()
                {
                    OrderDate = DateTime.Now,
                    Customer  = "",
                    UserId    = user_id,
                    Status    = 1
                };
                db.Orders.InsertOnSubmit(order);
                db.SubmitChanges();
            }
            else
            {
                order = db.Orders.Where(x => x.Id == order_id).SingleOrDefault();
                //check edit permision
                if (order.UserId != user_id || order.Status != 1)
                {
                    dtpOrderDate.Enabled = false;
                }
            }
            txtUser.Text       = order.User.ToString();
            dtpOrderDate.Value = order.OrderDate;
            txtOrderID.Text    = order.Id.ToString("D5");
            txtCustomer.Text   = order.Customer;

            var od_list = from d in db.OrderDetails
                          where d.OrderId == order.Id
                          select new
            {
                d.Id,
                d.Product.ProductName,
                d.Product.Unit,
                d.Price,
                d.Quantity,
                Total = d.Price * d.Quantity
            };

            dataGridView1.DataSource     = od_list;
            cbbProductName.DataSource    = db.Products;
            cbbProductName.ValueMember   = "Id";
            cbbProductName.DisplayMember = "ProductName";
        }
Example #2
0
        private void frmOrderDetails_Load(object sender, EventArgs e)
        {
            if (order_id == 0)
            {
                order = new Order()
                {
                    OrderDate = DateTime.Now,
                    Customer  = "",
                    UserId    = user_id,
                    Status    = 1
                };
                db.Orders.InsertOnSubmit(order);
                db.SubmitChanges();
            }
            else
            {
                order = db.Orders.Where(x => x.Id == order_id).SingleOrDefault();

                //check editing permission
                if (order.UserId != user_id || order.Status != 1)
                {
                    dtpOrderDate.Enabled = false;
                    txtCustomer.ReadOnly = true;
                    //.......
                    panel1.Enabled    = false;
                    btnFinish.Enabled = false;
                }
            }

            txtId.Text         = order.Id.ToString("D5");
            dtpOrderDate.Value = order.OrderDate;
            txtUser.Text       = order.User.FullName;//co van de
            txtCustomer.Text   = order.Customer;


            LoadOrdersDetail(0);
            cbbProducts.DataSource    = db.Products.ToList();
            cbbProducts.ValueMember   = "Id";
            cbbProducts.DisplayMember = "ProductName";
            cbbProducts.Text          = "s";
        }