Ejemplo n.º 1
0
 public static bool IsUniqueRecord(CtVet1a tmp)
 {
     if (tmp == null)
     {
         return(false);
     }
     using (SqlConnection _conn = new SqlConnection(spDAL.connStr))
     {
         string q = "SELECT COUNT(ID) as kolvo FROM ctVET1a " +
                    "WHERE (repMO = @repMO and KIDdiv=@KIDDiv " +
                    "and KIDspc=@KIDspc and KIDdis=@KIDdis and KIDro=@KIDro)";
         var param = new
         {
             repMO  = tmp.repMO,
             KIDdiv = tmp.KIDdiv,
             KIDspc = tmp.KIDspc,
             KIDdis = tmp.KIDdis,
             KIDro  = tmp.KIDro
         };
         int count = _conn.QueryFirstOrDefault <int>(q, param);
         if (count == 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Ejemplo n.º 2
0
 public static void Add_CtVet1a(CtVet1a tmp)
 {
     if (tmp == null)
     {
         return;
     }
     using (SqlConnection _conn = new SqlConnection(spDAL.connStr))
     {
         string q = "INSERT INTO ctVet1a (KIDro,repMO,KIDdiv,KIDspc,KIDdis,pos_units," +
                    "positives,dead,end_pos_units,end_pos_animals,culled,comments)" +
                    " VALUES (" +
                    "@KIDro,@repMO,@KIDdiv,@KIDspc,@KIDdis,@pos_units," +
                    "@positives,@dead,@end_pos_units,@end_pos_animals,@culled,@c)";
         var param = new
         {
             KIDro           = tmp.KIDro,
             repMO           = tmp.repMO,
             KIDdiv          = tmp.KIDdiv,
             KIDspc          = tmp.KIDspc,
             KIDdis          = tmp.KIDdis,
             pos_units       = tmp.pos_units,
             positives       = tmp.positives,
             dead            = tmp.dead,
             end_pos_units   = tmp.end_pos_units,
             end_pos_animals = tmp.end_pos_animals,
             culled          = tmp.culled,
             c = tmp.comments
         };
         _conn.Execute(q, param);
         _conn.Close();
     }
 }
Ejemplo n.º 3
0
 public static CtVet1a Get_CtVet1a_ById(Guid id)
 {
     using (SqlConnection _conn = new SqlConnection(spDAL.connStr))
     {
         string  q     = "SELECT * FROM ctVet1a WHERE ID=@idd";
         var     param = new { idd = id };
         CtVet1a tmp   = _conn.QueryFirstOrDefault <CtVet1a>(q, param);
         tmp.KIDdisDisplay = spDAL.KIDdisName(tmp.KIDdis);
         tmp.KIDdivDisplay = spDAL.KIDdivName(tmp.KIDdiv);
         tmp.KIDspcDisplay = spDAL.KIDspcName(tmp.KIDspc);
         return(tmp);
     }
 }
Ejemplo n.º 4
0
        public IActionResult Delete(Guid id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            CtVet1a tmpVet1a = CtVet1aDAL.Get_CtVet1a_ById(id);

            if (tmpVet1a == null)
            {
                return(NotFound());
            }
            ViewBag.Page = "CtVet1a";
            return(View(tmpVet1a));
        }
Ejemplo n.º 5
0
 public IActionResult Edit(Guid id, [Bind] CtVet1a objCtVet1a)
 {
     //if ((id == null)||(!CtVet1aDAL.IsUniqueRecord(objCtVet1a)))
     if (id == null)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         CtVet1aDAL.UpdateCtVet1a(objCtVet1a);
         ViewBag.Page = "CtVet1a";
         return(RedirectToAction("Index"));
     }
     ViewBag.Page = "CtVet1a";
     return(View(objCtVet1a));
 }
Ejemplo n.º 6
0
        public IActionResult Create()
        {
            int Y = Convert.ToInt32(User.Claims.ToList().FirstOrDefault(x => x.Type == "reportDtYear").Value);
            int M = Convert.ToInt32(User.Claims.ToList().FirstOrDefault(x => x.Type == "reportDtMonth").Value);

            ViewBag.RepMoList  = spDAL.RepMO1YearList(Y, M);
            ViewBag.KIDdivList = spDAL.KIDdivList(User.Claims.ToList().FirstOrDefault(x => x.Type == "KIDro").Value);
            ViewBag.KIDspcList = spDAL.KIDspcList();
            ViewBag.KIDdisList = spDAL.KIDdisList();

            CtVet1a tmp = new CtVet1a
            {
                KIDro = User.Claims.ToList().FirstOrDefault(x => x.Type == "KIDro").Value,
                repMO = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)
            };

            ViewBag.Page = "CtVet1a";
            return(View(tmp));
        }
Ejemplo n.º 7
0
 public static void UpdateCtVet1a(CtVet1a tmp)
 {
     if (tmp is null)
     {
         return;
     }
     using (SqlConnection _conn = new SqlConnection(spDAL.connStr))
     {
         string q = "UPDATE ctVET1a SET " +
                    "KIDro=@KIDro," +
                    "repMO=@repMO," +
                    "KIDdiv=@KIDdiv," +
                    "KIDspc=@KIDspc," +
                    "KIDdis=@KIDdis," +
                    "pos_units=@pos_units," +
                    "positives=@positives," +
                    "dead=@dead," +
                    "end_pos_units=@end_pos_units," +
                    "end_pos_animals=@end_pos_animals," +
                    "culled=@culled," +
                    "comments=@c " +
                    "WHERE ID=@ID";
         var param = new
         {
             KIDro           = tmp.KIDro,
             repMO           = tmp.repMO,
             KIDdiv          = tmp.KIDdiv,
             KIDspc          = tmp.KIDspc,
             KIDdis          = tmp.KIDdis,
             pos_units       = tmp.pos_units,
             positives       = tmp.positives,
             dead            = tmp.dead,
             end_pos_units   = tmp.end_pos_units,
             end_pos_animals = tmp.end_pos_animals,
             culled          = tmp.culled,
             ID = tmp.ID,
             c  = tmp.comments
         };
         _conn.Execute(q, param);
         _conn.Close();
     }
 }
Ejemplo n.º 8
0
 public IActionResult Create([Bind] CtVet1a tmpVet)
 {
     if (ModelState.IsValid)
     {
         //проверка на существования аналогичной записи
         if (CtVet1aDAL.IsUniqueRecord(tmpVet))
         {
             CtVet1aDAL.Add_CtVet1a(tmpVet);
         }
         else
         {
             TempData["EM"] = "Такая запись уже существует";
             ModelState.AddModelError("", "Такая запись уже существует");
             //return NotFound();
         };
         ViewBag.Page = "CtVet1a";
         return(RedirectToAction("Index"));
     }
     ViewBag.Page = "CtVet1a";
     return(View(tmpVet));
 }
Ejemplo n.º 9
0
        public IActionResult Edit(Guid id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            CtVet1a tmpVet1a = CtVet1aDAL.Get_CtVet1a_ById(id);

            if (tmpVet1a == null)
            {
                return(NotFound());
            }

            int Y = Convert.ToInt32(User.Claims.ToList().FirstOrDefault(x => x.Type == "reportDtYear").Value);
            int M = Convert.ToInt32(User.Claims.ToList().FirstOrDefault(x => x.Type == "reportDtMonth").Value);

            ViewBag.RepMoList  = spDAL.RepMO1YearList(Y, M);
            ViewBag.KIDdivList = spDAL.KIDdivList(User.Claims.ToList().FirstOrDefault(x => x.Type == "KIDro").Value);
            ViewBag.KIDspcList = spDAL.KIDspcList(); ViewBag.KIDdisList = spDAL.KIDdisList();
            ViewBag.Page       = "CtVet1a";
            return(View(tmpVet1a));
        }