Exemple #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"));
        }
        public ActionResult Create(T_Consumer_Bank t_consumer_bank)
        {
            if (ModelState.IsValid)
            {
                db.T_Consumer_Bank.Add(t_consumer_bank);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(t_consumer_bank));
        }
Exemple #3
0
 public ActionResult Create(T_Trucks t_trucks)
 {
     if (ModelState.IsValid)
     {
         db.T_Trucks.Add(t_trucks);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.StateID = new SelectList(db.T_State, "StateID", "StateName");
     return(View(t_trucks));
 }
Exemple #4
0
        public ActionResult Create(T_BankMyAcount t_bankmyacount)
        {
            if (ModelState.IsValid)
            {
                db.T_BankMyAcount.Add(t_bankmyacount);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(t_bankmyacount));
        }
Exemple #5
0
        public ActionResult Create(T_Produces t_produces)
        {
            if (ModelState.IsValid)
            {
                db.T_Produces.Add(t_produces);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(t_produces));
        }
        public ActionResult Create(T_ProducersPays t_producerspays)
        {
            if (ModelState.IsValid)
            {
                db.T_ProducersPays.Add(t_producerspays);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PayStateID = new SelectList(db.T_PayState, "PayStateID", "PayStateName", t_producerspays.PayStateID);
            ViewBag.PayTypeID  = new SelectList(db.T_PayType, "PayTypeID", "PayTypeName", t_producerspays.PayTypeID);
            ViewBag.PFSID      = new SelectList(db.T_ProducerFinancialStatements, "ProducerFinancialStatementID", "RegisterDate", t_producerspays.PFSID);
            return(View(t_producerspays));
        }
        public ActionResult Create(T_ConsumerFinancialStatements t_consumerfinancialstatements)
        {
            if (ModelState.IsValid)
            {
                db.T_ConsumerFinancialStatements.Add(t_consumerfinancialstatements);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ConsumerID = new SelectList(db.T_Consumers.Where(m => m.StateID == true), "ConsumerID", "CompanyName", t_consumerfinancialstatements.ConsumerID);
            ViewBag.StateID    = new SelectList(db.T_FinancialStates, "StateID", "StateName", t_consumerfinancialstatements.StateID);
            return(View(t_consumerfinancialstatements));
        }
 public ActionResult DeleteAllBurdenConfirmed(long id)
 {
     ViewBag.err = "";
     try
     {
         List <T_BurdenInformations> t_burden = db.T_BurdenInformations.Where(m => m.PFSID == id).ToList();
         for (int i = 0; i < t_burden.Count; i++)
         {
             t_burden[i].PFSID           = null;
             db.Entry(t_burden[i]).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch
     {
         ViewBag.err = "خطا در حذف حواله ها";
     }
     return(RedirectToAction("Details", new { id = id }));
 }
Exemple #9
0
        public ActionResult Create(T_Users t_users, FormCollection frm)
        {
            if (ModelState.IsValid)
            {
                if (t_users.TypeID == 1)
                {
                }
                else if (t_users.TypeID == 2)
                {
                    t_users.PublicID = int.Parse(frm["TruckID"].ToString());
                    T_UserRoles    role = db.T_UserRoles.Where(m => m.RoleName == "Truck").ToList()[0];
                    T_UsersInRoles uir  = new T_UsersInRoles();
                    //uir.UserId = t_users.UserID;
                    uir.RoleId = role.RoleId;
                    t_users.T_UsersInRoles.Add(uir);
                }
                else if (t_users.TypeID == 3)
                {
                    t_users.PublicID = int.Parse(frm["ConsumerID"].ToString());
                    T_UserRoles    role = db.T_UserRoles.Where(m => m.RoleName == "Consumer").ToList()[0];
                    T_UsersInRoles uir  = new T_UsersInRoles();
                    //uir.UserId = t_users.UserID;
                    uir.RoleId = role.RoleId;
                    t_users.T_UsersInRoles.Add(uir);
                }

                db.T_Users.Add(t_users);
                db.SaveChanges();


                TempData["Msg"] = "کابر ایجاد شد";
                return(RedirectToAction("Index"));
            }

            ViewBag.TypeID     = new SelectList(db.T_Users_Type.ToList(), "TypeID", "TypeName", 1);
            ViewBag.TruckID    = new SelectList(db.T_Trucks.ToList(), "TruckID", "_NumberName", 1);
            ViewBag.ConsumerID = new SelectList(db.T_Consumers.ToList(), "ConsumerID", "CompanyName", 1);

            return(View(t_users));
        }
        public ActionResult Active(int id = 0)
        {
            T_TransportPrices t_transportprices = db.T_TransportPrices.Find(id);

            if (t_transportprices == null)
            {
                return(HttpNotFound());
            }

            Nullable <int> ProduceID, ProducerID, ConsumerID;

            ProducerID = t_transportprices.ProducerID;
            ProduceID  = t_transportprices.ProduceID;
            ConsumerID = t_transportprices.ConsumerID;

            List <T_TransportPrices> trlist = db.T_TransportPrices.Where(m => m.ConsumerID == ConsumerID && m.ProduceID == ProduceID && m.ProducerID == ProducerID).ToList();

            if (trlist.Count > 0)
            {
                foreach (var item in trlist)
                {
                    if (item.TransportPriceID == id)
                    {
                        item.StateID = true;
                    }
                    else
                    {
                        item.StateID = false;
                    }

                    db.Entry(item).State = System.Data.EntityState.Modified;
                    db.SaveChanges();
                }
            }



            return(RedirectToAction("Index", "TransportPrice"));
        }