Exemplo n.º 1
0
        private void OpenProject_Click(object sender, EventArgs e)
        {
            if (_selnode.Tag == null)
            {
                MessageBox.Show(this, "Необходимо предварительно выбрать Задание", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Project prj = _selnode.Tag as Project;

            if (prj.Stages.Count == 0)
            {
                ProjectStage stage = new ProjectStage();

                stage.Koef      = 1;
                stage.StageName = "Этап #1";

                prj.Stages.Add(stage);
            }

            if (_app != null)
            {
                for (int j = 0; j < _app.Projects.Count; j++)
                {
                    _app.Projects[j].Actived = false;
                }

                prj.Actived = true;
            }

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Выбрать проект для работы
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenProject_Click(object sender, EventArgs e)
        {
            if (treeViewProjects.SelectedNode != null)
            {
                TreeNode selected = treeViewProjects.SelectedNode;
                Project  prj      = selected.Tag as Project;

                if (prj != null)
                {
                    foreach (Project project in _app.Projects)
                    {
                        project.Actived = false;
                    }

                    prj.Actived = true;
                    if (prj.Stages.Count == 0)
                    {
                        ProjectStage stage = new ProjectStage();

                        stage.Koef      = 1;
                        stage.StageName = "Этап #1";

                        prj.Stages.Add(stage);
                    }

                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
            }
            else
            {
                MessageBox.Show(this, "Выберите работу и повторите попытку",
                                "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// добавить новый этап работы в проект
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addNewStage_Click(object sender, EventArgs e)
        {
            InsertStageForm frm = new InsertStageForm();

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                ProjectStage stage = new ProjectStage();

                stage.Koef      = frm.StageKoef;
                stage.StageName = frm.StageName;

                try
                {
                    stage.Plan_consumption = float.Parse(frm.Plan_consumption);
                    stage.Plan_volume      = float.Parse(frm.Plan_volume);

                    stage.Plan_density  = float.Parse(frm.Plan_density);
                    stage.Plan_pressure = float.Parse(frm.Plan_pressure);
                }
                catch { }

                edited.Stages.Add(stage);
                InsertStageInList(stage);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Добавить этапы работы с активного проекта
        /// </summary>
        /// <param name="_prj"></param>
        protected void InsertStages(Project _prj)
        {
            try
            {
                Project prj = _app.CurrentProject;
                if (prj != null)
                {
                    foreach (ProjectStage stage in prj.Stages)
                    {
                        ProjectStage new_stage = new ProjectStage();

                        new_stage.StageName = stage.StageName;

                        new_stage.Koef = stage.Koef;

                        new_stage.Plan_consumption = stage.Plan_consumption;
                        new_stage.Plan_density     = stage.Plan_density;

                        new_stage.Plan_pressure = stage.Plan_pressure;
                        new_stage.Plan_volume   = stage.Plan_volume;

                        _prj.Stages.Add(new_stage);
                    }
                }
            }
            catch { }
        }
Exemplo n.º 5
0
        private void CopyFromProject_Click(object sender, EventArgs e)
        {
            InsertProjectForm2 frm = new InsertProjectForm2();

            if (_selnode != null)
            {
                string[] opis = GetNodeAttribute(_selnode);
                int      j    = opis.Length;
                // ==========
                // 07.12.2011
                frm.SetOpis(opis, projects, _selnode.Tag as Project);
            }

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                if (_app != null)
                {
                    frm.newProject.IsModify = true;

                    Project prj = frm.newProject;

                    if (prj.Stages.Count == 0)
                    {
                        ProjectStage stage = new ProjectStage();

                        stage.Koef      = 1;
                        stage.StageName = "Этап #1";

                        prj.Stages.Add(stage);
                    }

                    DateTime now = DateTime.Now;
                    prj.Created = now;
                    prj.Dir     = string.Format("{0:00}_{1:00}_{2:00}_{3:00}_{4:00}_{5:00}",
                                                now.Year,
                                                now.Month,
                                                now.Day,
                                                now.Hour,
                                                now.Minute,
                                                now.Second);
                    prj.DB_Name = string.Format("db_{0:00}_{1:00}_{2:00}_{3:00}_{4:00}_{5:00}",
                                                now.Year,
                                                now.Month,
                                                now.Day,
                                                now.Hour,
                                                now.Minute,
                                                now.Second);

                    prj.InternalNmb = projects.maxNmb + 1;
                    prj.IsModify    = true;
                    projects.AddProject(prj, true);
                    _app.Projects.Add(prj);

                    projects.SortByName();
                    BuildProjectsTreeView();
                    this.ShowSelNode();
                    this.treeViewProjects.Select();
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Добавить этап работы
        /// </summary>
        /// <param name="stage">добавляемый этап работы</param>
        protected void InsertStageInList(ProjectStage stage)
        {
            ListViewItem item = new ListViewItem((listViewStages.Items.Count + 1).ToString());

            ListViewItem.ListViewSubItem name = new ListViewItem.ListViewSubItem(item, stage.StageName);
            ListViewItem.ListViewSubItem koef = new ListViewItem.ListViewSubItem(item, stage.Koef.ToString());

            item.Tag = stage;

            item.SubItems.Add(name);
            item.SubItems.Add(koef);

            listViewStages.Items.Add(item);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Добавить этап работы
        /// </summary>
        /// <param name="stage">добавляемый этап работы</param>
        protected void InsertStageInList(ProjectStage stage)
        {
            ListViewItem item = new ListViewItem((listViewStages.Items.Count + 1).ToString());

            ListViewItem.ListViewSubItem name = new ListViewItem.ListViewSubItem(item, stage.StageName);
            ListViewItem.ListViewSubItem koef = new ListViewItem.ListViewSubItem(item, stage.Koef.ToString());

            item.Tag = stage;

            item.SubItems.Add(name);
            item.SubItems.Add(koef);

            listViewStages.Items.Add(item);
        }
Exemplo n.º 8
0
        /// <summary>
        /// редактируем этап
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void editStage_Click(object sender, EventArgs e)
        {
            if (listViewStages.SelectedItems != null &&
                listViewStages.SelectedItems.Count > 0)
            {
                ProjectStage selected = listViewStages.SelectedItems[0].Tag as ProjectStage;
                if (selected != null)
                {
                    InsertStageForm frm = new InsertStageForm();

                    frm.StageName = selected.StageName;
                    frm.StageKoef = selected.Koef;

                    frm.Plan_consumption = string.Format("{0:F2}", selected.Plan_consumption);
                    frm.Plan_volume      = string.Format("{0:F2}", selected.Plan_volume);

                    frm.Plan_density  = string.Format("{0:F2}", selected.Plan_density);
                    frm.Plan_pressure = string.Format("{0:F2}", selected.Plan_pressure);

                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        selected.Koef      = frm.StageKoef;
                        selected.StageName = frm.StageName;

                        try
                        {
                            selected.Plan_consumption = float.Parse(frm.Plan_consumption);
                            selected.Plan_volume      = float.Parse(frm.Plan_volume);

                            selected.Plan_density  = float.Parse(frm.Plan_density);
                            selected.Plan_pressure = float.Parse(frm.Plan_pressure);
                        }
                        catch { }

                        listViewStages.SelectedItems[0].SubItems[1].Text = selected.StageName;
                        listViewStages.SelectedItems[0].SubItems[2].Text = selected.Koef.ToString();
                    }
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// удаляем этап
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void removeStage_Click(object sender, EventArgs e)
        {
            if (listViewStages.SelectedItems != null &&
                listViewStages.SelectedItems.Count > 0)
            {
                foreach (ListViewItem s_item in listViewStages.SelectedItems)
                {
                    ProjectStage selected = s_item.Tag as ProjectStage;// listViewStages.SelectedItems[0].Tag as ProjectStage;
                    if (selected != null)
                    {
                        edited.Stages.Remove(selected);
                        listViewStages.Items.Remove(listViewStages.SelectedItems[0]);

                        int index = 1;
                        foreach (ListViewItem item in listViewStages.Items)
                        {
                            item.Text = index++.ToString();
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// добавить новый этап работы в проект
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addNewStage_Click(object sender, EventArgs e)
        {
            InsertStageForm frm = new InsertStageForm();
            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                ProjectStage stage = new ProjectStage();

                stage.Koef = frm.StageKoef;
                stage.StageName = frm.StageName;

                try
                {
                    stage.Plan_consumption = float.Parse(frm.Plan_consumption);
                    stage.Plan_volume = float.Parse(frm.Plan_volume);

                    stage.Plan_density = float.Parse(frm.Plan_density);
                    stage.Plan_pressure = float.Parse(frm.Plan_pressure);
                }
                catch { }

                edited.Stages.Add(stage);
                InsertStageInList(stage);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Выбрать проект для работы
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenProject_Click(object sender, EventArgs e)
        {
            if (treeViewProjects.SelectedNode != null)
            {
                TreeNode selected = treeViewProjects.SelectedNode;
                Project prj = selected.Tag as Project;

                if (prj != null)
                {
                    foreach (Project project in _app.Projects)
                    {
                        project.Actived = false;
                    }

                    prj.Actived = true;
                    if (prj.Stages.Count == 0)
                    {
                        ProjectStage stage = new ProjectStage();

                        stage.Koef = 1;
                        stage.StageName = "Этап #1";

                        prj.Stages.Add(stage);
                    }

                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
            }
            else
            {
                MessageBox.Show(this, "Выберите работу и повторите попытку",
                    "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 12
0
        private Application _app = null; // основное приложение

        #endregion Fields

        #region Constructors

        public StageViewForm(int s_index)
        {
            stage_index = s_index;
            InitializeComponent();

            _app = Application.CreateInstance();
            if (_app != null)
            {
                Project prj = _app.CurrentProject;
                if (prj != null)
                {
                    if (stage_index > -1 && stage_index < prj.Stages.Count)
                    {
                        sel_stage = prj.Stages[stage_index];
                        if (sel_stage != null)
                        {
                            manager = graphicsSheet1.InstanceManager();
                            manager.Mode = GraphicComponent.DrawMode.PassivScroll;

                            manager.HardTime = true;
                            manager.HardStartTime = sel_stage.StartTime;

                            manager.StartTime = sel_stage.StartTime;
                            manager.Orientation = GraphicComponent.Orientation.Horizontal;

                            graphics = new Graphic[5];
                            for (int index = 0; index < 5; index++)
                            {
                                graphics[index] = manager.InstanceGraphic();
                                switch (index)
                                {
                                    case 0:

                                        graphics[index].Color = _app.Graphic_consumption.Color;
                                        graphics[index].Description = _app.Graphic_consumption.Description;

                                        graphics[index].Range.Min = _app.Graphic_consumption.Range.Min;
                                        graphics[index].Range.Max = _app.Graphic_consumption.Range.Max;

                                        graphics[index].Units = _app.Graphic_consumption.Units;
                                        break;

                                    case 1:

                                        graphics[index].Color = _app.Graphic_volume.Color;
                                        graphics[index].Description = _app.Graphic_volume.Description;

                                        graphics[index].Range.Min = _app.Graphic_volume.Range.Min;
                                        graphics[index].Range.Max = _app.Graphic_volume.Range.Max;

                                        graphics[index].Units = _app.Graphic_volume.Units;
                                        break;

                                    case 2:

                                        graphics[index].Color = _app.Graphic_density.Color;
                                        graphics[index].Description = _app.Graphic_density.Description;

                                        graphics[index].Range.Min = _app.Graphic_density.Range.Min;
                                        graphics[index].Range.Max = _app.Graphic_density.Range.Max;

                                        graphics[index].Units = _app.Graphic_density.Units;
                                        break;

                                    case 3:

                                        graphics[index].Color = _app.Graphic_pressure.Color;
                                        graphics[index].Description = _app.Graphic_pressure.Description;

                                        graphics[index].Range.Min = _app.Graphic_pressure.Range.Min;
                                        graphics[index].Range.Max = _app.Graphic_pressure.Range.Max;

                                        graphics[index].Units = _app.Graphic_pressure.Units;
                                        break;

                                    case 4:

                                        graphics[index].Color = _app.Graphic_temperature.Color;
                                        graphics[index].Description = _app.Graphic_temperature.Description;

                                        graphics[index].Range.Min = _app.Graphic_temperature.Range.Min;
                                        graphics[index].Range.Max = _app.Graphic_temperature.Range.Max;

                                        graphics[index].Units = _app.Graphic_temperature.Units;
                                        break;

                                    default:
                                        break;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show(this, "", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Close();
            }
        }
Exemplo n.º 13
0
Arquivo: Form1.cs Projeto: slawer/skc
        /// <summary>
        /// тестово начали работу
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonStartWork_Click(object sender, EventArgs e)
        {
            try
            {
                switch (load_res)
                {
                    case loadResults.ProjectLoadedAndDBLoaded:

                        // ---- требуемы условия выполнены можно начинать работу ----

                        NewStagesTime = DateTime.Now;
                        ResetRgR();                             // сбросили объем в бксд
                        System.Threading.Thread.Sleep(500);     // ждем пока бксд обработает сброс объема

                        _app.Commutator.Technology.Stages.resetRGROn();
                        foreach (Rgr rgr in _app.Commutator.Technology.Rgrs)
                        {
                            rgr.Reset();
                            //rgr.CurrentVolume = 0.0f;
                        }

                        Project current = _app.CurrentProject;
                        if (current != null)
                        {
                            current.Worked = DateTime.Now;
                            foreach (ProjectStage stage in current.Stages)
                            {
                                stage.StageVolume = float.NaN;

                                stage.Min_volume = float.MaxValue;
                                stage.Max_volume = float.MinValue;

                                stage.StartTime = DateTime.MinValue;
                                stage.FinishTime = DateTime.MaxValue;
                            }

                            //InsertToListStagesWithClear(current);

                            if (current.Stages.Count == 0)
                            {
                                ProjectStage stage = new ProjectStage();

                                stage.Koef = 1.0f;

                                stage.StageVolume = float.NaN;
                                stage.StageName = string.Format("Этап работы 1");

                                current.Stages.Add(stage);
                            }

                            //toolStripLabelStageNumber.Text = string.Format("Этап {0}", 1);

                            //toolStripLabelStageName.Text = current.Stages[0].StageName;
                            toolStripTextBoxKoefs.Text = current.Stages[0].Koef.ToString();

                            toolStripStatusLabelWorkState.Text = "Идет работа";

                            buttonStartWork.Enabled = false;
                            buttonNewStage.Enabled = true;

                            checkBoxRgrTurner.Enabled = true;
                            buttonFinishWork.Enabled = true;

                            buttonRaport.Enabled = false;
                            рапортToolStripMenuItem.Enabled = false;

                            _app.Commutator.Technology.Stages.NextStage();
                            _app.Commutator.Technology.Stages.Current.NameStage = current.Stages[0].StageName;

                            try
                            {
                                current.Stages[_app.Commutator.Technology.Stages.Current.Number - 1].StartTime = _app.Commutator.Technology.Stages.Current.StartTime;
                                current.Stages[_app.Commutator.Technology.Stages.Current.Number - 1].FinishTime = DateTime.MaxValue;
                            }
                            catch { }

                            _app.SaveStages();

                            _app.Commutator.Technology.Stages.TotalVolume = 0.0f;
                            _app.Commutator.Technology.Stages.ProccessVolume = 0.0f;

                            _app.Commutator.Technology.Stages.UpdateKoef(current.Stages[0].Koef);

                            InsertToListStagesWithClear(current);
                            SetSelectStageInListStages();

                            _app.Save();
                        }

                        if (_app.AutoStartConsumption)
                        {
                            checkBoxRgrTurner.Checked = true;
                        }

                        break;

                    default:

                        ShowResultStatus(true);
                        break;
                }

                isFinished = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ErrorHandler.WriteToLog(this, new ErrorArgs(ex.Message, ErrorType.Unknown));
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Добавить этапы работы с активного проекта
        /// </summary>
        /// <param name="_prj"></param>
        protected void InsertStages(Project _prj)
        {
            try
            {
                Project prj = _app.CurrentProject;
                if (prj != null)
                {
                    foreach (ProjectStage stage in prj.Stages)
                    {
                        ProjectStage new_stage = new ProjectStage();

                        new_stage.StageName = stage.StageName;

                        new_stage.Koef = stage.Koef;

                        new_stage.Plan_consumption = stage.Plan_consumption;
                        new_stage.Plan_density = stage.Plan_density;

                        new_stage.Plan_pressure = stage.Plan_pressure;
                        new_stage.Plan_volume = stage.Plan_volume;

                        _prj.Stages.Add(new_stage);
                    }
                }
            }
            catch { }
        }
Exemplo n.º 15
0
        private void OpenProject_Click(object sender, EventArgs e)
        {
            if (_selnode.Tag == null)
            {
                MessageBox.Show(this, "Необходимо предварительно выбрать Задание", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Project prj = _selnode.Tag as Project;

            if (prj.Stages.Count == 0)
            {
                ProjectStage stage = new ProjectStage();

                stage.Koef = 1;
                stage.StageName = "Этап #1";

                prj.Stages.Add(stage);
            }

            if (_app != null)
            {
                for (int j = 0; j < _app.Projects.Count; j++)
                {
                    _app.Projects[j].Actived = false;
                }

                prj.Actived = true;
            }

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
Exemplo n.º 16
0
        /// <summary>
        /// Добавляем новый проект
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InsertNewProject_Click(object sender, EventArgs e)
        {
            InsertProjectForm2 frm = new InsertProjectForm2();

            if (_selnode != null)
            {
                string[] opis = GetNodeAttribute(_selnode);
                int j = opis.Length;
                // ==========
                // 07.12.2011
                frm.SetOpis(opis, projects, _selnode.Tag as Project);
            }

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                if (_app != null)
                {
                    frm.newProject.IsModify = true;

                    Project prj = frm.newProject;

                    prj.Stages.Clear();
                    ProjectStage stage = new ProjectStage();
                    stage.Koef = 1;
                    stage.StageName = "Этап #1";
                    prj.Stages.Add(stage);

                    DateTime now = DateTime.Now;
                    prj.Created = now;
                    prj.Dir = string.Format("{0:00}_{1:00}_{2:00}_{3:00}_{4:00}_{5:00}",
                        now.Year,
                        now.Month,
                        now.Day,
                        now.Hour,
                        now.Minute,
                        now.Second);
                    prj.DB_Name = string.Format("db_{0:00}_{1:00}_{2:00}_{3:00}_{4:00}_{5:00}",
                        now.Year,
                        now.Month,
                        now.Day,
                        now.Hour,
                        now.Minute,
                        now.Second);

                    prj.InternalNmb = projects.maxNmb + 1;
                    prj.IsModify = true;
                    projects.AddProject(prj, true);
                    _app.Projects.Add(prj);

                    projects.SortByName();
                    BuildProjectsTreeView();
                    this.ShowSelNode();
                    this.treeViewProjects.Select();
                }
            }
        }
Exemplo n.º 17
0
        public StageViewForm(int s_index)
        {
            stage_index = s_index;
            InitializeComponent();

            _app = Application.CreateInstance();
            if (_app != null)
            {
                Project prj = _app.CurrentProject;
                if (prj != null)
                {
                    if (stage_index > -1 && stage_index < prj.Stages.Count)
                    {
                        sel_stage = prj.Stages[stage_index];
                        if (sel_stage != null)
                        {
                            manager      = graphicsSheet1.InstanceManager();
                            manager.Mode = GraphicComponent.DrawMode.PassivScroll;

                            manager.HardTime      = true;
                            manager.HardStartTime = sel_stage.StartTime;

                            manager.StartTime   = sel_stage.StartTime;
                            manager.Orientation = GraphicComponent.Orientation.Horizontal;

                            graphics = new Graphic[5];
                            for (int index = 0; index < 5; index++)
                            {
                                graphics[index] = manager.InstanceGraphic();
                                switch (index)
                                {
                                case 0:

                                    graphics[index].Color       = _app.Graphic_consumption.Color;
                                    graphics[index].Description = _app.Graphic_consumption.Description;

                                    graphics[index].Range.Min = _app.Graphic_consumption.Range.Min;
                                    graphics[index].Range.Max = _app.Graphic_consumption.Range.Max;

                                    graphics[index].Units = _app.Graphic_consumption.Units;
                                    break;

                                case 1:

                                    graphics[index].Color       = _app.Graphic_volume.Color;
                                    graphics[index].Description = _app.Graphic_volume.Description;

                                    graphics[index].Range.Min = _app.Graphic_volume.Range.Min;
                                    graphics[index].Range.Max = _app.Graphic_volume.Range.Max;

                                    graphics[index].Units = _app.Graphic_volume.Units;
                                    break;

                                case 2:

                                    graphics[index].Color       = _app.Graphic_density.Color;
                                    graphics[index].Description = _app.Graphic_density.Description;

                                    graphics[index].Range.Min = _app.Graphic_density.Range.Min;
                                    graphics[index].Range.Max = _app.Graphic_density.Range.Max;

                                    graphics[index].Units = _app.Graphic_density.Units;
                                    break;

                                case 3:

                                    graphics[index].Color       = _app.Graphic_pressure.Color;
                                    graphics[index].Description = _app.Graphic_pressure.Description;

                                    graphics[index].Range.Min = _app.Graphic_pressure.Range.Min;
                                    graphics[index].Range.Max = _app.Graphic_pressure.Range.Max;

                                    graphics[index].Units = _app.Graphic_pressure.Units;
                                    break;

                                case 4:

                                    graphics[index].Color       = _app.Graphic_temperature.Color;
                                    graphics[index].Description = _app.Graphic_temperature.Description;

                                    graphics[index].Range.Min = _app.Graphic_temperature.Range.Min;
                                    graphics[index].Range.Max = _app.Graphic_temperature.Range.Max;

                                    graphics[index].Units = _app.Graphic_temperature.Units;
                                    break;

                                default:
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show(this, "", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Close();
            }
        }
Exemplo n.º 18
0
Arquivo: Form1.cs Projeto: slawer/skc
        /// <summary>
        /// новый этап работы
        /// </summary>
        /// <param name="sender">Источник события</param>
        /// <param name="e">Аргументы события</param>
        private void buttonNewStage_Click(object sender, EventArgs e)
        {
            try
            {
                switch (load_res)
                {
                    case loadResults.ProjectLoadedAndDBLoaded:

                        DateTime now = DateTime.Now;
                        TimeSpan interval = now - NewStagesTime;
                        if (interval.Ticks < intrvalNewStages.Ticks)
                        {
                            break;
                        }

                        Project current = _app.CurrentProject;
                        if (current != null)
                        {
                            NewStagesTime = DateTime.Now;

                            TechStage last = _app.Commutator.Technology.Stages.Current;
                            if (last != null)
                            {
                                ResetRgR();                             // сбросили объем в бксд
                                System.Threading.Thread.Sleep(500);     // ждем пока бксд обработает сброс объема

                                _app.Commutator.Technology.Stages.NextStage();
                                foreach (Rgr rgr in _app.Commutator.Technology.Rgrs)
                                {
                                    rgr.Reset();
                                }

                                //_app.Commutator.Technology.Rgr.Reset();

                                _app.SaveStages();

                                int stage_number = last.Number;
                                float stage_volume = last.Volume;

                                if (stage_number > -1 && stage_number <= current.Stages.Count)
                                {
                                    current.Stages[stage_number - 1].StageVolume = stage_volume;
                                }

                                int current_stage_number = _app.Commutator.Technology.Stages.Current.Number;
                                if (current_stage_number > -1 && current_stage_number > current.Stages.Count)
                                {
                                    // нету этапа в проектах
                                    ProjectStage stage = new ProjectStage();

                                    stage.Koef = 1.0f;

                                    stage.StageVolume = float.NaN;
                                    stage.StageName = string.Format("Этап работы {0}", current_stage_number);

                                    current.Stages.Add(stage);
                                }

                                _app.Commutator.Technology.Stages.UpdateKoef(current.Stages[current_stage_number - 1].Koef);

                                try
                                {
                                    current.Stages[_app.Commutator.Technology.Stages.Current.Number - 1].StartTime = _app.Commutator.Technology.Stages.Current.StartTime;
                                    current.Stages[_app.Commutator.Technology.Stages.Current.Number - 2].FinishTime = _app.Commutator.Technology.Stages.Current.StartTime;
                                }
                                catch { }

                                //toolStripLabelStageNumber.Text = string.Format("Этап {0}", current_stage_number);

                                //toolStripLabelStageName.Text = current.Stages[current_stage_number - 1].StageName;
                                _app.Commutator.Technology.Stages.Current.NameStage = current.Stages[current_stage_number - 1].StageName;

                                toolStripTextBoxKoefs.Text = current.Stages[current_stage_number - 1].Koef.ToString();

                                InsertToListStagesWithClear(current);
                                SetSelectStageInListStages();

                                _app.Save();
                            }
                        }

                        break;

                    default:

                        ShowResultStatus(true);
                        break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ErrorHandler.WriteToLog(this, new ErrorArgs(ex.Message, ErrorType.Unknown));
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Создать и выбрать новый проект
        /// </summary>
        public bool CreateNewAndSelectProject(Form frame)
        {
            try
            {
                InsertProjectForm2 frm = new InsertProjectForm2();

                if (_selnode != null)
                {
                    string[] opis = GetNodeAttribute(_selnode);
                    int      j    = opis.Length;
                    // ==========
                    // 07.12.2011
                    frm.SetOpis(opis, projects, _selnode.Tag as Project);
                }

                if (frm.ShowDialog(frame) == DialogResult.OK)
                {
                    if (_app != null)
                    {
                        frm.newProject.IsModify = true;

                        Project prj = frm.newProject;

                        prj.Stages.Clear();
                        ProjectStage stage = new ProjectStage();
                        stage.Koef      = 1;
                        stage.StageName = "Этап #1";
                        prj.Stages.Add(stage);

                        DateTime now = DateTime.Now;
                        prj.Created = now;
                        prj.Dir     = string.Format("{0:00}_{1:00}_{2:00}_{3:00}_{4:00}_{5:00}",
                                                    now.Year,
                                                    now.Month,
                                                    now.Day,
                                                    now.Hour,
                                                    now.Minute,
                                                    now.Second);
                        prj.DB_Name = string.Format("db_{0:00}_{1:00}_{2:00}_{3:00}_{4:00}_{5:00}",
                                                    now.Year,
                                                    now.Month,
                                                    now.Day,
                                                    now.Hour,
                                                    now.Minute,
                                                    now.Second);

                        prj.InternalNmb = projects.maxNmb + 1;
                        prj.IsModify    = true;
                        projects.AddProject(prj, true);
                        _app.Projects.Add(prj);

                        projects.SortByName();
                        BuildProjectsTreeView();
                        this.ShowSelNode();
                        this.treeViewProjects.Select();

                        OpenProject_Click(null, EventArgs.Empty);
                        return(true);
                    }
                }
            }
            catch { }
            return(false);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Сохранить прект в узел Xml
        /// </summary>
        /// <param name="doc">докумен для которого осуществляется сохранение проекта</param>
        /// <returns></returns>
        public void DeserializeFromXmlNode(XmlNode root)
        {
            try
            {
                if (root != null)
                {
                    if (root.Name == ProjectRootName)
                    {
                        if (root.HasChildNodes)
                        {
                            foreach (XmlNode child in root.ChildNodes)
                            {
                                switch (child.Name)
                                {
                                case "place":

                                    try
                                    {
                                        place = child.InnerText;
                                    }
                                    catch { }
                                    break;

                                case "bush":

                                    try
                                    {
                                        bush = child.InnerText;
                                    }
                                    catch { }
                                    break;

                                case "well":

                                    try
                                    {
                                        well = child.InnerText;
                                    }
                                    catch { }
                                    break;

                                case "job":

                                    try
                                    {
                                        job = child.InnerText;
                                    }
                                    catch { }
                                    break;

                                case "created":

                                    try
                                    {
                                        created = DateTime.Parse(child.InnerText);
                                    }
                                    catch { }
                                    break;

                                case "worked":

                                    try
                                    {
                                        worked = DateTime.Parse(child.InnerText);
                                    }
                                    catch { }
                                    break;

                                case "db_name":

                                    try
                                    {
                                        db_name = child.InnerText;
                                    }
                                    catch { }
                                    break;

                                case "actived":

                                    try
                                    {
                                        actived = bool.Parse(child.InnerText);
                                    }
                                    catch { }
                                    break;

                                case "dir":

                                    try
                                    {
                                        dir = child.InnerText;
                                    }
                                    catch { }
                                    break;

                                case "stages":

                                    try
                                    {
                                        if (child.HasChildNodes)
                                        {
                                            foreach (XmlNode s_child in child.ChildNodes)
                                            {
                                                if (s_child.Name == ProjectStage.StageRootName)
                                                {
                                                    ProjectStage stage = new ProjectStage();
                                                    stage.DeserializeFromXmlNode(s_child);

                                                    stages.Add(stage);
                                                }
                                            }
                                        }
                                    }
                                    catch { }
                                    break;

                                default:
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch { }
        }