Ejemplo n.º 1
0
        public void ChangePartStatus(ChangePartStatusBindingModel model)
        {
            var part = partLogic.Read(new PartBindingModel
            {
                Id         = model.PartId,
                PartStatus = PartStatus.Костыль
            })?.FirstOrDefault();

            if (part == null)
            {
                throw new Exception("Деталь не найдена");
            }

            if (part.PartCount - model.PartCount >= 0)
            {
                partLogic.CreateOrUpdate(new PartBindingModel
                {
                    Id           = part.Id,
                    ProviderId   = part.ProviderId,
                    ProviderFIO  = part.ProviderFIO,
                    PartType     = part.PartType,
                    PartColor    = part.PartColor,
                    PartCount    = model.PartCount,
                    PartStatus   = PartStatus.Убыл,
                    DateRecieve  = part.DateRecieve,
                    DateTransfer = DateTime.Now
                });

                partLogic.CreateOrUpdate(new PartBindingModel
                {
                    ProviderId  = part.ProviderId,
                    ProviderFIO = part.ProviderFIO,
                    PartType    = part.PartType,
                    PartColor   = part.PartColor,
                    PartCount   = part.PartCount - model.PartCount,
                    PartStatus  = PartStatus.Прибыл,
                    DateRecieve = part.DateRecieve
                });
            }
            else
            {
                throw new Exception("Не хватает деталей");
            }
        }
Ejemplo n.º 2
0
        private void LoadData()
        {
            try
            {
                var list = partlogic.Read(new PartBindingModel {
                    PartStatus = PartStatus.Прибыл
                });

                dataGridViewAvailableParts.Rows.Clear();
                foreach (var elem in list)
                {
                    if (elem.PartCount > 0)
                    {
                        dataGridViewAvailableParts.Rows.Add(new object[]
                        {
                            elem.Id,
                            elem.PartType,
                            elem.PartColor,
                            elem.PartCount
                        });
                    }
                }

                /*if (list != null)
                 * {
                 *  dataGridViewAvailableParts.DataSource = list;
                 *  dataGridViewAvailableParts.Columns[0].Visible = false;
                 *  dataGridViewAvailableParts.Columns[1].Visible = false;
                 *  dataGridViewAvailableParts.Columns[2].Visible = false;
                 *  dataGridViewAvailableParts.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                 *  dataGridViewAvailableParts.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                 *  dataGridViewAvailableParts.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                 *  dataGridViewAvailableParts.Columns[6].Visible = false;
                 *  dataGridViewAvailableParts.Columns[7].Visible = false;
                 *  dataGridViewAvailableParts.Columns[8].Visible = false;
                 * }*/
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка при загрузке деталей", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
        public void AddPart(PartBindingModel model)
        {
            var           parts = partLogic.Read(null);
            PartViewModel part  = null;

            foreach (var p in parts)
            {
                if (p.PartType == model.PartType && p.PartColor == model.PartColor && p.PartStatus == model.PartStatus)
                {
                    part = p;
                    break;
                }
            }

            if (part != null)
            {
                partLogic.CreateOrUpdate(new PartBindingModel
                {
                    Id          = part.Id,
                    PartType    = part.PartType,
                    PartColor   = part.PartColor,
                    PartCount   = part.PartCount + model.PartCount,
                    PartStatus  = part.PartStatus,
                    DateRecieve = part.DateRecieve
                });
            }
            else
            {
                partLogic.CreateOrUpdate(new PartBindingModel
                {
                    PartType    = model.PartType,
                    PartColor   = model.PartColor,
                    PartCount   = model.PartCount,
                    PartStatus  = PartStatus.Прибыл,
                    DateRecieve = DateTime.Now
                });
            }
        }
Ejemplo n.º 4
0
 public List <PartModel> GetPartList() => _part.Read(null)?.Select(rec => PartConvert(rec)).ToList();