Beispiel #1
0
        public void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                timer1.Interval = 10000;
                List <PhoneObj> AccidentList = new List <PhoneObj>();
                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 != "")
                {
                    PhoneObj.AccidentList = AccidentList.GetRange(0, AccidentList.Count);
                    ListViewCompleting(sender, e);
                }
                if (!PhoneObj.GetHash(AccidentList, PhoneObj.AccidentList))
                {
                    PhoneObj.AccidentList = AccidentList.GetRange(0, AccidentList.Count);
                    ListViewCompleting(sender, e);
                }
            }
            catch (Exception e1)
            {
                myException = new MyException(e1);
            }
        }
Beispiel #2
0
        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;
                }
                //находим по времени происшествие
                PhoneObj obj = new PhoneObj();
                foreach (var var in PhoneObj.AccidentList)
                {
                    if (var.DataTime == selected)
                    {
                        obj = var;
                    }
                }
                PhoneObj.DeleteAccident(obj);
            }
            catch (Exception e1)
            {
                myException = new MyException(e1);
            }
        }
Beispiel #3
0
 static void Main()
 {
     PhoneObj.CreateTable();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new Form1());
 }
        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)
            {
                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 (Form1.Button == "Add")
            {
                PhoneObj.AddAccident(new PhoneObj(district, textBox_Adress.Text, richTextBox1.Text, textBox_time.Text));
            }
            if (Form1.Button == "Edit")
            {
                PhoneObj.ChangeAccident(PhoneObj.ObjAccident, new PhoneObj(district, textBox_Adress.Text, richTextBox1.Text, textBox_time.Text));
            }
            Close();
        }
Beispiel #5
0
 /// <summary>
 /// Добавление происшествия
 /// </summary>
 /// <param name="district">Район</param>
 /// <param name="adress">Адрес</param>
 /// <param name="accident">Происшествие</param>
 /// <param name="timeAccident">Время происшествия</param>
 public static void AddAccident(PhoneObj accident)
 {
     try
     {
         using (AccidentContext db = new AccidentContext())
         {
             db.Accidents.Add(accident);
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         myException = new MyException(e);
     }
 }
Beispiel #6
0
 /// <summary>
 /// создание таблицы
 /// </summary>
 public static void CreateTable()
 {
     try
     {
         using (AccidentContext db = new AccidentContext())
         {
             PhoneObj accident = new PhoneObj("", "", "", "");
             db.Accidents.Add(accident);
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         myException = new MyException(e);
     }
 }
Beispiel #7
0
        /// <summary>
        /// Удаление происшествия
        /// </summary>
        /// <param name="objAccident"></param>
        public static void DeleteAccident(PhoneObj 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;
        }
Beispiel #8
0
        public static void ChangeAccident(PhoneObj oldAccident, PhoneObj 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);
        }
Beispiel #9
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[] { ';' });
                            PhoneObj accident = new PhoneObj();
                            accident.DataTime         = Loads[1];
                            accident.Street           = Loads[2];
                            accident.Accident         = Loads[3];
                            accident.DateCall         = 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);
            }
        }