コード例 #1
0
 public static void UploadTable(string path)
 {
     try
     {
         string[] Load = File.ReadAllLines(path);
         using (AccidentContext db = new AccidentContext())
         {
             foreach (var VARIABLE in Load)
             {
                 try
                 {
                     string[]    Loads    = VARIABLE.Split(new char[] { ';' });
                     AccidentObj accident = new AccidentObj();
                     accident.DataTime         = Loads[1];
                     accident.Adress           = Loads[2];
                     accident.Accident         = Loads[3];
                     accident.TimeAccident     = Loads[4];
                     accident.AddDispetcher    = Loads[5];
                     accident.RemoveDispetcher = Loads[6];
                     accident.Computer         = Loads[7];
                     accident.District         = Loads[8];
                     accident.Kind             = Loads[9];
                     db.Accidents.Add(accident);
                 }
                 catch {}
             }
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         myException = new MyException(e);
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: polsok/InteractiveTable
        public void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                timer1.Interval = 10000;
                List <AccidentObj> AccidentList = new List <AccidentObj>();
                using (AccidentContext db = new AccidentContext())
                {
                    var kinds     = new[] { "Удален", "Изменен" };
                    var accidents = db.Accidents.Where(p => !kinds.Contains(p.Kind));
                    foreach (var VARIABLE in accidents)
                    {
                        AccidentList.Add(VARIABLE);
                    }
                }

                if (SizeFont != "")
                {
                    AccidentObj.AccidentList = AccidentList.GetRange(0, AccidentList.Count);
                    ListViewCompleting(sender, e);
                }
                if (!AccidentObj.GetHash(AccidentList, AccidentObj.AccidentList))
                {
                    AccidentObj.AccidentList = AccidentList.GetRange(0, AccidentList.Count);
                    ListViewCompleting(sender, e);
                }
            }
            catch (Exception e1)
            {
                myException = new MyException(e1);
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: polsok/InteractiveTable
        private void button_Del_Click(object sender, EventArgs e)
        {
            try
            {
                string selected = "";
                foreach (ListViewItem item in listViewAccident.SelectedItems)
                {
                    selected = item.Text;
                }

                if (selected == "")
                {
                    MessageBox.Show("Выберете что удалять");
                    return;
                }
                //находим по времени происшествие
                AccidentObj obj = new AccidentObj();
                foreach (var var in AccidentObj.AccidentList)
                {
                    if (var.DataTime == selected)
                    {
                        obj = var;
                    }
                }
                AccidentObj.DeleteAccident(obj);
            }
            catch (Exception e1)
            {
                myException = new MyException(e1);
            }
        }
コード例 #4
0
 /// <summary>
 /// Добавление происшествия
 /// </summary>
 /// <param name="district">Район</param>
 /// <param name="adress">Адрес</param>
 /// <param name="accident">Происшествие</param>
 /// <param name="timeAccident">Время происшествия</param>
 public static void AddAccident(AccidentObj accident)
 {
     try
     {
         using (AccidentContext db = new AccidentContext())
         {
             db.Accidents.Add(accident);
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         myException = new MyException(e);
     }
 }
コード例 #5
0
 /// <summary>
 /// создание таблицы
 /// </summary>
 public static void CreateTable()
 {
     try
     {
         using (AccidentContext db = new AccidentContext())
         {
             AccidentObj accident = new AccidentObj("", "", "", "");
             db.Accidents.Add(accident);
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         myException = new MyException(e);
     }
 }
コード例 #6
0
 /// <summary>
 /// Удаление происшествия
 /// </summary>
 /// <param name="objAccident"></param>
 public static void DeleteAccident(AccidentObj accident)
 {
     try
     {
         using (AccidentContext db = new AccidentContext())
         {
             var accidents = db.Accidents.Where(p => p.DataTime == accident.DataTime);
             accidents.FirstOrDefault().Kind             = "Удален";
             accidents.FirstOrDefault().RemoveDispetcher = Environment.UserName;
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         myException = new MyException(e);
     }
     Transfer = true;
 }
コード例 #7
0
 public static void ChangeAccident(AccidentObj oldAccident, AccidentObj newAccident)
 {
     try
     {
         using (AccidentContext db = new AccidentContext())
         {
             var accidents = db.Accidents.Where(p => p.DataTime == oldAccident.DataTime);
             accidents.FirstOrDefault().Kind             = "Изменен";
             accidents.FirstOrDefault().RemoveDispetcher = Environment.UserName;
             db.Accidents.Add(newAccident);
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         myException = new MyException(e);
     }
     Transfer = true;
     //AccidentList = copyAccidents.GetRange(0, copyAccidents.Count);
 }
コード例 #8
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            //проверяем что все поля заполнены
            if (radioButton_GKS3.Checked != true && radioButton_North.Checked != true &&
                radioButton_South.Checked != true && radioButton_ZAO.Checked != true &&
                radioButton_ELEV.Checked != true && radioButton_INFO.Checked != true)
            {
                MessageBox.Show("Не выбран район");
                return;
            }

            if (textBox_Adress.Text.Length < 5)
            {
                MessageBox.Show("Не указан адрес");
                return;
            }

            if (richTextBox1.Text.Length < 5)
            {
                MessageBox.Show("Не указано происшествие");
                return;
            }

            if (textBox_time.Text.Length < 3)
            {
                MessageBox.Show("Не указано время");
                return;
            }

            string district = "";

            if (radioButton_ZAO.Checked == true)
            {
                district = "ЗАО";
            }
            if (radioButton_GKS3.Checked == true)
            {
                district = "ЖКС3";
            }
            if (radioButton_North.Checked == true)
            {
                district = "СЕВЕР";
            }
            if (radioButton_South.Checked == true)
            {
                district = "ЮГ";
            }
            if (radioButton_ELEV.Checked == true)
            {
                district = "ЛИФТЫ";
            }
            if (radioButton_INFO.Checked == true)
            {
                district = "ИНФО";
            }

            if (Form1.Button == "Add")
            {
                AccidentObj.AddAccident(new AccidentObj(district, textBox_Adress.Text, richTextBox1.Text, textBox_time.Text));
            }
            if (Form1.Button == "Edit")
            {
                AccidentObj.ChangeAccident(AccidentObj.ObjAccident, new AccidentObj(district, textBox_Adress.Text, richTextBox1.Text, textBox_time.Text));
            }
            Close();
        }