示例#1
0
        public ActionResult EditQuick(int?id, string UrlReferrer, string HostingEntityName, string AssociatedType, string viewtype)
        {
            if (!User.CanEdit("T_Address") || !CustomAuthorizationBeforeEdit(id, HostingEntityName, AssociatedType))
            {
                return(RedirectToAction("Index", "Error"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (string.IsNullOrEmpty(viewtype))
            {
                viewtype = "EditQuick";
            }
            GetTemplatesForEditQuick(viewtype);
            T_Address t_address = db.T_Addresss.Find(id);

            if (t_address == null)
            {
                return(HttpNotFound());
            }
            if (UrlReferrer != null)
            {
                ViewData["T_AddressParentUrl"] = UrlReferrer;
            }
            if (ViewData["T_AddressParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Address") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Address/Edit/" + t_address.Id + "") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Address/Create"))
            {
                ViewData["T_AddressParentUrl"] = Request.UrlReferrer;
            }
            ViewData["HostingEntityName"] = HostingEntityName;
            ViewData["AssociatedType"]    = AssociatedType;
            LoadViewDataBeforeOnEdit(t_address);
            ViewBag.T_AddressIsHiddenRule       = checkHidden("T_Address", "OnEdit", false);
            ViewBag.T_AddressIsGroupsHiddenRule = checkHidden("T_Address", "OnEdit", true);
            ViewBag.T_AddressIsSetValueUIRule   = checkSetValueUIRule("T_Address", "OnEdit");
            var objT_Address = new List <T_Address>();

            ViewBag.T_AddressDD = new SelectList(objT_Address, "ID", "DisplayValue");
            return(View(t_address));
        }
示例#2
0
        // GET: /T_Address/Delete/5
        public ActionResult Delete(int id)
        {
            if (!User.CanDelete("T_Address") || !CustomAuthorizationBeforeDelete(id))
            {
                return(RedirectToAction("Index", "Error"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            T_Address t_address = db.T_Addresss.Find(id);

            if (t_address == null)
            {
                throw(new Exception("Deleted"));
            }
            if (ViewData["T_AddressParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Address"))
            {
                ViewData["T_AddressParentUrl"] = Request.UrlReferrer;
            }
            return(View(t_address));
        }
示例#3
0
 public ActionResult CreateQuick([Bind(Include = "Id,ConcurrencyKey,T_AddressLine1,T_AddressLine2,T_ZipCode,T_AddressCountryID,T_AddressStateID,T_AddressCityID")] T_Address t_address, string UrlReferrer, bool?IsAddPop, string AssociatedEntity, string HostingEntityName, string HostingEntityID)
 {
     CheckBeforeSave(t_address);
     if (ModelState.IsValid)
     {
         bool customcreate_hasissues = false;
         if (!CustomSaveOnCreate(t_address, out customcreate_hasissues, "Create"))
         {
             db.T_Addresss.Add(t_address);
             db.SaveChanges();
         }
         if (!customcreate_hasissues)
         {
             return(Json("FROMPOPUP", "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet));
         }
     }
     else
     {
         var errors = "";
         foreach (ModelState modelState in ViewData.ModelState.Values)
         {
             foreach (ModelError error in modelState.Errors)
             {
                 errors += error.ErrorMessage + ".  ";
             }
         }
         return(Json(errors, "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet));
     }
     LoadViewDataAfterOnCreate(t_address);
     ViewBag.T_AddressIsHiddenRule       = checkHidden("T_Address", "OnCreate", false);
     ViewBag.T_AddressIsGroupsHiddenRule = checkHidden("T_Address", "OnCreate", true);
     ViewBag.T_AddressIsSetValueUIRule   = checkSetValueUIRule("T_Address", "OnCreate");
     if (!string.IsNullOrEmpty(AssociatedEntity))
     {
         LoadViewDataForCount(t_address, AssociatedEntity);
     }
     return(View(t_address));
 }
示例#4
0
        public bool InsertAddress(string address1, string address2, string name, string mobile)
        {
            UserBll bll    = new UserBll();
            int     userid = 0;

            userid = bll.GetUserIdByToken();
            if (userid > 0)
            {
                T_Address model = new T_Address();
                model.Adress     = address2;
                model.Area       = address1;
                model.Name       = name;
                model.Mobile     = mobile;
                model.CreateDate = DateTime.Now;
                model.UserId     = userid;
                AddressDal addressdal = new AddressDal();
                return(addressdal.InsertAddress(model));
            }
            else
            {
                return(false);
            }
        }
示例#5
0
        public bool AddOrderByUserId(string card, string bastdate, string paytype, string remark, string ordercode)
        {
            UserBll userbll = new UserBll();
            // int csum = Convert.ToInt32(sum);
            int userid = 0;

            userid = userbll.GetUserIdByToken();
            bool orderres = false;

            if (userid > 0)
            {
                T_Order       order    = new T_Order();
                CartBll       cartbll  = new CartBll();
                OrderDal      orderdal = new OrderDal();
                List <T_Cart> cartlist = new List <T_Cart>();
                cartlist = cartbll.GetCartListByUserId(userid);
                AddressBll addressbll = new AddressBll();
                T_Address  address    = new T_Address();
                // UserBll userbll = new UserBll();
                T_User user = new T_User();
                user                = userbll.GerUserByUserId(userid);
                address             = addressbll.GetAddressByUserId();
                order.OrderCode     = ordercode;
                order.CreateDate    = DateTime.Now;
                order.Adress        = address.Adress + address.Area + "_" + address.Name;
                order.Mobile        = address.Mobile;
                order.OrderStatus   = "待付款";
                order.PayType       = paytype;
                order.bastdate      = bastdate;
                order.card_birthday = card;
                order.Remark        = remark;
                order.UserId        = userid;
                string  makabi    = "";
                decimal?sumprice  = 0;
                int     makaprice = 0;
                bool    res       = false;

                if (cartlist != null)
                {
                    foreach (T_Cart cart in cartlist)
                    {
                        T_OrderDetail orderdetail = new T_OrderDetail();
                        orderdetail.CreateDate    = DateTime.Now;
                        orderdetail.OrderCode     = order.OrderCode;
                        orderdetail.ProductId     = cart.ProductId;
                        orderdetail.ProductName   = cart.ProductName;
                        orderdetail.ProductNumber = cart.ProductNumber;
                        orderdetail.ProductPrice  = cart.ProductPrice;
                        orderdetail.Specification = cart.Specification;
                        res = orderdal.AddOrderDetail(orderdetail);
                        if (res)
                        {
                            cartbll.DelCartById(cart.Id);
                        }
                        sumprice = sumprice + cart.ProductPrice;
                    }
                }
                if (user != null)
                {
                    makabi = user.MaKaCurrency.ToString();

                    makaprice = (int)user.MaKaCurrency / 10;
                    if (makaprice >= sumprice)
                    {
                        sumprice = 0;
                    }
                    else
                    {
                        sumprice = (int)sumprice - makaprice;
                    }
                    order.makabi = user.MaKaCurrency;
                }
                if (sumprice <= 230)
                {
                    sumprice   = sumprice + 18;
                    order.fare = 18;
                }
                else
                {
                    order.fare = 0;
                }

                order.OrderPrice = sumprice;
                orderres         = orderdal.AddOrder(order);
                if (orderres)
                {
                    userbll.UpdateUser(userid, (int)user.MaKaCurrency);
                }
                return(orderres);
            }
            else
            {
                return(false);
            }
        }
 public void AfterSave(T_Address t_address)
 {
     // Write your logic here
 }
 public void OnSaving(T_Address t_address, ApplicationContext db)
 {
     // Write your logic here
 }
 public void OnDeleting(T_Address t_address)
 {
     // Write your logic here
 }
 private RedirectToRouteResult CustomRedirectUrl(T_Address t_address, string action, string command = "")
 {
     // Sample Custom implemention below
     // return RedirectToAction("Index", "T_Address");
     return(null);
 }
 private void CustomLoadViewDataListAfterEdit(T_Address t_address)
 {
 }
 private void CustomLoadViewDataListBeforeEdit(T_Address t_address)
 {
 }
 private void CustomLoadViewDataListAfterOnCreate(T_Address t_address)
 {
 }
示例#13
0
        public ActionResult Edit([Bind(Include = "Id,ConcurrencyKey,T_AddressLine1,T_AddressLine2,T_ZipCode,T_AddressCountryID,T_AddressStateID,T_AddressCityID")] T_Address t_address, string UrlReferrer)
        {
            string command = Request.Form["hdncommand"];

            CheckBeforeSave(t_address, command);
            if (ModelState.IsValid)
            {
                bool customsave_hasissues = false;
                if (!CustomSaveOnEdit(t_address, out customsave_hasissues, command))
                {
                    db.Entry(t_address).State = EntityState.Modified;
                    db.SaveChanges();
                }
                if (!customsave_hasissues)
                {
                    RedirectToRouteResult customRedirectAction = CustomRedirectUrl(t_address, "Edit", command);
                    if (customRedirectAction != null)
                    {
                        return(customRedirectAction);
                    }
                    if (command != "Save")
                    {
                        if (command == "SaveNextPrev")
                        {
                            long NextPreId = Convert.ToInt64(Request.Form["hdnNextPrevId"]);
                            return(RedirectToAction("Edit", new { Id = NextPreId, UrlReferrer = UrlReferrer }));
                        }
                        else
                        {
                            return(RedirectToAction("Edit", new { Id = t_address.Id, UrlReferrer = UrlReferrer }));
                        }
                    }
                    if (!string.IsNullOrEmpty(UrlReferrer))
                    {
                        var uri   = new Uri(UrlReferrer);
                        var query = HttpUtility.ParseQueryString(uri.Query);
                        if (Convert.ToBoolean(query.Get("IsFilter")) == true)
                        {
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            return(Redirect(UrlReferrer));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }

            // NEXT-PREVIOUS DROP DOWN CODE
            TempData.Keep();
            string json = "";

            if (TempData["T_Addresslist"] == null)
            {
                json = Newtonsoft.Json.JsonConvert.SerializeObject(db.T_Addresss.Select(z => new { ID = z.Id, DisplayValue = z.DisplayValue }).ToList());
            }
            else
            {
                ViewBag.EntityT_AddressDisplayValueEdit = TempData["T_Addresslist"];
                json = Newtonsoft.Json.JsonConvert.SerializeObject(TempData["T_Addresslist"]);
            }

            Newtonsoft.Json.JsonSerializerSettings serSettings = new    Newtonsoft.Json.JsonSerializerSettings();
            serSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
            var lst = Newtonsoft.Json.JsonConvert.DeserializeObject <IEnumerable <object> >(json, serSettings);

            ViewBag.EntityT_AddressDisplayValueEdit = new SelectList(lst, "ID", "DisplayValue");
            //
            LoadViewDataAfterOnEdit(t_address);
            ViewData["T_AddressParentUrl"]      = UrlReferrer;
            ViewBag.T_AddressIsHiddenRule       = checkHidden("T_Address", "OnEdit", false);
            ViewBag.T_AddressIsGroupsHiddenRule = checkHidden("T_Address", "OnEdit", true);
            ViewBag.T_AddressIsSetValueUIRule   = checkSetValueUIRule("T_Address", "OnEdit");
            return(View(t_address));
        }
示例#14
0
        public ActionResult Edit(int?id, string UrlReferrer, string HostingEntityName, string AssociatedType, string defaultview)
        {
            if (!User.CanEdit("T_Address") || !CustomAuthorizationBeforeEdit(id, HostingEntityName, AssociatedType))
            {
                return(RedirectToAction("Index", "Error"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            T_Address t_address = db.T_Addresss.Find(id);

            // NEXT-PREVIOUS DROP DOWN CODE
            TempData.Keep();
            string json = "";

            if (TempData["T_Addresslist"] == null)
            {
                json = Newtonsoft.Json.JsonConvert.SerializeObject(db.T_Addresss.Select(z => new { ID = z.Id, DisplayValue = z.DisplayValue }).ToList());
            }
            else
            {
                ViewBag.EntityT_AddressDisplayValueEdit = TempData["T_Addresslist"];
                json = Newtonsoft.Json.JsonConvert.SerializeObject(TempData["T_Addresslist"]);
            }

            Newtonsoft.Json.JsonSerializerSettings serSettings = new    Newtonsoft.Json.JsonSerializerSettings();
            serSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
            var lst = Newtonsoft.Json.JsonConvert.DeserializeObject <IEnumerable <object> >(json, serSettings);

            ViewBag.EntityT_AddressDisplayValueEdit = new SelectList(lst, "ID", "DisplayValue");
            //
            if (t_address == null)
            {
                return(HttpNotFound());
            }
            if (string.IsNullOrEmpty(defaultview))
            {
                defaultview = "Edit";
            }
            GetTemplatesForEdit(defaultview);
            // NEXT-PREVIOUS DROP DOWN CODE
            SelectList            selitm  = new SelectList(lst, "ID", "DisplayValue");
            List <SelectListItem> newList = selitm.ToList();

            if (Request.UrlReferrer != null && Request.UrlReferrer.AbsolutePath.EndsWith("/T_Address/Create"))
            {
                newList.Insert(0, (new SelectListItem {
                    Text = t_address.DisplayValue, Value = t_address.Id.ToString()
                }));
                ViewBag.EntityT_AddressDisplayValueEdit = newList;
                TempData["T_Addresslist"] = newList.Select(z => new { ID = z.Value, DisplayValue = z.Text });
            }
            else if (!newList.Exists(p => p.Value == Convert.ToString(t_address.Id)))
            {
                if (newList.Count > 0)
                {
                    newList[0].Text  = t_address.DisplayValue;
                    newList[0].Value = t_address.Id.ToString();
                }
                else
                {
                    newList.Insert(0, (new SelectListItem {
                        Text = t_address.DisplayValue, Value = t_address.Id.ToString()
                    }));
                }
                ViewBag.EntityT_AddressDisplayValueEdit = newList;
                TempData["T_Addresslist"] = newList.Select(z => new { ID = z.Value, DisplayValue = z.Text });
            }
            //
            if (UrlReferrer != null)
            {
                ViewData["T_AddressParentUrl"] = UrlReferrer;
            }
            if (ViewData["T_AddressParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Address") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Address/Edit/" + t_address.Id + "") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Address/Create"))
            {
                ViewData["T_AddressParentUrl"] = Request.UrlReferrer;
            }
            ViewData["HostingEntityName"] = HostingEntityName;
            ViewData["AssociatedType"]    = AssociatedType;
            LoadViewDataBeforeOnEdit(t_address);
            ViewBag.T_AddressIsHiddenRule       = checkHidden("T_Address", "OnEdit", false);
            ViewBag.T_AddressIsGroupsHiddenRule = checkHidden("T_Address", "OnEdit", true);
            ViewBag.T_AddressIsSetValueUIRule   = checkSetValueUIRule("T_Address", "OnEdit");
            return(View(t_address));
        }