Ejemplo n.º 1
0
        private void BasketForm_Load(object sender, EventArgs e)
        {
            selectedUser = new user();
            setDataGrid();

            if (dataFormDTO.userData.isAdmin)
            {
                tbName.ReadOnly       = false;
                tbSecondName.ReadOnly = false;
                tbEmail.ReadOnly      = false;
            }
            else
            {
                PickCustomer.Hide();
            }

            tbName.Text       = dataFormDTO.userData.firstName;
            tbSecondName.Text = dataFormDTO.userData.secondName;
            tbEmail.Text      = dataFormDTO.userData.email;

            if (!ordered)
            {
                DeliveryLabel.Hide();
                DeliveryText.Hide();
            }
            else
            {
                List <ShopBasketPos> pos = basket.GetLines();
                car c = dataFormDTO.db.cars.Find(pos[0].ProdID);

                DeliveryText.Text = c.deliveryTime + " дней";
            }
        }
Ejemplo n.º 2
0
        private void setDelivery()
        {
            pos  = basket.GetLines();
            cars = new List <car>(pos.Count);

            for (int i = 0; i < pos.Count; i++)
            {
                cars.Add(dataFormDTO.db.cars.Find(pos[i].ProdID));
            }

            int  maxDelivery  = 0;
            bool needDelivery = false;

            for (int i = 0; i < pos.Count; i++)
            {
                if (pos[i].Quantity > cars[i].rest)
                {
                    needDelivery = true;
                    if (maxDelivery < cars[i].deliveryTime)
                    {
                        maxDelivery = cars[i].deliveryTime.Value;
                    }
                }
            }

            if (needDelivery)
            {
                DeliveryLabel.Show();
                DeliveryText.Show();
                DeliveryText.Text = maxDelivery.ToString() + " д.";
            }
            else
            {
                DeliveryText.Hide();
                DeliveryLabel.Hide();
            }
        }