public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Dogovor dogovor)
        {
            if (id != dogovor.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dogovor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DogovorExists(dogovor.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(dogovor));
        }
Beispiel #2
0
        public void CreateOrUpdate(DogovorBindingModel model)
        {
            using (var context = new KursachDatabase())
            {
                Dogovor element = context.Dogovors.FirstOrDefault(rec => rec.Id != model.Id);

                if (model.Id.HasValue)
                {
                    element = context.Dogovors.FirstOrDefault(rec => rec.Id == model.Id);
                    if (element == null)
                    {
                        throw new Exception("Склад не найден");
                    }
                }
                else
                {
                    element = new Dogovor();
                    context.Dogovors.Add(element);
                    element.ClientId = model.ClientId;
                    element.AgentId  = model.AgentId;
                    element.data     = model.data;
                }
                element.Summa = model.Summa;
                context.SaveChanges();
            }
        }
Beispiel #3
0
 //
 public void CreateDogovor(Dogovor model)
 {
     try
     {
         using (var ctx = new Entities())
         {
             string        query         = "INSERT INTO Dogovor (IDKl, IDAg, IDTr, Date, IDGroup, Described) VALUES(@P0, @P1, @P2, @P3, @P4, @P5)";
             List <object> parameterList = new List <object> {
                 model.IDKl,
                 model.IDAg,
                 model.IDTr,
                 model.Date,
                 model.IDGroup,
                 model.Described
             };
             object[] parameters = parameterList.ToArray();
             int      result     = ctx.Database.ExecuteSqlCommand(query, parameters);
             Logger.Log.Info("Данные успешно добавлены в Dogovor");
         }
     }
     catch (Exception ex)
     {
         Logger.Log.Error("Ошибка: ", ex);
     }
 }
Beispiel #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Dogovor dogovor = db.Dogovor.Find(id);

            db.Dogovor.Remove(dogovor);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #5
0
        public ActionResult Reject(int id)
        {
            Dogovor dogovor = dogovorDAO.getDogovor(id);

            dogovor.IDGroup = 4;
            dogovorDAO.UpdateGroup(dogovor);
            return(RedirectToAction("Index"));
        }
Beispiel #6
0
        public ActionResult Create(string id)
        {
            var tarif = new SelectList(tarifDAO.GetAllTarif(), "Id", "Object");

            ViewData["IDTr"] = tarif;
            Dogovor dogovor = new Dogovor();

            return(View(dogovor));
        }
Beispiel #7
0
        public ActionResult Edit(int id)
        {
            Dogovor Dogov = dogovorDAO.getDogovor(id);

            if (!ViewDataSelectList(Dogov.GroupDog.Id))
            {
                return(RedirectToAction("MyObject"));
            }
            return(View(dogovorDAO.getDogovor(id)));
        }
Beispiel #8
0
        public ActionResult Reject(int id)
        {
            Dogovor dogovor = dogovorDAO.getDogovor(id);
            string  userId  = User.Identity.GetUserId();

            dogovor.IDAg    = userId;
            dogovor.IDGroup = 4;
            dogovorDAO.UpdateGroup(dogovor);
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Create([Bind("Id,Name")] Dogovor dogovor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dogovor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dogovor));
        }
Beispiel #10
0
 public ActionResult Edit([Bind(Include = "id_Dog,Id_Request")] Dogovor dogovor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dogovor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Id_Request = new SelectList(db.Reqyests, "Id_Request", "Description", dogovor.Id_Request);
     return(View(dogovor));
 }
Beispiel #11
0
        public ActionResult Create([Bind(Include = "id_Dog,Id_Request")] Dogovor dogovor)
        {
            if (ModelState.IsValid)
            {
                db.Dogovor.Add(dogovor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Id_Request = new SelectList(db.Reqyests, "Id_Request", "Description", dogovor.Id_Request);
            return(View(dogovor));
        }
Beispiel #12
0
        // GET: Dogovors/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dogovor dogovor = db.Dogovor.Find(id);

            if (dogovor == null)
            {
                return(HttpNotFound());
            }
            return(View(dogovor));
        }
Beispiel #13
0
        // GET: Dogovors/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dogovor dogovor = db.Dogovor.Find(id);

            if (dogovor == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id_Request = new SelectList(db.Reqyests, "Id_Request", "Description", dogovor.Id_Request);
            return(View(dogovor));
        }
Beispiel #14
0
 public bool UpdateGroup(Dogovor dogovor)
 {
     try
     {
         var Entity = _entities.Dogovor.FirstOrDefault(x => x.Id == dogovor.Id);
         Entity.IDGroup = dogovor.IDGroup;
         Entity.IDAg    = dogovor.IDAg;
         _entities.SaveChanges();
     }
     catch (Exception ex)
     {
         Logger.Log.Error("Ошибка: ", ex);
         return(false);
     }
     return(true);
 }
Beispiel #15
0
        public bool deleteDogovor(int Id)
        {
            Dogovor originalRecords = getDogovor(Id);

            try
            {
                _entities.Dogovor.Remove(originalRecords);
                _entities.SaveChanges();
            }
            catch (Exception ex)
            {
                Logger.Log.Error("Ошибка: ", ex);
                return(false);
            }
            return(true);
        }
Beispiel #16
0
        public void Delete(DogovorBindingModel model)
        {
            using (var context = new KursachDatabase())
            {
                Dogovor element = context.Dogovors.FirstOrDefault(rec => rec.Id == model.Id);

                if (element != null)
                {
                    context.Dogovors.Remove(element);
                    context.SaveChanges();
                }
                else
                {
                    throw new Exception("Элемент не найден");
                }
            }
        }
Beispiel #17
0
        public ActionResult Create(Dogovor model)
        {
            var tarif = new SelectList(tarifDAO.GetAllTarif(), "Id", "Object");

            ViewData["IDTr"] = tarif;
            string userId = User.Identity.GetUserId();

            model.IDKl = userId;
            try
            {
                dogovorDAO.CreateDogovor(model);
                return(RedirectToAction("MyObject"));
            }
            catch (Exception ex)
            {
                Logger.Log.Error("Ошибка: ", ex);
            }
            return(RedirectToAction("Create"));
        }
Beispiel #18
0
 public ActionResult Delete(int id, Dogovor Dogov)
 {
     try
     {
         if (dogovorDAO.deleteDogovor(id))
         {
             return(RedirectToAction("MyObject"));
         }
         else
         {
             return(View(dogovorDAO.getDogovor(id)));
         }
     }
     catch (Exception ex)
     {
         Logger.Log.Error("Ошибка: ", ex);
         return(View(dogovorDAO.getDogovor(id)));
     }
 }
Beispiel #19
0
        public bool updateDogovor(Dogovor Dogov)
        {
            Dogovor originalRecords = getDogovor(Dogov.Id);

            try
            {
                originalRecords.IDTr      = Dogov.IDTr;
                originalRecords.Date      = Dogov.Date;
                originalRecords.IDGroup   = Dogov.IDGroup;
                originalRecords.Described = Dogov.Described;

                _entities.SaveChanges();
            }
            catch (Exception ex)
            {
                Logger.Log.Error("Ошибка: ", ex);
                return(false);
            }
            return(true);
        }
Beispiel #20
0
        /// <summary>
        /// Создает указанное количество абонентов
        /// </summary>
        /// <param name="ats"></param>
        /// <param name="count">Количество абонентов</param>
        private static Abonent[] CreateDogovors(Station ats, int count)
        {
            Abonent[] abonents = new Abonent[count];

            for (int i = 0; i < count; i++)
            {
                Dogovor  dogovor = ats.CreateDogovor();
                Port     port    = ats.GetPort(dogovor);
                Terminal phone   = ats.GetPhone();
                phone.Ringing += Phone_Ringing;
                abonents[i]    = new Abonent(dogovor, port, phone);
                Console.WriteLine($"{i} - Договор №{dogovor.DogovorNumber} Номер: {port.AbonentNumber} Тариф: {dogovor.Tariff.Name} Терминал: {phone.Name}");
            }

            Console.WriteLine();
            //сразу подключаем всех к портам
            ConnectTerminalsToPorts(abonents);

            return(abonents);
        }
Beispiel #21
0
 public ActionResult Edit(Dogovor Dogov)
 {
     ViewDataSelectList(-1);
     try
     {
         if (ModelState.IsValid && dogovorDAO.updateDogovor(Dogov))
         {
             return(RedirectToAction("MyObject"));
         }
         else
         {
             return(View(Dogov));
         }
     }
     catch (Exception ex)
     {
         Logger.Log.Error("Ошибка: ", ex);
         return(View(Dogov));
     }
 }
        public static List <Dogovor> DogovorFind(string qiymat, int count)
        {
            List <Dogovor> list = new List <Dogovor>();

            try
            {
                XDocument doc = GetXMLDocument("Data\\Dogovor.xml");
                if (doc == null)
                {
                    return(null);
                }
                List <XElement> elems = doc.Element("DogovorDocument").Elements().ToList <XElement>();

                uint ii;
                int  i = 0;
                if (qiymat != null)
                {
                    qiymat = qiymat.ToLower();
                    string str = "";
                    for (int j = elems.Count - 1; j >= 0; j--)
                    {
                        str = SelectIshTuri("Id", elems[j].Element("ITI").Value.ToString())[0].Nom.ToLower();
                        if (elems[j].Element("ND").Value.ToString().ToLower().IndexOf(qiymat) >= 0 || elems[j].Element("ON").Value.ToString().ToLower().IndexOf(qiymat) >= 0 || elems[j].Element("KN").Value.ToString().IndexOf(qiymat) >= 0 || elems[j].Element("B").Value.ToString().IndexOf(qiymat) >= 0 || str.IndexOf(qiymat) >= 0)
                        {
                            Dogovor dogovor = new Dogovor();

                            dogovor.Id           = uint.TryParse(elems[j].Element("Id").Value, out ii) ? ii : 0;
                            dogovor.NomerDogovor = elems[j].Element("ND").Value;
                            dogovor.Sana         = ToDateTime(elems[j].Element("S").Value);
                            dogovor.ObyektNom    = elems[j].Element("ON").Value;
                            dogovor.KlentNom     = elems[j].Element("KN").Value;
                            dogovor.Bajaruvchi   = elems[j].Element("B").Value;
                            dogovor.IshTuriId    = elems[j].Element("ITI").Value;
                            dogovor.PK           = ToDuoubleNuqta(elems[j].Element("PK").Value);
                            dogovor.PKK          = elems[j].Element("PKK").Value;
                            dogovor.PQ           = ToDuoubleNuqta(elems[j].Element("PQ").Value);

                            i++;
                            list.Add(dogovor);
                        }

                        if (count != 0 && i >= count)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    //MessageBox.Show(i.ToString());
                    for (int j = elems.Count - 1; j >= 0; j--)
                    {
                        Dogovor dogovor = new Dogovor();

                        dogovor.Id           = uint.TryParse(elems[j].Element("Id").Value, out ii) ? ii : 0;
                        dogovor.NomerDogovor = elems[j].Element("ND").Value;
                        dogovor.Sana         = ToDateTime(elems[j].Element("S").Value);
                        dogovor.ObyektNom    = elems[j].Element("ON").Value;
                        dogovor.KlentNom     = elems[j].Element("KN").Value;
                        dogovor.Bajaruvchi   = elems[j].Element("B").Value;
                        dogovor.IshTuriId    = elems[j].Element("ITI").Value;
                        dogovor.PK           = ToDuoubleNuqta(elems[j].Element("PK").Value);
                        dogovor.PKK          = elems[j].Element("PKK").Value;
                        dogovor.PQ           = ToDuoubleNuqta(elems[j].Element("PQ").Value);
                        list.Add(dogovor);
                        i++;
                        if (count != 0 && i >= count)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString());
            }
            return(list);
        }
Beispiel #23
0
 public Abonent(Dogovor dogovor, Port port, Terminal terminal)
 {
     Dogovor  = dogovor;
     Port     = port;
     Terminal = terminal;
 }