Example #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            OBSD oBSD = db.OBSDs.Find(id);

            db.OBSDs.Remove(oBSD);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "Id,AdresId,TableServiceId,Nachislenie,Licevoi,Date")] OBSD oBSD)
 {
     if (ModelState.IsValid)
     {
         db.Entry(oBSD).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AdresId        = new SelectList(db.Adres, "Id", "Adress", oBSD.AdresId);
     ViewBag.TableServiceId = new SelectList(db.TableServices, "Id", "Type", oBSD.TableServiceId);
     return(View(oBSD));
 }
Example #3
0
        // GET: OBSDs/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OBSD oBSD = db.OBSDs.Find(id);

            if (oBSD == null)
            {
                return(HttpNotFound());
            }
            return(View(oBSD));
        }
Example #4
0
        // GET: OBSDs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OBSD oBSD = db.OBSDs.Find(id);

            if (oBSD == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AdresId        = new SelectList(db.Adres, "Id", "Adress", oBSD.AdresId);
            ViewBag.TableServiceId = new SelectList(db.TableServices, "Id", "Type", oBSD.TableServiceId);
            return(View(oBSD));
        }
Example #5
0
        public async void Poisk(List <List <string> > excel, DateTime Date, List <Adres> Adresa, List <TableService> Services)
        {
            int    progress = 0;
            double pro100   = 0;
            int    procount = 0;

            pro100 = excel.Count;
            OBSD        OBSDKA  = new OBSD();
            CultureInfo culture = new CultureInfo("en-US");
            //для каждой строки в экселе
            int lastadres = 0;
            int counter   = 0;

            foreach (List <string> L in excel)
            {
                counter++;
                bool   EstService = false;
                string ser        = L[2].Replace(" ", "").ToUpper();
                string adr        = L[0].Replace(" ", "").ToUpper();

                decimal Saldo  = 0;
                decimal Nach   = 0;
                bool    ignore = false;
                try
                {
                    Saldo = Convert.ToDecimal(L[5], culture);
                }
                catch
                {
                }
                try
                {
                    Nach = Convert.ToDecimal(L[3], culture);
                }
                catch
                {
                }

                if (Nach == 0 && Saldo == 0)
                {
                    ignore = true;
                }

                if (!ignore)//Если не игнорить то ищем
                {
                    try
                    {
                        OBSDKA.TableServiceId = Services.Where(x => x.Type.Equals(ser)).Select(x => x.Id).First();
                        EstService            = true;
                    }
                    catch
                    {
                    }
                    //     foreach (TableService S in Services)
                    //    {

                    //       if (S.Type.Equals(ser))
                    //       {
                    //           OBSDKA.TableServiceId = S.Id;
                    //           EstService = true;
                    //           break;
                    //       }
                    //   }
                }



                if (EstService)//если есть такой сервис
                {
                    bool nashli = false;

                    for (int A = lastadres; A < Adresa.Count; A++)
                    {
                        if (Adresa[A].Adress.Equals(adr))//и адрес совпал
                        {
                            //если в массиве адресов есть адрес из строчки то сохраняем айдишник

                            OBSDKA.AdresId = Adresa[A].Id;
                            lastadres      = A;
                            nashli         = true;
                            int licevoi = 0;
                            try
                            {
                                licevoi = Convert.ToInt32(L[1]);
                            }
                            catch
                            { }
                            OBSDKA.Licevoi = licevoi;
                            OBSDKA.Date    = Date;


                            OBSDKA.Nachislenie = Nach;
                            OBSDKA.Saldo       = Saldo;
                            OBSDKA.FIO         = L[4];
                            OBSDKA.Kvartira    = L[6];
                            using (WorkContext db = new WorkContext())
                            {
                                try//сохраняем в БД
                                {
                                    db.OBSDs.Add(OBSDKA);
                                    await db.SaveChangesAsync();
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine("Ошибка записи в базу данных " + e.Message);
                                }
                            }
                            // OBSDKA.Name = "";
                            break;
                        }
                    }
                    if (!nashli && lastadres > 0)//если адрес не нашли то продолжаем поиск с начала списка
                    {
                        for (int A = 0; A < lastadres; A++)
                        {
                            if (Adresa[A].Adress.Equals(adr))//и адрес совпал
                            {
                                //если в массиве адресов есть адрес из строчки то сохраняем айдишник

                                OBSDKA.AdresId = Adresa[A].Id;
                                lastadres      = A;
                                nashli         = true;
                                int licevoi = 0;
                                try
                                {
                                    licevoi = Convert.ToInt32(L[1]);
                                }
                                catch
                                { }
                                OBSDKA.Licevoi = licevoi;
                                OBSDKA.Date    = Date;


                                OBSDKA.Nachislenie = Nach;
                                OBSDKA.Saldo       = Saldo;
                                OBSDKA.FIO         = L[4];
                                OBSDKA.Kvartira    = L[6];

                                try//сохраняем в БД
                                {
                                    db.OBSDs.Add(OBSDKA);
                                    await db.SaveChangesAsync();
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine("Ошибка записи в базу данных " + e.Message);
                                }
                                // OBSDKA.Name = "";
                                break;
                            }
                        }
                    }
                }
                procount++;
                progress = Convert.ToInt16(50 + procount / pro100 * 50);
                ProgressHub.SendMessage("Обрабатываем файл ОБСД...", progress);
                if (procount > pro100)
                {
                    procount = Convert.ToInt32(pro100);
                }
            }
            List <string> Adr = Adresa.Select(x => x.Adress).ToList();

            for (int a = 0; a < Adr.Count; a++)
            {
                Adr[a] = Adr[a].Replace(" ", "").ToUpper();
            }
        }
Example #6
0
        public void FastPoisk(List <List <string> > excel, DateTime Date, List <Adres> Adresa, List <TableService> Services)
        {
            //упрощаем поиск
            List <Adres2> A2 = new List <Adres2>();

            foreach (Adres A in Adresa)
            {
                Adres2 AA = new Adres2();
                AA.Adres = A.Adress;
                AA.id    = A.Id;
                A2.Add(AA);
            }
            int    progress = 0;
            double pro100   = 0;
            int    procount = 0;

            pro100 = excel.Count;

            CultureInfo culture = new CultureInfo("en-US");
            //для каждой строки в экселе
            int counter = 0;

            foreach (List <string> L in excel)
            {
                OBSD OBSDKA = new OBSD();
                counter++;
                bool   EstService = false;
                string ser        = L[2].Replace(" ", "").ToUpper();
                string adr        = L[0].Replace(" ", "").ToUpper();

                decimal Saldo  = 0;
                decimal Nach   = 0;
                bool    ignore = false;
                try
                {
                    Saldo = Convert.ToDecimal(L[5], culture);
                }
                catch
                {
                }
                try
                {
                    Nach = Convert.ToDecimal(L[3], culture);
                }
                catch
                {
                }

                if (Nach == 0 && Saldo == 0)
                {
                    ignore = true;
                }

                if (!ignore)//Если не игнорить то ищем
                {
                    try
                    {
                        OBSDKA.TableServiceId = Services.Where(x => x.Type.Equals(ser)).Select(x => x.Id).First();
                        EstService            = true;
                    }
                    catch
                    {
                    }
                    //     foreach (TableService S in Services)
                    //    {

                    //       if (S.Type.Equals(ser))
                    //       {
                    //           OBSDKA.TableServiceId = S.Id;
                    //           EstService = true;
                    //           break;
                    //       }
                    //   }
                }



                if (EstService)//если есть такой сервис
                {
                    try
                    {
                        OBSDKA.AdresId = A2.Where(x => x.Adres.Equals(adr)).Select(x => x.id).First();

                        int licevoi = 0;
                        try
                        {
                            licevoi = Convert.ToInt32(L[1]);
                        }
                        catch
                        { }
                        OBSDKA.Licevoi     = licevoi;
                        OBSDKA.Date        = Date;
                        OBSDKA.Nachislenie = Nach;
                        OBSDKA.Saldo       = Saldo;
                        OBSDKA.FIO         = L[4];
                        OBSDKA.Kvartira    = L[6];
                        db.OBSDs.Add(OBSDKA);
                        db.SaveChanges();
                    }
                    catch
                    {
                    }
                }

                procount++;
                progress = Convert.ToInt16(50 + procount / pro100 * 50);
                ProgressHub.SendMessage("Обрабатываем файл ОБСД...", progress);
                if (procount > pro100)
                {
                    procount = Convert.ToInt32(pro100);
                }
            }
            List <string> Adr = Adresa.Select(x => x.Adress).ToList();

            for (int a = 0; a < Adr.Count; a++)
            {
                Adr[a] = Adr[a].Replace(" ", "").ToUpper();
            }
        }