コード例 #1
0
        public ActionResult Create(T_BurdenInformations t_burdeninformations)
        {
            if (ModelState.IsValid)
            {
                int ProduceID  = db.T_TransportPrices.Where(m => m.TransportPriceID == t_burdeninformations.TransportPriceID).ToList()[0].ProduceID;
                int ProducerID = db.T_TransportPrices.Where(m => m.TransportPriceID == t_burdeninformations.TransportPriceID).ToList()[0].ProducerID;
                int ConsumerID = db.T_TransportPrices.Where(m => m.TransportPriceID == t_burdeninformations.TransportPriceID).ToList()[0].ConsumerID;

                List <T_ProducerProducePrices> ppps = db.T_ProducerProducePrices.Where(m => m.ProduceID == ProduceID && m.ProducerID == ProducerID && m.StateID == true).ToList();
                List <T_ConsumerProducePrices> cpps = db.T_ConsumerProducePrices.Where(m => m.ProduceID == ProduceID && m.ConsumerID == ConsumerID && m.StateID == true).ToList();


                if (ppps.Count == 1)
                {
                    t_burdeninformations.PPPID = ppps[0].ProducerProducePriceID;
                }
                else if (ppps.Count > 1)
                {
                    ViewBag.err = " بیشتر از یک قیمت محصول تولید کننده فعال است ابتدا به لیست قیمت محصولات تولید کننده رفته و پس از رفع مشکل دوباره تلاش کنید";
                    return(View());
                }
                else if (ppps.Count == 0)
                {
                    ViewBag.err = " هیچ یک از قیمت های محصول تولید کننده فعال نیست ابتدا به لیست قیمت محصولات تولید کننده رفته و پس از رفع مشکل دوباره تلاش کنید";
                    return(View());
                }
                if (cpps.Count == 1)
                {
                    t_burdeninformations.CPPID = cpps[0].ConsumerProducePriceID;
                }
                else if (cpps.Count > 1)
                {
                    ViewBag.err = " بیشتر از یک قیمت محصول خریدار فعال است ابتدا به لیست قیمت محصولات خریدار رفته و پس از رفع مشکل دوباره تلاش کنید";
                    return(View());
                }
                else if (cpps.Count == 0)
                {
                    ViewBag.err = " هیچ یک از قیمت های محصول خریدار فعال نیست ابتدا به لیست قیمت محصولات خریدار رفته و پس از رفع مشکل دوباره تلاش کنید";
                    return(View());
                }



                t_burdeninformations.RegisterDateTime = PersianDateTime.Now.ToDateTime().ToShortDateString();
                //t_burdeninformations.UserID =int.Parse( Session["UserID"].ToString());
                t_burdeninformations.UserID = db.T_Users.Where(m => m.UserName == User.Identity.Name).First().UserID;

                db.T_BurdenInformations.Add(t_burdeninformations);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.ProducerID = new SelectList(db.T_Producers.Where(m => m.StateID == true).ToList(), "ProducerID", "CompanyName");
            ViewBag.ConsumerID = new SelectList(db.T_Consumers.Where(m => m.StateID == true).ToList(), "ConsumerID", "CompanyName");

            ViewBag.TransportPriceID = new SelectList(db.T_TransportPrices.Where(m => m.StateID == true), "TransportPriceID", "_TransportPriceName");
            ViewBag.TruckID          = new SelectList(db.T_Trucks.Where(m => m.StateID == true).ToList(), "TruckID", "_NumberName", t_burdeninformations.TruckID);
            //ViewBag.UserID = new SelectList(db.T_Users, "UserID", "UserName", t_burdeninformations.UserID);
            //return View(t_burdeninformations);
            return(RedirectToAction("Create"));
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(long id)
        {
            T_BurdenInformations t_burdeninformations = db.T_BurdenInformations.Find(id);

            db.T_BurdenInformations.Remove(t_burdeninformations);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public ActionResult Details(long id = 0)
        {
            T_BurdenInformations t_burdeninformations = db.T_BurdenInformations.Find(id);

            if (t_burdeninformations == null)
            {
                return(HttpNotFound());
            }
            return(View(t_burdeninformations));
        }
コード例 #4
0
        public ActionResult Edit(long id = 0)
        {
            T_BurdenInformations t_burdeninformations = db.T_BurdenInformations.Find(id);

            if (t_burdeninformations == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProducerID = new SelectList(db.T_Producers.ToList(), "ProducerID", "CompanyName", t_burdeninformations.T_TransportPrices.ProducerID);
            ViewBag.ConsumerID = new SelectList(db.T_Consumers.ToList(), "ConsumerID", "CompanyName", t_burdeninformations.T_TransportPrices.ConsumerID);
            ViewBag.PPPID      = new SelectList(db.T_ProducerProducePrices.Where(m => m.ProduceID == t_burdeninformations.T_TransportPrices.ProduceID && m.ProducerID == t_burdeninformations.T_TransportPrices.ProducerID).ToList(), "ProducerProducePriceID", "Price", t_burdeninformations.PPPID);
            ViewBag.CPPID      = new SelectList(db.T_ConsumerProducePrices.Where(m => m.ProduceID == t_burdeninformations.T_TransportPrices.ProduceID && m.ConsumerID == t_burdeninformations.T_TransportPrices.ConsumerID).ToList(), "ConsumerProducePriceID", "Price", t_burdeninformations.CPPID);
            ViewBag.BID        = id;

            // m.StateID == true &&
            List <T_TransportPrices> list    = db.T_TransportPrices.Where(m => m.ProducerID == t_burdeninformations.T_TransportPrices.ProducerID && m.ConsumerID == t_burdeninformations.T_TransportPrices.ConsumerID).ToList();
            List <Produce>           proList = new List <Produce>();

            if (list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    Produce p = new Produce();
                    p.ProduceID   = list[i].T_Produces.ProduceID;
                    p.ProduceName = list[i].T_Produces.ProduceName;

                    proList.Add(p);
                }
            }
            ViewBag.ProduceID = new SelectList(proList, "ProduceID", "ProduceName", t_burdeninformations.T_TransportPrices.ProduceID);

            ViewBag.TransportPriceID = new SelectList(db.T_TransportPrices.Where(m => m.ConsumerID == t_burdeninformations.T_TransportPrices.ConsumerID && m.ProducerID == t_burdeninformations.T_TransportPrices.ProducerID && m.ProduceID == t_burdeninformations.T_TransportPrices.ProduceID), "TransportPriceID", "Price", t_burdeninformations.TransportPriceID);
            ViewBag.TruckID          = new SelectList(db.T_Trucks, "TruckID", "_NumberName", t_burdeninformations.TruckID);
            // ViewBag.UserID = new SelectList(db.T_Users, "UserID", "UserName");

            return(View(t_burdeninformations));
        }
コード例 #5
0
        public ActionResult ShowReportConsumer(T_BurdenInformations t_burden, FormCollection frm)
        {
            if (frm["ProducerID"].ToString() != "" || frm["ProduceID"].ToString() != "" || frm["TruckID"].ToString() != "" || frm["FromDate"].ToString() != "" || frm["ToDate"].ToString() != "")
            {
                long producerid = 0;
                long produceid  = 0;
                // long consumerID = 0;
                long   truckID = 0;
                string fromDate = "", toDate = "";
                try
                {
                    producerid = long.Parse(frm["ProducerID"].ToString());
                }
                catch
                {
                }
                try
                {
                    produceid = long.Parse(frm["ProduceID"].ToString());
                }
                catch
                {
                }

                try
                {
                    truckID = long.Parse(frm["TruckID"].ToString());
                }
                catch
                {
                }
                try
                {
                    fromDate = frm["FromDate"].ToString();
                }
                catch
                {
                }
                try
                {
                    toDate = frm["ToDate"].ToString();
                }
                catch
                {
                }



                return(RedirectToAction("ReportConsumer", "BurdenInformation", new { ProducerID = producerid, ProduceID = produceid, TruckID = truckID, FromDate = fromDate, ToDate = toDate }));
            }
            else
            {
                ViewBag.ProducerID = new SelectList(db.T_Producers.Where(m => m.StateID == true).ToList(), "ProducerID", "CompanyName");
                //ViewBag.ConsumerID = new SelectList(db.T_Consumers.ToList(), "ConsumerID", "CompanyName");
                ViewBag.TruckID   = new SelectList(db.T_Trucks.Where(m => m.StateID == true).ToList(), "TruckID", "Number");
                ViewBag.ProduceID = new SelectList(db.T_Produces.ToList(), "ProduceID", "ProduceName");
                return(View());
            }



            // return View();
        }