Ejemplo n.º 1
0
        private void otherProductListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (otherProductListBox.SelectedItem == null)
            {
                return;
            }
            OtherProductListItem otherProductListItem = otherProductListBox.SelectedItem as OtherProductListItem;
            OrderProduct         tmpOrderProdcut      = dataBaseAC.OrderProducts.Find(otherProductListItem.Order_product_id);
            ReturnProductDetails returnProductDetails = new ReturnProductDetails(tmpOrderProdcut, dataBaseAC);

            if (returnProductDetails.ShowDialog() == true)
            {
                otherProductListItem.Return_count = returnProductDetails.ReturnOrderProductCount;
                otherProductListBox.SelectedItem  = otherProductListItem;
                otherProductListBox.Items.Refresh();
            }
        }
Ejemplo n.º 2
0
        private void GetProducts()
        {
            List <OrderProduct>         orderProducts         = new List <OrderProduct>();
            OrderProduct                orderProduct          = new OrderProduct();
            List <OtherProductListItem> otherProductListItems = new List <OtherProductListItem>();
            OtherProductListItem        otherProductListItem  = new OtherProductListItem();

            orderProducts = dataBaseAC.OrderProducts.Where(op => op.Order_id == selectedOrder.OrderId).ToList();
            foreach (OrderProduct op in orderProducts)
            {
                otherProductListItem = new OtherProductListItem();
                otherProductListItem.Order_product_id = op.Id;
                otherProductListItem.Name             = dataBaseAC.Products.Find(op.Product_id).Name;
                otherProductListItem.Count            = op.Count;
                otherProductListItem.Return_count     = op.Count;
                otherProductListItem.Price            = op.Count * op.Price;
                otherProductListItems.Add(otherProductListItem);
            }
            otherProductListBox.ItemsSource = otherProductListItems;
        }
Ejemplo n.º 3
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            OtherProductListItem otherProductListItem = new OtherProductListItem();
            ProductList          productList          = new ProductList(dataBaseAC, true);

            if (productList.ShowDialog() == true)
            {
                tmpOrderProduct            = new OrderProduct();
                tmpOrderProduct.Product_id = productList.SelectedProduct.Id;
                tmpOrderProduct.Order_id   = 1;                                                                 /// Correct id get in MainWindow
                OrderProductDetails orderProductDetails = new OrderProductDetails(dataBaseAC, tmpOrderProduct);
                if (orderProductDetails.ShowDialog() == true)
                {
                    otherProductListItem.Name  = dataBaseAC.Products.Find(orderProductDetails.OrderProducts[0].Product_id).Name;
                    otherProductListItem.Count = orderProductDetails.OrderProducts[0].Count;
                    otherProductListItem.Price = orderProductDetails.OrderProducts[0].Count * orderProductDetails.OrderProducts[0].Price;
                    otherProductListItems.Add(otherProductListItem);
                    tmpOrderProductsOther.Add(orderProductDetails.OrderProducts[0]);
                    otherProductListBox.ItemsSource = otherProductListItems;
                    otherProductListBox.Items.Refresh();
                    AcceptBtn.IsEnabled = true;
                }
            }
        }
Ejemplo n.º 4
0
        private void FillData()
        {
            Client client = new Client();

            List <OrderProduct>         orderProducts         = new List <OrderProduct>();
            OrderProduct                orderProduct          = new OrderProduct();
            List <OtherProductListItem> otherProductListItems = new List <OtherProductListItem>();
            OtherProductListItem        otherProductListItem  = new OtherProductListItem();

            List <Payment>         payments         = new List <Payment>();
            List <PaymentListItem> paymentListItems = new List <PaymentListItem>();
            PaymentListItem        paymentListItem;

            switch (selectedContract.OrderStatus)
            {
            case 0:    /// New contracts
                LeaseContract selectedLeaseContract = dataBaseAC.LeaseContracts.Find(selectedContract.OrderId);
                client   = dataBaseAC.Clients.Find(selectedLeaseContract.Client_id);
                payments = dataBaseAC.Payments.Where(p => p.Order_id == selectedLeaseContract.Id).ToList();

                creationDateTimeLbl.Content = UnixTimeStampToDateTime(selectedLeaseContract.Create_datetime).ToShortDateString();
                if (selectedLeaseContract.Return_datetime > 0)
                {
                    returnDateTimeLbl.Content = UnixTimeStampToDateTime(selectedLeaseContract.Return_datetime).ToShortDateString();
                }

                this.DataContext = selectedLeaseContract;
                break;

            case 1:    /// Returned lease contracts
                ReturnedLeaseContract returnedLeaseContract = dataBaseAC.ReturnedLeaseContracts.Where(r => r.Order_id == selectedContract.OrderId).FirstOrDefault();
                client   = dataBaseAC.Clients.Find(returnedLeaseContract.Client_id);
                payments = dataBaseAC.Payments.Where(p => p.Order_id == returnedLeaseContract.Order_id).ToList();

                creationDateTimeLbl.Content = UnixTimeStampToDateTime(returnedLeaseContract.Create_datetime).ToShortDateString();
                if (returnedLeaseContract.Return_datetime > 0)
                {
                    returnDateTimeLbl.Content = UnixTimeStampToDateTime(returnedLeaseContract.Return_datetime).ToShortDateString();
                }

                this.DataContext = returnedLeaseContract;
                break;

            case 2:    /// Closed contracts
                ArchiveLeaseContract archiveLeaseContract = dataBaseAC.ArchiveLeaseContracts.Where(c => c.Order_id == selectedContract.OrderId).FirstOrDefault();
                client   = dataBaseAC.Clients.Find(archiveLeaseContract.Client_id);
                payments = dataBaseAC.Payments.Where(p => p.Order_id == archiveLeaseContract.Order_id).ToList();


                creationDateTimeLbl.Content = UnixTimeStampToDateTime(archiveLeaseContract.Create_datetime).ToShortDateString();
                if (archiveLeaseContract.Return_datetime > 0)
                {
                    returnDateTimeLbl.Content = UnixTimeStampToDateTime(archiveLeaseContract.Return_datetime).ToShortDateString();
                }

                this.DataContext = archiveLeaseContract;
                break;
            }

            clientFIOLbl.Content          = client.Surname + " " + client.Name + " " + client.Middle_name;
            clientPhoneNumberLbl.Content  = client.Phone_number;
            clientPassNumberLbl.Content   = client.Pass_number;
            clientPhoneNumber2Lbl.Content = client.Phone_number2;
            clientAddressLbl.Content      = client.Address;
            orderDaysLbl.Content          = selectedContract.UsedDays;

            orderProducts = dataBaseAC.OrderProducts.Where(op => op.Order_id == selectedContract.OrderId).ToList();
            foreach (OrderProduct op in orderProducts)
            {
                otherProductListItem       = new OtherProductListItem();
                otherProductListItem.Name  = dataBaseAC.Products.Find(op.Product_id).Name;
                otherProductListItem.Count = op.Count;
                otherProductListItem.Price = op.Count * op.Price;
                if (dataBaseAC.ReturnProducts.Where(rp => rp.Order_id == op.Order_id && rp.Product_id == op.Product_id).FirstOrDefault() != null)
                {
                    otherProductListItem.Return_count = dataBaseAC.ReturnProducts.Where(rp => rp.Order_id == op.Order_id && rp.Product_id == op.Product_id).FirstOrDefault().Count;
                }
                otherProductListItems.Add(otherProductListItem);
            }
            otherProductListBox.ItemsSource = otherProductListItems;


            foreach (Payment payment in payments)
            {
                paymentListItem             = new PaymentListItem();
                paymentListItem.Amount      = payment.Amount;
                paymentListItem.DateTime    = UnixTimeStampToDateTime(payment.Datetime).ToShortDateString();
                paymentListItem.PaymentType = payment.Payment_type;
                paymentListItems.Add(paymentListItem);
            }
            paymentListBox.ItemsSource = paymentListItems;
        }