/// <summary> /// Delete Group Area /// </summary> /// <param name="groupCd"></param> /// <param name="forUser"></param> /// <returns></returns> public bool DeleteGroupArea(long groupCd = 0, int forUser = 0) { ManageDistrictDa dataAccess = new ManageDistrictDa(); int result = 0; using (var transaction = new TransactionScope()) { try { result = dataAccess.DeleteGroupArea(groupCd, forUser); var result2 = dataAccess.DeleteAllTownInArea(groupCd, forUser); if (result > 0) { transaction.Complete(); } } catch (Exception ex) { transaction.Dispose(); result = -1; throw new Exception(ex.Message, ex); } finally { transaction.Dispose(); } } return(result > 0); }
//check exist //public ActionResult CheckExistDistrictCd(int cityCd, int districtCd, int districtCdOld) //{ // if (Request.IsAjaxRequest()) // { // // Declare new DataAccess object // ManageDistrictDa dataAccess = new ManageDistrictDa(); // var exist = dataAccess.CheckExistDistrictCd(cityCd, districtCd, districtCdOld); // JsonResult result = Json(new // { // exist // }, JsonRequestBehavior.AllowGet); // return result; // } // return new EmptyResult(); //} #endregion #region LIST // GET: /AdminManageDistrict/ public ActionResult DistrictList() { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; if (currentUser == null || currentUser.IsAdmin == false) { return(RedirectToAction("Login", "Login")); } CityModel model = new CityModel(); CommonService comService = new CommonService(); ManageDistrictDa dataAccess = new ManageDistrictDa(); model.CITY_LIST = dataAccess.getCityList(Constant.CityLevel.City).ToList().Select( f => new SelectListItem { Value = f.ID.ToString(), Text = f.Name }).ToList(); model.CITY_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "" }); return(View(model)); }
public bool DeleteTownInArea(long cityCd = 0, long districtCd = 0, long townCD = 0, int forUser = 0) { ManageDistrictDa dataAccess = new ManageDistrictDa(); int result = 0; using (var transaction = new TransactionScope()) { try { result = dataAccess.DeleteTownInArea(cityCd, districtCd, townCD, forUser); if (result > 0) { transaction.Complete(); } } catch (Exception ex) { transaction.Dispose(); result = -1; throw new Exception(ex.Message, ex); } finally { transaction.Dispose(); } } return(result > 0); }
public IEnumerable <MstDistrictEx> SearchDistrictList(DataTableModel dt, DistrictModel model, out int total_row) { ManageDistrictDa dataAccess = new ManageDistrictDa(); IEnumerable <MstDistrictEx> results = dataAccess.SearchDistrictList(dt, model, out total_row); return(results); }
public bool DeleteDistrict(long CITY_CD, long DISTRICT_CD) { ManageDistrictDa dataAccess = new ManageDistrictDa(); int result = 0; using (var transaction = new TransactionScope()) { try { result = dataAccess.DeleteDistrict(CITY_CD, DISTRICT_CD); if (result > 0) { transaction.Complete(); } } catch (Exception ex) { transaction.Dispose(); result = -1; throw new Exception(ex.Message, ex); } finally { transaction.Dispose(); } } return(result > 0); }
public ActionResult UpdateUser() { UserModel model = new UserModel(); CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; if (currentUser == null) { return(RedirectToAction("Login", "Login")); } //CommonService comService = new CommonService(); UserDa dataAccess = new UserDa(); if (currentUser.ID > 0) { UserModel infor = new UserModel(); infor = dataAccess.getInfoUser(currentUser.ID); model = infor != null ? infor : model; } int HaNoiCity = 1; ManageDistrictDa daDistrict = new ManageDistrictDa(); model.DISTRICT_LIST = daDistrict.getDistrictList(HaNoiCity).ToList().Select( f => new SelectListItem { Value = f.ID.ToString(), Text = f.Name }).ToList(); model.DISTRICT_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "Chọn Quận/huyện" }); return(View(model)); }
public ActionResult DistrictEdit(int CityCd = 0, int DistrictCd = 0) { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; var authorityList = currentUser != null ? currentUser.USER_AUTHORITY : 0; if (currentUser == null || authorityList != 2) { return(RedirectToAction("Login", "UserAccount")); } DistrictModel model = new DistrictModel(); CommonService comService = new CommonService(); ManageDistrictDa dataAccess = new ManageDistrictDa(); if (CityCd > 0 && DistrictCd > 0) { model = dataAccess.getInfoDistrict(CityCd, DistrictCd); } model.CITY_LIST = comService.GetCityList().ToList().Select( f => new SelectListItem { Value = f.CITY_CD.ToString(), Text = f.CITY_NAME }).ToList(); model.CITY_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "" }); return(View(model)); }
public long UpdateGroupArea(GroupAreaModel model) { long res = 0; // Declare new DataAccess object ManageDistrictDa dataAccess = new ManageDistrictDa(); using (var transaction = new TransactionScope()) { MstGroupArea entity = new MstGroupArea(); entity.GROUP_CD = model.GROUP_CD; entity.GROUP_NAME = model.GROUP_NAME; entity.FOR_USER = model.FOR_USER; entity.DEL_FLG = DeleteFlag.NON_DELETE; entity.INS_DATE = Utility.GetCurrentDateTime(); entity.UPD_DATE = Utility.GetCurrentDateTime(); res = dataAccess.UpdateGroupArea(entity); if (res <= 0) { transaction.Dispose(); } transaction.Complete(); } return(res); }
public ActionResult OrderList() { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; if (currentUser == null || currentUser.IsAdmin == false) { return(RedirectToAction("Login", "Login")); } ManageDistrictDa dataAccess = new ManageDistrictDa(); AdminOrderList model = new AdminOrderList(); CommonService comService = new CommonService(); CommonController comControl = new CommonController(); int HaNoiCity = 1; model.DISTRICT_LIST = dataAccess.getDistrictList(HaNoiCity).ToList().Select( f => new SelectListItem { Value = f.ID.ToString(), Text = f.Name }).ToList(); model.DISTRICT_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "Chọn Quận/huyện" }); model.SORT_TYPE_LIST = UtilityServices.UtilityServices.SortTypeList(); model.STATUS_SELECT_LIST = UtilityServices.UtilityServices.getListStatusAll(); model.TO_DATE = DateTime.Now; model.FROM_DATE = model.TO_DATE.Value.AddDays(-15); return(View(model)); }
// GET: UserManageOrder #region LIST ORDER USER public ActionResult ManageOrderList(AdminOrderList condition, int?page) { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; if (currentUser == null) { return(RedirectToAction("Login", "Login")); } ManageDistrictDa dataAccess = new ManageDistrictDa(); AdminOrderList model = new AdminOrderList(); CommonService comService = new CommonService(); CommonController comControl = new CommonController(); model.SORT_TYPE_LIST = UtilityServices.UtilityServices.SortTypeList(); model.STATUS_SELECT_LIST = UtilityServices.UtilityServices.getListStatusAll(); model.TO_DATE = DateTime.Now; model.FROM_DATE = model.TO_DATE.Value.AddDays(-15); AdminOrderDa da = new AdminOrderDa(); UserOrderService service = new UserOrderService(); DataTableModel dt = new DataTableModel(); dt.iDisplayStart = 0; dt.iDisplayLength = 25; int total_row = 0; condition.UserID = currentUser.ID; var dataList = service.SearchOrderListbyUser(dt, condition, out total_row).ToList(); var totalDataNoneStatus = service.SearchOrderListTotalNoneStatus(dt, condition); for (int i = 0; i < dataList.Count(); i++) { dataList[i].ORDER_STATUS_TEXT = OrderStatus.Items[dataList[i].Status].ToString(); dataList[i].CREATE_DATE_STRING = dataList[i].CreatedDate.HasValue ? dataList[i].CreatedDate.Value.ToString("dd/MM/yyyy hh:mm") : ""; var getProductDetail = da.getlistProductByOrder(dataList[i].ID).Take(3); List <string> listName = new List <string>(); foreach (var det in getProductDetail) { det.Name = det.Name.Length > 20 ? det.Name.Substring(0, 20) : det.Name; listName.Add(det.Name); } if (listName.Count > 0) { dataList[i].Product_Name = string.Join(", ", listName); } } if (Request.HttpMethod != "GET") { page = 1; } int Pagesize = 20; // tạo biến số trang hiện tại int PageNumber = (page ?? 1); return(View(dataList.ToPagedList(PageNumber, Pagesize))); }
public ActionResult DatHang() { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; OrderModel model = new OrderModel(); ManageDistrictDa dataAccess = new ManageDistrictDa(); if (currentUser == null) { return(RedirectToAction("Login", "Login")); } else { int HaNoiCity = 1; model.DISTRICT_LIST = dataAccess.getDistrictList(HaNoiCity).ToList().Select( f => new SelectListItem { Value = f.ID.ToString(), Text = f.Name }).ToList(); model.DISTRICT_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "Chọn Quận/huyện" }); model.UserID = currentUser.ID; model.UserName = currentUser.UserName; model.Receive_District = currentUser.USER_DISTRICT; model.Receive_Address = currentUser.USER_ADDRESS; model.Email = currentUser.Email; model.Receive_Phone = currentUser.Phone; List <ItemGioHang> lstGioHang = LayGioHang(); ViewBag.lstGioHangItem = lstGioHang; model.TongSoLuong = TinhTongSoLuong(); model.TongTienHang = TongTien(); if (model.Receive_District > 0) { var getDistrict = dataAccess.getCityByID(model.Receive_District); model.PriceShip = getDistrict != null ? (int)getDistrict.PriceShip.Value : 0; } ManagePromotionDa promotionDa = new ManagePromotionDa(); var getPromotion = promotionDa.getPromotionForDiscount(model.TongTienHang); if (getPromotion != null) { var discount = getPromotion.Discount.HasValue ? getPromotion.Discount.Value : 0; model.PriceDiscountTotal = (int)(model.TongTienHang * discount / 100); } model.PriceTotal = model.TongTienHang + model.PriceShip - model.PriceDiscountTotal; } return(View(model)); }
public ActionResult OrderDetail(string Code) { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; if (currentUser == null) { return(RedirectToAction("Login", "Login")); } AdminOrderDa da = new AdminOrderDa(); UserOrderService service = new UserOrderService(); //ViewOrderModel model = new ViewOrderModel(); IList <ItemGioHang> listDetail = new List <ItemGioHang>(); var getOrder = da.getOrderByCode(Code); if (getOrder != null) { var getOrderDetail = da.getOrderDetail(getOrder.ID); foreach (var item in getOrderDetail) { ItemGioHang sanpham = new ItemGioHang(item.ProductID); sanpham.SoLuong = item.Quantity.HasValue ? item.Quantity.Value : 0; sanpham.DonGia = item.Price.HasValue ? item.Price.Value : 0; sanpham.TienHang = sanpham.DonGia * sanpham.SoLuong; listDetail.Add(sanpham); } ViewBag.listDetail = listDetail; getOrder.ORDER_STATUS_TEXT = OrderStatus.Items[getOrder.Status].ToString(); getOrder.PAYMENT_METHOD_TEXT = PaymentMethodType.Items[getOrder.PaymentMethod].ToString(); getOrder.PAID_TEXT = getOrder.Paid == true ? PayStatus.Items[1].ToString() : PayStatus.Items[0].ToString(); int HaNoiCity = 1; ManageDistrictDa dataAccess = new ManageDistrictDa(); getOrder.DISTRICT_LIST = dataAccess.getDistrictList(HaNoiCity).ToList().Select( f => new SelectListItem { Value = f.ID.ToString(), Text = f.Name }).ToList(); getOrder.DISTRICT_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "Chọn Quận/huyện" }); } else { return(HttpNotFound()); } return(View(getOrder)); }
public IEnumerable <MstGroupArea> SearchGroupAreatList(DataTableModel dt, GroupAreaModel model, out int total_row) { ManageDistrictDa dataAccess = new ManageDistrictDa(); if (model.CITY_CD != null && model.CITY_CD > 0) { var getListGroup = dataAccess.getListGroupForSearch(model).ToList(); if (getListGroup.Count > 0) { model.GROUP_CD_LIST = string.Join("','", getListGroup.ToArray()); } } IEnumerable <MstGroupArea> results = dataAccess.SearchGroupAreatList(dt, model, out total_row); return(results); }
public long UpdateTownInArea(GroupTown model, int forUser) { long res = 0; // Declare new DataAccess object ManageDistrictDa dataAccess = new ManageDistrictDa(); using (var transaction = new TransactionScope()) { res = dataAccess.UpdateTownInArea(model, forUser); if (res <= 0) { transaction.Dispose(); } transaction.Complete(); } return(res); }
public ActionResult getDictrictByID(long districtID) { if (Request.IsAjaxRequest()) { // Declare new DataAccess object ManageDistrictDa dataAccess = new ManageDistrictDa(); var exist = dataAccess.getCityByID(districtID); JsonResult result = Json(new { exist }, JsonRequestBehavior.AllowGet); return(result); } return(new EmptyResult()); }
//check exist public ActionResult CheckExistDistrictCd(int cityCd, int districtCd, int districtCdOld) { if (Request.IsAjaxRequest()) { // Declare new DataAccess object ManageDistrictDa dataAccess = new ManageDistrictDa(); var exist = dataAccess.CheckExistDistrictCd(cityCd, districtCd, districtCdOld); JsonResult result = Json(new { exist }, JsonRequestBehavior.AllowGet); return(result); } return(new EmptyResult()); }
public long UpdateDistrict(DistrictModel model) { long res = 0; // Declare new DataAccess object ManageDistrictDa dataAccess = new ManageDistrictDa(); using (var transaction = new TransactionScope()) { res = dataAccess.UpdateDistrict(model); if (res <= 0) { transaction.Dispose(); } transaction.Complete(); } return(res); }
// GET: ManageDistrict #region REGISTER/ UPDATE public ActionResult DistrictEdit(int CityCd = 0, int DistrictCd = 0) { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; if (currentUser == null || currentUser.IsAdmin == false) { return(RedirectToAction("Login", "Login")); } CityModel model = new CityModel(); CommonService comService = new CommonService(); ManageDistrictDa dataAccess = new ManageDistrictDa(); if (DistrictCd > 0) { var info = dataAccess.getCityByID(DistrictCd); if (info != null) { model.ID = info.ID; model.CITY_ID = info.Parent_Code.HasValue ? info.Parent_Code.Value : 0; model.Level = info.Level; model.Name = info.Name; model.PriceShip = info.PriceShip; model.Status = info.Status; model.CreatedDate = info.CreatedDate; model.ModifiedDate = info.ModifiedDate; } } model.CITY_LIST = dataAccess.getCityList(Constant.CityLevel.City).ToList().Select( f => new SelectListItem { Value = f.ID.ToString(), Text = f.Name }).ToList(); model.CITY_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "" }); return(View(model)); }
public long UpdateCity(CityModel model) { long res = 0; // Declare new DataAccess object ManageDistrictDa dataAccess = new ManageDistrictDa(); using (var transaction = new TransactionScope()) { try { TblCity city = new TblCity(); city.ID = model.ID; city.Parent_Code = model.CITY_ID; city.Name = model.Name; city.Level = model.Level; city.Status = model.Status; city.PriceShip = model.PriceShip; city.del_flg = Constant.DeleteFlag.NON_DELETE; res = dataAccess.UpdateCity(city); if (res <= 0) { transaction.Dispose(); } transaction.Complete(); } catch (Exception ex) { throw new Exception(ex.Message, ex); } finally { transaction.Dispose(); } } return(res); }
public ActionResult UserList() { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; if (currentUser == null || currentUser.IsAdmin == false) { return(RedirectToAction("Login", "Login")); } UserModel model = new UserModel(); CommonService comService = new CommonService(); var tmpCondition = GetRestoreData() as UserModel; if (tmpCondition != null) { model = tmpCondition; } UserDa dataAccess = new UserDa(); int HaNoiCity = 1; ManageDistrictDa daDistrict = new ManageDistrictDa(); model.DISTRICT_LIST = daDistrict.getDistrictList(HaNoiCity).ToList().Select( f => new SelectListItem { Value = f.ID.ToString(), Text = f.Name }).ToList(); model.DISTRICT_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "Chọn Quận/huyện" }); return(View(model)); }
public ActionResult GroupDistrictEdit(long GroupCd = 0) { CmnEntityModel currentUser = Session["CmnEntityModel"] as CmnEntityModel; var authorityList = currentUser != null ? currentUser.USER_AUTHORITY : 0; if (currentUser == null || authorityList != 2) { return(RedirectToAction("Login", "UserAccount")); } GroupAreaModel model = new GroupAreaModel(); CommonService comService = new CommonService(); ManageDistrictDa dataAccess = new ManageDistrictDa(); model.LIST_TOWN = new List <GroupTown>(); if (GroupCd > 0) { model = dataAccess.getInfoGroupArea(GroupCd); var listTown = dataAccess.GetListTownInArea(model); if (listTown.Count() > 0) { model.LIST_TOWN = listTown.ToList(); foreach (var Town in model.LIST_TOWN) { if (model.FOR_USER == GroupForUser.Receive) { Town.DSP_ORDER = Town.DSP_ORDER_RECEIVE; Town.GROUP_CD = Town.GROUP_CD_RECEIVE; } else { Town.DSP_ORDER = Town.DSP_ORDER_SENDER; Town.GROUP_CD = Town.GROUP_CD_SENDER; } } model.LIST_TOWN = model.LIST_TOWN.OrderBy(i => i.DSP_ORDER).ToList(); } model.FOR_USER_TEXT = GroupForUser.Items[model.FOR_USER].ToString(); } model.CITY_LIST = comService.GetCityList().ToList().Select( f => new SelectListItem { Value = f.CITY_CD.ToString(), Text = f.CITY_NAME }).ToList(); //model.CITY_LIST.Insert(0, new SelectListItem { Value = Constant.DEFAULT_VALUE, Text = "" }); model.DISTRICT_LIST = comService.GetDistrictList().ToList().Select( f => new SelectListItem { Value = f.CITY_CD.ToString() + "_" + f.DISTRICT_CD.ToString(), Text = f.DISTRICT_NAME }).ToList(); model.TOWN_LIST = comService.GetTownList().ToList().Select( f => new SelectListItem { Value = f.CITY_CD.ToString() + "_" + f.DISTRICT_CD.ToString() + "_" + f.TOWN_CD.ToString(), Text = f.TOWN_NAME }).ToList(); ViewBag.GetGroupForUser = new SelectList(UtilityServices.UtilityServices.GetGroupForUser(), "Value", "Text"); return(View(model)); }