Пример #1
0
        public EditWindow(MainWindow mainWindow, MattressObjectV2 obj)
        {
            InitializeComponent();

            this.mainWindow = mainWindow;
            mtrObj          = obj;

            lbOrderInfo.Content    += mtrObj.OrderInfo;
            lbTableName.Content    += mtrObj.TableName;
            lbMattressName.Content += mtrObj.Name;
            lbSize.Content         += mtrObj.Size;
            lbNumbers.Content      += mtrObj.Numbers.ToString();

            this.mainWindow.GetOrdersList().ForEach(str => cmbOrders.Items.Add(str));
            using (PgContext context = new PgContext())
            {
                foreach (var size in context.Sizes)
                {
                    cmbSizes.Items.Add(size);
                }
                foreach (var table in context.Tables)
                {
                    cmbTables.Items.Add(table);
                }
            }
        }
Пример #2
0
 public void AddObjectInGlobalTypesList(MattressObjectV2 objForAdding)
 {
     if (globalTypesList.Contains(objForAdding))
     {
         globalTypesList.Remove(objForAdding);
         listBoxTypesList.Items.Remove(objForAdding);
     }
     globalTypesList.Add(objForAdding);
     listBoxTypesList.Items.Add(objForAdding);
 }
Пример #3
0
 public void RemoveGlobalTypesListObject(MattressObjectV2 objForRemove)
 {
     globalTypesList.Remove(objForRemove);
     listBoxTypesList.Items.Remove(objForRemove);
 }
Пример #4
0
        private void AddMattressObject()
        {
            if (!(txtOrderId.Text.Length > 0 & txtDateOfOrder.Text.Length > 0))
            {
                throw new Exception("Поля кода или даты заказа не должны быть пусты.");
            }
            //if (cmbTables.SelectedItem == null)
            //    throw new Exception("Не выбран стол сборки.");
            if (listBoxMattressList.SelectedItem == null)
            {
                throw new Exception("Не выбран матрас.");
            }
            string tableName = null;

            if (cmbTables.SelectedItem != null)
            {
                tableName = cmbTables.SelectedItem.ToString();
            }

            int numbers = 1;

            if (txtNumbers.Text.Length != 0)
            {
                numbers = Convert.ToInt32(txtNumbers.Text);
            }

            int lenght, width;

            if (!(cmbSizes.SelectedItem == null & (txtCustomLenght.Text.Length == 0 & txtCustomWidth.Text.Length == 0)))
            {
                if (cmbSizes.SelectedItem != null)
                {
                    Sizes tempSize = (Sizes)cmbSizes.SelectedItem;
                    lenght = tempSize.lenght;
                    width  = tempSize.width;
                }
                else
                {
                    if (txtCustomLenght.Text.Length != 0 & txtCustomWidth.Text.Length != 0)
                    {
                        lenght = Convert.ToInt32(txtCustomLenght.Text);
                        width  = Convert.ToInt32(txtCustomWidth.Text);
                    }
                    else
                    {
                        throw new Exception("Не указана длинна или ширина матраса.");
                    }
                }
            }
            else
            {
                throw new Exception("Отсутствуют данные о размере.");
            }

            if (globalTypesList == null)
            {
                globalTypesList = new List <MattressObjectV2>();
            }

            MattressObjectV2 tempMattressObject = new MattressObjectV2(txtOrderId.Text + " : " + txtDateOfOrder.Text, tableName, (Mattresses)listBoxMattressList.SelectedItem, lenght, width, numbers);

            if (globalTypesList.Contains(tempMattressObject))
            {
                numbers += globalTypesList.Find(mattress => mattress == tempMattressObject).Numbers;
                globalTypesList.Remove(tempMattressObject);
                listBoxTypesList.Items.Remove(tempMattressObject);
                tempMattressObject = new MattressObjectV2(txtOrderId.Text + " : " + txtDateOfOrder.Text, tableName, (Mattresses)listBoxMattressList.SelectedItem, lenght, width, numbers);
            }

            globalTypesList.Add(tempMattressObject);
            listBoxTypesList.Items.Add(tempMattressObject);

            txtNumbers.Clear();
        }