Пример #1
0
 //нажата кнопка добавить новое покрытие
 private void button1_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(tb_TypeCoating.Text))
     {
         MessageBox.Show("Тип покрытия не задано !");
     }
     else
     {
         double d;
         if (double.TryParse(tb_Coefficient.Text, out d))
         {
             if (c == null)
             {
                 c = new Coating(tb_TypeCoating.Text, d);
             }
             else
             {
                 c.TypeName = tb_TypeCoating.Text;
                 c.Coeff    = d;
             }
             if (addOrEdit)
             {
                 Add();
             }
             else
             {
                 Edit();
             }
         }
         else
         {
             MessageBox.Show("Не корректно задан коэффициент !");
         }
     }
 }
Пример #2
0
        public CoatingForm(string tCoating, double coeff) : this(false)
        {
            coating = Coating.CreateCoating(tCoating, coeff);

            textBoxTypeCoating.Text = tCoating;
            ID = tCoating;

            textBoxCoefficient.Text = coeff.ToString();
        }
Пример #3
0
 /// <summary>
 /// Создание дуги. Фабрика.
 /// </summary>
 /// <param name="ID">ID</param>
 /// <param name="head">Исходная вершина</param>
 /// <param name="end">Конечная вершина</param>
 /// <param name="coat">Дорожное покрытие</param>
 /// <param name="name">Название улицы</param>
 /// <param name="isBelaterial">Дусторонняя дорога</param>
 /// <param name="signMaxSpeed">Знак ограничения скорости</param>
 /// <param name="polieceman">Полицейский</param>
 /// <returns></returns>
 public static Edge CreateEdge(long ID, Vertex head, Vertex end, Coating coat, string name, bool isBelaterial, Sign signMaxSpeed, Police polieceman)
 {
     return(new Edge
     {
         ID = ID,
         HeadVertex = head,
         EndVertex = end,
         NameStreet = name,
         Coat = coat,
         IsBilateral = isBelaterial,
         SignMaxSpeed = signMaxSpeed,
         Policemen = polieceman
     });
 }
Пример #4
0
        public void ReadCoatings()
        {
            string           startupPath = Environment.CurrentDirectory;
            IExcelDataReader excelReader = ReadExcel(startupPath + @"\BelaegningsTyper.xlsx");

            //excelReader.IsFirstRowAsColumnNames = true;
            excelReader.Read();
            while (excelReader.Read())
            {
                Coating coating = new Coating();
                coating.name   = excelReader.GetString(0);
                coating.factor = excelReader.GetDouble(1);

                Coatings.Add(coating);
            }

            excelReader.Close();
        }
Пример #5
0
        private void Accept()
        {
            textBoxTypeCoating.BackColor = Color.White;

            string type = textBoxTypeCoating.Text;
            double d;

            if (string.IsNullOrWhiteSpace(type) || string.IsNullOrEmpty(type))
            {
                MessageBox.Show("Тип покрытия не задан!");
                textBoxTypeCoating.BackColor = Color.Red;
            }
            else
            {
                if (double.TryParse(textBoxCoefficient.Text, out d))
                {
                    if (d > 1 || d == 0)
                    {
                        MessageBox.Show("Допустимый диапазон коэффициента: (0,1]!");
                    }
                    else
                    {
                        if (coating == null)
                        {
                            coating = new Coating(type, d);
                        }
                        else
                        {
                            coating.TypeName = type;
                            coating.Coeff    = d;
                        }

                        if (addOrEdit)
                        {
                            Add();
                        }
                        else
                        {
                            Edit();
                        }
                    }
                }
            }
        }
Пример #6
0
        string AddGrade(ref uos uos)
        {
            Grade g = new Grade();

            g.id = GenerateId();

            Coating c = new Coating();

            c.id              = GenerateId();
            c.Coating_name    = "TiAlN";
            c.Coating_process = "Coating_process";
            uos.Coating       = AddElement(uos.Coating, c);


            Substrate s = new Substrate();

            s.id          = GenerateId();
            s.Name        = "WC";
            uos.Substrate = AddElement(uos.Substrate, s);

            Material_designation m = new Material_designation();

            m.id                     = GenerateId();
            m.Material_name          = "P";
            uos.Material_designation = AddElement(uos.Material_designation, m);

            g.Coating         = new Coating[1];
            g.Coating[0]      = new Coating();
            g.Coating[0].@ref = c.id;

            g.Substrate         = new Substrate[1];
            g.Substrate[0]      = new Substrate();
            g.Substrate[0].@ref = s.id;

            g.Workpiece_material         = new Material_designation[1];
            g.Workpiece_material[0]      = new Material_designation();
            g.Workpiece_material[0].@ref = m.id;

            uos.Grade = AddElement(uos.Grade, g);
            return(g.id);
        }
Пример #7
0
        public bool Insert(object obj)
        {
            try
            {
                Coating c = (Coating)obj;
                new SQLiteCommand(string.Format("Insert into Surface values ('{0}', {1})", c.TypeName.ToLower(), c.Coeff.ToString().Replace(',', '.')), DAO.GetConnection()).ExecuteNonQuery();

                List <object> list = new List <object>
                {
                    c.TypeName.ToLower(),
                              c.Coeff
                };
                Coating.ListSurface.Add(list);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #8
0
        public bool Update(object obj, string ID)
        {
            bool flag = true;

            try
            {
                List <List <object> > list = GetAll("Edge");
                list.ForEach((e) =>
                {
                    if (e[6].ToString().Equals(ID))
                    {
                        flag = false;
                    }
                });

                if (!flag)
                {
                    return(false);
                }

                Coating c = (Coating)obj;
                new SQLiteCommand(string.Format("UPDATE Surface SET [NameSurface] = '{0}', [KoefSurface] = {1} where NameSurface = '{2}'", c.TypeName.ToLower(), c.Coeff.ToString().Replace(',', '.'), ID), DAO.GetConnection()).ExecuteNonQuery();

                var updatedCoating = Coating.ListSurface.FirstOrDefault(l => l.ElementAt(0).ToString().ToLower().Equals(ID.ToLower()));
                if (updatedCoating != null)
                {
                    updatedCoating[0] = c.TypeName.ToLower();
                    updatedCoating[1] = c.Coeff;
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #9
0
 //Конструктор
 public CoatingForm(int id, string tCoating, double coeff) : this(false)
 {
     c = new Coating(id, tCoating, coeff);
     tb_TypeCoating.Text = tCoating;
     tb_Coefficient.Text = coeff.ToString();
 }
Пример #10
0
        private void OkEditEgdeButton_Click(object sender, EventArgs e)
        {
            if (nameStreetComboBox.SelectedItem == null)
            {
                MessageBox.Show("Выберите название улицы");
                return;
            }
            else if (coatingComboBox.SelectedItem == null)
            {
                MessageBox.Show("Выберите покрытие");
                return;
            }
            else
            {
                bool isPolice = policemanCheckBox.Checked;

                if (isPolice)
                {
                    if (policemanComboBox.SelectedItem == null)
                    {
                        MessageBox.Show("Выберите полицейского");
                        return;
                    }
                }

                bool isSignMaxSpeed = signMaxSpeedCheckBox.Checked;

                if (isSignMaxSpeed)
                {
                    if (signMaxSpeedComboBox.SelectedItem == null)
                    {
                        MessageBox.Show("Выберите знак");
                        return;
                    }
                }

                if (isPolice)
                {
                    Edge.Policemen = Police.CreatePolice(policemanComboBox.SelectedItem.ToString());
                }
                else
                {
                    Edge.Policemen = null;
                }

                if (isSignMaxSpeed)
                {
                    List <object> sign = Sign.ListSigns.First(sg => int.Parse(sg[0].ToString()) == int.Parse(signMaxSpeedComboBox.SelectedItem.ToString()));
                    Edge.SignMaxSpeed = Sign.CreateSign(int.Parse(sign[0].ToString()));
                }
                else
                {
                    Edge.SignMaxSpeed = null;
                }

                Edge.NameStreet = nameStreetComboBox.SelectedItem.ToString();

                List <object> coat = Coating.ListSurface.First(coating => coating[0].ToString().Equals(coatingComboBox.SelectedItem.ToString()));
                Edge.Coat = Coating.CreateCoating(coat[0].ToString(), double.Parse(coat[1].ToString()));

                Edge.IsBilateral = !signOneWayCheckBox.Checked;
            }

            DialogResult = DialogResult.OK;
            MakeMap.ViewPort.Invalidate();
            Close();
        }