Exemple #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);
     }
 }
Exemple #2
0
        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);
            }
        }
Exemple #3
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);
     }
 }
Exemple #4
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);
     }
 }
Exemple #5
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;
 }
Exemple #6
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);
 }
Exemple #7
0
 public StoryForm()
 {
     InitializeComponent();
     try
     {
         AccidentHistoryList = new List <AccidentObj>();
         using (AccidentContext db = new AccidentContext())
         {
             var accidents = db.Accidents;
             foreach (var VARIABLE in accidents)
             {
                 AccidentHistoryList.Add(VARIABLE);
             }
         }
     }
     catch (Exception e1)
     {
         myException = new MyException(e1);
     }
     CreateHeadersAndFillListView();
 }
Exemple #8
0
        /// <summary>
        /// событие заполнения ListView
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ListViewCompleting(object sender, EventArgs e)
        {
            try
            {
                ListViewItem lvi;
                ListViewItem.ListViewSubItem lvsi;
                string t = sender.ToString();
                switch (t)
                {
                case "System.Windows.Forms.Button, Text: ЮГ":
                    if (_buttonSouthEnabled)
                    {
                        button_South.BackColor = System.Drawing.Color.White;
                        _buttonSouthEnabled    = false;
                    }
                    else
                    {
                        button_South.BackColor = System.Drawing.Color.Red;
                        _buttonSouthEnabled    = true;
                    }
                    break;

                case "System.Windows.Forms.Button, Text: СЕВЕР":
                    if (_buttonNordEnabled)
                    {
                        button_Nord.BackColor = System.Drawing.Color.White;
                        _buttonNordEnabled    = false;
                    }
                    else
                    {
                        button_Nord.BackColor = System.Drawing.Color.Aqua;
                        _buttonNordEnabled    = true;
                    }
                    break;

                case "System.Windows.Forms.Button, Text: ЗАО":
                    if (_buttonVasEnabled)
                    {
                        button_Vas.BackColor = System.Drawing.Color.White;
                        _buttonVasEnabled    = false;
                    }
                    else
                    {
                        button_Vas.BackColor = System.Drawing.Color.Green;
                        _buttonVasEnabled    = true;
                    }
                    break;

                case "System.Windows.Forms.Button, Text: ЖКС3":
                    if (_buttonGks3Enabled)
                    {
                        button_GKS3.BackColor = System.Drawing.Color.White;
                        _buttonGks3Enabled    = false;
                    }
                    else
                    {
                        button_GKS3.BackColor = System.Drawing.Color.Yellow;
                        _buttonGks3Enabled    = true;
                    }
                    break;

                case "System.Windows.Forms.Button, Text: ЛИФТЫ":
                    if (_buttonElevEnabled)
                    {
                        button_Elev.BackColor = System.Drawing.Color.White;
                        _buttonElevEnabled    = false;
                    }
                    else
                    {
                        button_Elev.BackColor = System.Drawing.Color.DarkOrange;
                        _buttonElevEnabled    = true;
                    }
                    break;

                case "System.Windows.Forms.Button, Text: ИНФО":
                    if (_buttonInfoEnabled)
                    {
                        button_Info.BackColor = System.Drawing.Color.White;
                        _buttonInfoEnabled    = false;
                    }
                    else
                    {
                        button_Info.BackColor = System.Drawing.Color.Pink;
                        _buttonInfoEnabled    = true;
                    }
                    break;

                default:
                    break;
                }
                listViewAccident.Items.Clear();
                if (AccidentObj.AccidentList == null)
                {
                    return;
                }
                using (AccidentContext db = new AccidentContext())
                {
                    List <string> districtList = new List <string>();
                    if (_buttonGks3Enabled)
                    {
                        districtList.Add("ЖКС3");
                    }
                    if (_buttonNordEnabled)
                    {
                        districtList.Add("СЕВЕР");
                    }
                    if (_buttonSouthEnabled)
                    {
                        districtList.Add("ЮГ");
                    }
                    if (_buttonVasEnabled)
                    {
                        districtList.Add("ЗАО");
                    }
                    if (_buttonElevEnabled)
                    {
                        districtList.Add("ЛИФТЫ");
                    }
                    if (_buttonInfoEnabled)
                    {
                        districtList.Add("ИНФО");
                    }
                    var accidents = AccidentObj.AccidentList.Where(p => districtList.Contains(p.District));
                    for (int i = 0; i < accidents.Count(); i++)
                    {
                        lvi = new ListViewItem();
                        ChangeFont(lvi);
                        lvi.Text = accidents.ElementAt(i).DataTime;

                        lvsi = new ListViewItem.ListViewSubItem();
                        ChangeFont(lvi);
                        lvsi.Text = accidents.ElementAt(i).Adress;
                        lvi.SubItems.Add(lvsi);

                        lvsi = new ListViewItem.ListViewSubItem();
                        ChangeFont(lvi);
                        lvsi.Text = accidents.ElementAt(i).Accident;
                        lvi.SubItems.Add(lvsi);

                        lvsi = new ListViewItem.ListViewSubItem();
                        ChangeFont(lvi);
                        lvsi.Text = accidents.ElementAt(i).TimeAccident;
                        lvi.SubItems.Add(lvsi);

                        lvsi = new ListViewItem.ListViewSubItem();
                        ChangeFont(lvi);
                        lvsi.Text = accidents.ElementAt(i).AddDispetcher;
                        lvi.SubItems.Add(lvsi);

                        listViewAccident.Items.Add(lvi);
                    }
                    SizeFont = "";
                }
            }
            catch (Exception e1)
            {
                myException = new MyException(e1);
            }
        }