예제 #1
0
        public IActionResult Create()
        {
            int reportDtYear  = Convert.ToInt32(User.Claims.ToList().FirstOrDefault(x => x.Type == "reportDtYear").Value);
            int reportDtMonth = Convert.ToInt32(User.Claims.ToList().FirstOrDefault(x => x.Type == "reportDtMonth").Value);

            ViewBag.RepMoList   = spDAL.RepMO1YearList(reportDtYear, reportDtMonth);
            ViewBag.VetPrepList = spDAL.VetPrepList();
            //ViewBag.EdIzmList = spDAL.EdIzmList();

            string _kidro = User.Claims.ToList().FirstOrDefault(x => x.Type == "KIDro").Value;
            long?  b      = BioPrepDAL.GetByloById(_kidro,
                                                   DateTime.Today,
                                                   "AZIN"
                                                   );
            BioPrep tmp = new BioPrep
            {
                KIDro             = _kidro,
                RepMO             = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1),
                VetPrep           = "AZIN",
                Bylo              = b,
                Ostatok_za_mesyac = b
            };

            ViewBag.Page = "BioPrep";
            return(View(tmp));
        }
예제 #2
0
        public IActionResult Edit(Guid id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            BioPrep tmp = BioPrepDAL.GetById_BioPrep(id);

            if (tmp == 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.VetPrepList = spDAL.VetPrepList();
            ViewBag.EdIzmList   = spDAL.EdIzmList();

            ViewBag.Page = "BioPrep";
            //if(tmp.ByloPredMonth!=tmp.Bylo)
            //    TempData["EM"] = "Остаток на нач. месяца не совпадает с введенными ранее данными";
            return(View(tmp));
        }
예제 #3
0
        public static void Add_BioPrep(BioPrep tmp)
        {
            SqlConnection _conn = new SqlConnection(spDAL.connStr);

            /*
             * string q = "SELECT TOP 1 (Bylo+PostupiloVsego+PostupiloRazn-IzrashodVsego-IzrashodDrugoe) "
             +"as ByloPredMonth FROM BioPrep WHERE (" +
             *          "KIDro=@KIDro and VetPrep=@VetPrep and EdIzm=@EdIzm and "+
             *          "repMO < @dt) ORDER BY repMO DESC";*/
            string q = "SELECT TOP 1 (Bylo+PostupiloVsego-IzrashodVsego) "
                       + "as ByloPredMonth FROM BioPrep WHERE (" +
                       "KIDro=@KIDro and VetPrep=@VetPrep and " +
                       "repMO < @dt) ORDER BY repMO DESC";
            var param = new
            {
                KIDro   = tmp.KIDro,
                VetPrep = tmp.VetPrep,
                //EdIzm = spDAL.EdIzmID(tmp.VetPrep),
                dt = tmp.RepMO,
            };

            tmp.Bylo = _conn.QueryFirstOrDefault <long?>(q, param);
            if (tmp.Bylo == null)
            {
                tmp.Bylo = 0;
            }

            _conn.Execute("INSERT INTO BioPrep (KIDro, repMO,VetPrep,EdIzm,Bylo,"
                          + "PostupiloVsego,PostupiloRazn,IzrashodVsego,IzrashodDrugoe,Ostatok_za_mesyac) VALUES (" +
                          "@KIDroP,@repMOP,@VetPrepP,@EdIzmP,@ByloP,"
                          + "@PostupiloVsegoP,@PostupiloRaznP,@IzrashodVsegoP,@IzrashodDrugoeP,@Ostatok_za_mesyac)",
                          new
            {
                KIDroP            = tmp.KIDro,
                repMOP            = tmp.RepMO,
                VetPrepP          = tmp.VetPrep,
                EdIzmP            = spDAL.EdIzmID(tmp.VetPrep),
                ByloP             = tmp.Bylo,
                PostupiloVsegoP   = tmp.PostupiloVsego,
                PostupiloRaznP    = tmp.PostupiloRazn,
                IzrashodDrugoeP   = tmp.IzrashodDrugoe,
                IzrashodVsegoP    = tmp.IzrashodVsego,
                Ostatok_za_mesyac = tmp.Bylo + tmp.PostupiloVsego
                                    //tmp.PostupiloRazn -
                                    - tmp.IzrashodVsego
                                    //tmp.IzrashodDrugoe
            });
            _conn.Close();
        }
예제 #4
0
        public IActionResult Delete(Guid id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            BioPrep tmp = BioPrepDAL.GetById_BioPrep(id);

            if (tmp == null)
            {
                return(NotFound());
            }
            ViewBag.Page = "BioPrep";
            return(View(tmp));
        }
예제 #5
0
 public IActionResult Edit(Guid id, [Bind] BioPrep objBioPrep)
 {
     if (id == null)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         //if(BioPrepDAL.IsUniqueRecord(objBioPrep))
         BioPrepDAL.Update_BioPrep(objBioPrep);
         return(RedirectToAction("Index"));
     }
     ViewBag.Page = "BioPrep";
     return(View(objBioPrep));
 }
예제 #6
0
 public IActionResult Create([Bind] BioPrep tmp)
 {
     if (ModelState.IsValid)
     {
         //проверка на существования аналогичной записи
         if (BioPrepDAL.IsUniqueRecord(tmp))
         {
             BioPrepDAL.Add_BioPrep(tmp);
         }
         else
         {
             TempData["EM"] = "Такая запись уже существует";
             //return LocalRedirect("~/Home/Error");
             //return RedirectToAction("Error");
         };
         return(RedirectToAction("Index"));
     }
     ViewBag.Page = "BioPrep";
     return(View(tmp));
 }
예제 #7
0
 public static void Update_BioPrep(BioPrep tmp)
 {
     if (tmp == null)
     {
         return;
     }
     using (SqlConnection _conn = new SqlConnection(spDAL.connStr))
     {
         string q =
             "UPDATE BioPrep SET KIDro=@KIDroP," +
             "repMO=@repMOP," +
             "VetPrep=@VetPrepP," +
             "EdIzm=@EdIzmP," +
             "Bylo=@Bylo," +
             "PostupiloVsego=@PostupiloVsegoP," +
             "PostupiloRazn=@PostupiloRaznP," +
             "IzrashodVsego=@IzrashodVsegoP," +
             "IzrashodDrugoe=@IzrashodDrugoeP," +
             "Ostatok_za_mesyac=@Ostatok_za_mesyac" +
             " WHERE ID=@IdP";
         var param = new {
             IdP               = tmp.ID,
             KIDroP            = tmp.KIDro,
             repMOP            = tmp.RepMO,
             VetPrepP          = tmp.VetPrep,
             EdIzmP            = spDAL.EdIzmID(tmp.VetPrep),
             Bylo              = tmp.Bylo,
             PostupiloVsegoP   = tmp.PostupiloVsego,
             PostupiloRaznP    = tmp.PostupiloRazn,
             IzrashodDrugoeP   = tmp.IzrashodDrugoe,
             IzrashodVsegoP    = tmp.IzrashodVsego,
             Ostatok_za_mesyac =
                 tmp.Bylo + tmp.PostupiloVsego
                 //tmp.PostupiloRazn -
                 //tmp.IzrashodDrugoe -
                 - tmp.IzrashodVsego
         };
         _conn.Execute(q, param);
         _conn.Close();
     }
 }
예제 #8
0
 public static bool IsUniqueRecord(BioPrep tmp)
 {
     if (tmp == null)
     {
         return(false);
     }
     using (SqlConnection _conn = new SqlConnection(spDAL.connStr))
     {
         int count = _conn.QueryFirst <int>("SELECT COUNT(*) FROM BioPrep WHERE ("
                                            + "repMO=@repMOP and KIDro=@KIDroP and VetPrep=@VetPrepP)",
                                            new { repMOP = tmp.RepMO, KIDroP = tmp.KIDro, VetPrepP = tmp.VetPrep });
         _conn.Close();
         if (count == 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
예제 #9
0
        public static BioPrep GetById_BioPrep(Guid Id)
        {
            using (SqlConnection _conn = new SqlConnection(spDAL.connStr))
            {
                BioPrep tmp = _conn.QueryFirst <BioPrep>(
                    "SELECT * FROM BioPrep WHERE ID=@IDv", new { IDv = Id });

                /*
                 * string q = "SELECT TOP 1 (Bylo+PostupiloVsego+PostupiloRazn-IzrashodVsego-IzrashodDrugoe) "
                 +"as ByloPredMonth FROM BioPrep WHERE (" +
                 *          "KIDro=@KIDro and VetPrep=@VetPrep and EdIzm=@EdIzm and "+
                 *          "repMO < @dt) ORDER BY repMO DESC";*/
                string q = "SELECT TOP 1 (Bylo+PostupiloVsego-IzrashodVsego) "
                           + "as ByloPredMonth FROM BioPrep WHERE (" +
                           "KIDro=@KIDro and VetPrep=@VetPrep and " +
                           "repMO < @dt) ORDER BY repMO DESC";
                var param = new
                {
                    KIDro   = tmp.KIDro,
                    VetPrep = tmp.VetPrep,
                    //EdIzm = tmp.EdIzm,
                    dt = tmp.RepMO,
                };
                tmp.Bylo = _conn.QueryFirstOrDefault <long?>(q, param);
                if (tmp.Bylo == null)
                {
                    tmp.Bylo = 0;
                }
                _conn.Close();

                tmp.VetPrepDisplay = spDAL.VetPrepName(tmp.VetPrep);
                //tmp.EdIzmDisplay = spDAL.EdIzmName(tmp.EdIzm);
                tmp.Ostatok_za_mesyac = tmp.Bylo + tmp.PostupiloVsego
                                        //+ tmp.PostupiloRazn
                                        - tmp.IzrashodVsego;
                //-tmp.IzrashodDrugoe;
                return(tmp);
            }
        }