예제 #1
0
        private void FillEntity(Guid id)
        {
            using (kipEntities context = new kipEntities())
            {
                mVPS           = context.MVPSSet.Where(b => b.Id == id).SingleOrDefault();
                NumberBox.Text = mVPS.number;
                SeriesBox.Text = mVPS.series;

                for (int i = 0; i < RoleBox.Items.Count; i++)
                {
                    if (RoleBox.Items[i].ToString() == mVPS.MVPSRole.name)
                    {
                        RoleBox.SelectedIndex = i;
                    }
                }

                for (int i = 0; i < TypeBox.Items.Count; i++)
                {
                    if (TypeBox.Items[i].ToString() == mVPS.MVPSType.name)
                    {
                        TypeBox.SelectedIndex = i;
                    }
                }

                AddButton.Text = "Сохранить";
                IdBox.Text     = mVPS.Id.ToString();
            }
        }
예제 #2
0
        private void FillForm()
        {
            using (kipEntities context = new kipEntities())
            {
                try
                {
                    IdBox.Text = Guid.NewGuid().ToString();
                    //TypeBox & RoleBox
                    var types        = context.MVPSTypeSet.ToList();
                    var roles        = context.MVPSRoleSet.ToList();
                    var currentRules = context.EquipmentRuleSet.ToList();

                    foreach (MVPSRole role in roles)
                    {
                        RoleBox.Items.Add(role.name);
                        roleIds.Add(role.Id);
                    }

                    foreach (MVPSType type in types)
                    {
                        TypeBox.Items.Add(type.name);
                        typeIds.Add(type.Id);
                    }

                    if (mVPS != null)
                    {
                        for (int i = 0; i < RoleBox.Items.Count; i++)
                        {
                            if (RoleBox.Items[i].ToString() == mVPS.MVPSRole.name)
                            {
                                RoleBox.SelectedIndex = i;
                            }
                        }

                        for (int i = 0; i < TypeBox.Items.Count; i++)
                        {
                            if (TypeBox.Items[i].ToString() == mVPS.MVPSType.name)
                            {
                                TypeBox.SelectedIndex = i;
                            }
                        }

                        GetRuleList();
                        SeriesBox.Text = mVPS.series;
                    }
                    mVPS = null;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
예제 #3
0
 private void AddToDayMVPSList(MVPS mvps, bool isTO3)
 {
     if (isTO3)
     {
         ms.Add(mvps);
         DayMVPSList.Items.Add("ТО3 " + mvps.GetSeries());
     }
     else
     {
         ms.Add(mvps);
         DayMVPSList.Items.Add("ТР1 " + mvps.GetSeries());
     }
 }
예제 #4
0
        private bool checkUnStaffed(MVPS mvp, kipEntities context)
        {
            var mvps = context.MVPSSet.Where(b => b.series == mvp.series);

            foreach (var m in mvps)
            {
                if (!m.IsStaffed())
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #5
0
        private void FillGrid()
        {
            mvpsGuid = Guid.Empty;

            if (CheckAllSelected())
            {
                using (kipEntities context = new kipEntities())
                {
                    try
                    {
                        var type   = MVPSTypeBox.SelectedItem.ToString();
                        var series = MVPSSeriesBox.SelectedItem.ToString();
                        var number = MVPSNumberBox.SelectedItem.ToString();

                        MVPS mvps = context.MVPSSet.Where(b => (b.series == series) &&
                                                          (b.MVPSType.name == type) && (b.number == number)).SingleOrDefault();

                        mvpsGuid = mvps.Id;

                        var rules = mvps.EquipmentRule.EquipmentType.ToList();
                        int i     = 0;
                        mvpsGrid.Rows.Clear();
                        foreach (var rule in rules)
                        {
                            string cell1 = null, cell2 = null, cell3 = null, cell4 = null;
                            var    block = mvps.Equipment.Where(b => b.EquipmentType == rule).SingleOrDefault();
                            Guid?  cell0 = null;
                            cell1 = rule.name;
                            cell2 = rule.SystemType.name;
                            if (block != null)
                            {
                                cell0 = block.Id;
                                cell3 = block.number;
                                cell4 = block.serviceDate.ToString("dd.MM.yy");
                            }

                            mvpsGrid.Rows.Add(cell0, cell1, cell2, cell3, cell4);
                            i++;
                        }

                        FillEquipmentGrid(mvpsGrid[1, 0].Value.ToString());
                        //var equipments = mvps.Equipment
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
예제 #6
0
        private void MvpsGrid_CellDoubleClick(Object sender, DataGridViewCellEventArgs e)
        {
            if (CheckAllSelected() && !CheckEmpty())
            {
                using (kipEntities context = new kipEntities())
                {
                    Guid      id        = Guid.Parse(mvpsGrid[0, e.RowIndex].Value.ToString());
                    Equipment equipment = context.EquipmentSet.Where(b => b.Id == id).SingleOrDefault();

                    DialogResult result = MessageBox.Show("Нажмите \"Да\", если блок снимается по неисправности. Если блок снимается по другой причине - нажмите \"Нет\"", "Снимаем " + equipment.EquipmentType.name + " № " + equipment.number, MessageBoxButtons.YesNoCancel);

                    MVPS mvps = context.MVPSSet.Where(b => b.Id == mvpsGuid).SingleOrDefault();

                    equipment.isFree = true;
                    mvps.Equipment.Remove(equipment);
                    context.SaveChanges();

                    switch (result)
                    {
                    case DialogResult.Yes:
                        equipment.isWorking = false;
                        equipment.isFree    = true;
                        mvps.Equipment.Remove(equipment);
                        if (worker != null)
                        {
                            OutGuid = equipment.Id;
                            input   = Microsoft.VisualBasic.Interaction.InputBox("Введите комментарий к замене", "Замена оборудования", "По сроку.", -1, -1);
                        }
                        context.SaveChanges();
                        break;

                    case DialogResult.No:
                        equipment.isFree = true;
                        mvps.Equipment.Remove(equipment);
                        if (worker != null)
                        {
                            OutGuid = equipment.Id;
                            input   = Microsoft.VisualBasic.Interaction.InputBox("Введите комментарий к замене", "Замена оборудования", "По сроку.", -1, -1);
                        }
                        context.SaveChanges();
                        break;

                    case DialogResult.Cancel:
                        break;
                    }
                }
                FillGrid();
            }
        }
예제 #7
0
        private void EquipmentGrid_CellDoubleClick(Object sender, DataGridViewCellEventArgs e)
        {
            if (CheckAllSelected() && CheckEmpty())
            {
                if (equipmentGrid[0, e.RowIndex].Value.ToString() != "")
                {
                    using (kipEntities context = new kipEntities())
                    {
                        Guid      id        = Guid.Parse(equipmentGrid[0, e.RowIndex].Value.ToString());
                        Equipment equipment = context.EquipmentSet.Where(b => b.Id == id).SingleOrDefault();

                        MVPS mvps = context.MVPSSet.Where(b => b.Id == mvpsGuid).SingleOrDefault();

                        equipment.isFree = false;
                        mvps.Equipment.Add(equipment);

                        if (worker != null)
                        {
                            if (OutGuid.Equals(Guid.Empty))
                            {
                                throw new Exception("Не найдена начатая замена. Если вы не снимали соотвествующее оборудование - обратитесь к мастеру или администратору");
                            }
                            else
                            {
                                Replacing(context, equipment.Id, OutGuid, mvps, input);
                            }
                        }

                        context.SaveChanges();
                    }
                    FillGrid();
                }
            }
            else
            {
                MessageBox.Show("Что-то пошло не так, возможно вы пытаетесь установить блок на занятую позицию.");
            }
        }
예제 #8
0
        public static void FillGrid(ListBox list, DataGridView view)
        {
            var str = "";

            if (list.SelectedItem != null)
            {
                str = list.SelectedItem.ToString();
            }
            gridView = view;
            listBox  = list;

            switch (str)
            {
            case "Оборудование":
                Equipment.FillGrid(view);
                break;

            case "Типы оборудования":
                EquipmentType.FillGrid(view);
                break;

            case "Производители":
                Manufacturer.FillGrid(view);
                break;

            case "Типы систем":
                SystemType.FillGrid(view);
                break;

            case "Роли МВПС":
                MVPSRole.FillGrid(view);
                break;

            case "Типы МВПС":
                MVPSType.FillGrid(view);
                break;

            case "МВПС":
                MVPS.FillGrid(view);
                break;

            case "Правила компелктования":
                EquipmentRule.FillGrid(view);
                break;

            case "Замены оборудования":
                ReplacingLog.FillGrid(view);
                break;

            case "Работники":
                Worker.FillGrid(view);
                break;

            case "Должности":
                Position.FillGrid(view);
                break;

            case "График ТО и ТР":
                Shedule.FillGrid(view);
                break;

            case "Журнал проверки/ремонта":
                ServiceLog.FillGrid(view);
                break;

            default:
                break;
            }
        }
예제 #9
0
        private void Replacing(kipEntities context, Guid InEquipment, Guid OutEquipment, MVPS mvps, string input)
        {
            bool onShed = false;

            if (input == "По сроку.")
            {
                onShed = true;
            }

            Equipment InEq  = context.EquipmentSet.Where(b => b.Id == InEquipment).Single();
            Equipment OutEq = context.EquipmentSet.Where(b => b.Id == OutEquipment).Single();

            Worker performer = context.WorkerSet.Where(b => b.Id == worker.Id).Single();

            ReplacingLog replacing = new ReplacingLog
            {
                date        = DateTime.Now,
                description = input,
                Installed   = InEq,
                MVPS        = mvps,
                onShedule   = onShed,
                Removed     = OutEq,
                Worker      = performer
            };

            context.ReplacingLogSet.Add(replacing);
        }
예제 #10
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            Guid guid = mVPS == null? Guid.Empty : mVPS.Id;

            using (kipEntities context = new kipEntities())
            {
                try
                {
                    CheckFields();
                    if (mVPS != null)
                    {
                        int           typeId = typeIds[TypeBox.SelectedIndex];
                        int           roleId = roleIds[RoleBox.SelectedIndex];
                        int           ruleId = currentRules[RuleBox.SelectedIndex].Id;
                        MVPSType      type   = context.MVPSTypeSet.Where(b => b.Id == typeId).SingleOrDefault();
                        MVPSRole      role   = context.MVPSRoleSet.Where(b => b.Id == roleId).SingleOrDefault();
                        EquipmentRule rule   = context.EquipmentRuleSet.Where(b => b.Id == ruleId).SingleOrDefault();
                        MVPS          mVPS   = context.MVPSSet.Where(b => b.Id == guid).SingleOrDefault();
                        if (mVPS.MVPSRole.Id != role.Id)
                        {
                            mVPS.MVPSRole = role;
                        }
                        if (mVPS.MVPSType.Id != type.Id)
                        {
                            mVPS.MVPSType = type;
                        }
                        if (mVPS.number != NumberBox.Text)
                        {
                            mVPS.number = NumberBox.Text;
                        }
                        if (mVPS.series != SeriesBox.Text)
                        {
                            mVPS.series = SeriesBox.Text;
                        }
                        if (mVPS.EquipmentRule.Id != rule.Id)
                        {
                            mVPS.EquipmentRule = rule;
                        }
                        context.SaveChanges();
                    }
                    else
                    {
                        int           typeId = typeIds[TypeBox.SelectedIndex];
                        int           roleId = roleIds[RoleBox.SelectedIndex];
                        int           ruleId = currentRules[RuleBox.SelectedIndex].Id;
                        MVPSType      type   = context.MVPSTypeSet.Where(b => b.Id == typeId).SingleOrDefault();
                        MVPSRole      role   = context.MVPSRoleSet.Where(b => b.Id == roleId).SingleOrDefault();
                        EquipmentRule rule   = context.EquipmentRuleSet.Where(b => b.Id == ruleId).SingleOrDefault();

                        mVPS = new MVPS
                        {
                            Id            = Guid.Parse(IdBox.Text),
                            number        = NumberBox.Text,
                            series        = SeriesBox.Text,
                            MVPSType      = type,
                            MVPSRole      = role,
                            EquipmentRule = rule
                        };

                        context.MVPSSet.Add(mVPS);
                        context.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    roleIds.Clear();
                    typeIds.Clear();
                    currentRules.Clear();
                    Close();
                }
            }
        }