Exemplo n.º 1
0
        public ActionResult Create(ProjectViewModel model)
        {
            if (model.V3 != true)
            {
                return this.Json(new { result = Constants.UnSuccess });
            }

            return model.Id == 0 ? CreateData(model) : EditData(model);
        }
Exemplo n.º 2
0
        private JsonResult CreateData(ProjectViewModel model)
        {
            if (_service.ExistedCode(model.Project.vProjectID))
            {
                return Json(new { result = Constants.DuplicateCode });
            }

            if (_service.ExistedName(model.Project.vProjectName))
            {
                return Json(new { result = Constants.Duplicate });
            }

            try
            {
                model.Project.iEnable = true;
                model.Project.iCreated = model.LoginId;
                model.Project.dCreated = DateTime.Now;
                model.Project.dBeginDate = DateTime.ParseExact(model.dBeginDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                if (!string.IsNullOrEmpty(model.dEnd))
                {
                    model.Project.dEnd = DateTime.ParseExact(model.dEnd, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                }
                _service.Insert(model.Project);

                return Json(new { result = Constants.Success });
            }
            catch (Exception e)
            {
                Log.Error("Create New Project!", e);
                return Json(new { result = Constants.UnSuccess });
            }
        }
Exemplo n.º 3
0
        private JsonResult EditData(ProjectViewModel model)
        {
            if (model.CheckCode != model.Project.vProjectID)
            {
                if (_service.ExistedCode(model.Project.vProjectID))
                {
                    return Json(new { result = Constants.DuplicateCode });
                }
            }

            if (model.CheckName != model.Project.vProjectName)
            {
                if (_service.ExistedName(model.Project.vProjectName))
                {
                    return Json(new { result = Constants.Duplicate });
                }
            }

            var entity = _service.GetByKey(model.Project.Id);
            if (!Convert.ToBase64String(model.Project.Timestamp).Equals(Convert.ToBase64String(entity.Timestamp)))
            {
                return Json(new { result = Constants.DataJustChanged });
            }

            try
            {
                entity.vProjectID = model.Project.vProjectID;
                entity.vProjectName = model.Project.vProjectName;
                entity.vLocation = model.Project.vLocation;
                entity.vMainContact = model.Project.vMainContact;
                entity.vCompanyName = model.Project.vCompanyName;
                entity.dBeginDate = DateTime.ParseExact(model.dBeginDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                if (!string.IsNullOrEmpty(model.dEnd))
                {
                    entity.dEnd = DateTime.ParseExact(model.dEnd, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                }
                entity.ClientId = model.Project.ClientId;
                entity.CountryId = model.Project.CountryId;
                entity.StoreId = model.Project.StoreId;
                entity.StatusId = model.Project.StatusId;
                entity.vDescription = model.Project.vDescription;
                entity.iModified = model.LoginId;
                entity.dModified = DateTime.Now;
                this._service.Update(entity);

                return Json(new { result = Constants.Success });
            }
            catch (Exception e)
            {
                Log.Error("Update Project!", e);
                return Json(new { result = Constants.UnSuccess });
            }
        }
Exemplo n.º 4
0
 public ActionResult TransactionStock(int page, int size, int project, string type, string fd, string td)
 {
     var totalRecord = _systemService.CountListTransactionStockByProject(page, size, project, type, fd, td);
     var totalTemp = Convert.ToDecimal(totalRecord) / Convert.ToDecimal(size);
     var totalPages = Convert.ToInt32(Math.Ceiling(totalTemp));
     var model = new ProjectViewModel
     {
         StockQuantityManagementResults = _systemService.ListTransactionStockByProject(page, size, project, type, fd, td),
         TotalRecords = Convert.ToInt32(totalRecord),
         TotalPages = totalPages,
         CurrentPage = page,
         PageSize = size
     };
     return PartialView("_TransactionStockPartial", model);
 }
Exemplo n.º 5
0
        public ActionResult LoadProject(int page, int size, string projectCode, string projectName, int country, int status, int client, string fd, string td, string enable)
        {
            var userName = System.Web.HttpContext.Current.User.Identity.Name;
            var totalRecord = _service.ListConditionCount(page, size, projectCode, projectName, country, status, client, fd, td, enable);
            var totalTemp = Convert.ToDecimal(totalRecord) / Convert.ToDecimal(size);
            int totalPages = size == 1000 ? 1 : Convert.ToInt32(Math.Ceiling(totalTemp));
            var model = new ProjectViewModel
            {
                UserLogin = _systemService.GetUserAndRole(0, userName),
                ProjectGetListResults = _service.ListCondition(page, size, projectCode, projectName, country, status, client, fd, td, enable),
                TotalRecords = Convert.ToInt32(totalRecord),
                TotalPages = totalPages,
                CurrentPage = page,
                PageSize = size
            };

            return PartialView("_ProjectPartial", model);
        }
Exemplo n.º 6
0
 public ActionResult Index()
 {
     var userName = System.Web.HttpContext.Current.User.Identity.Name;
     var user = this._systemService.GetUserAndRole(0, userName);
     if (user == null) return RedirectToAction("Index", "Login");
     if (user.ProjectR == 0) return RedirectToAction("Index", "Home");
     var viewModel = new ProjectViewModel
     {
         UserLogin = user,
         Countries = new SelectList(this._systemService.CountryList(), "Id", "Name"),
         Client = new SelectList(this._systemService.ClientProjectList(), "Id", "Name"),
         Suppervisor = new SelectList(this._systemService.SuppervisorList(), "Id", "Name"),
         StatusProject = new SelectList(this._systemService.GetLookUp(Constants.LuProjectStatus), Constants.LookUpKey, Constants.LookUpValue),
         Projects = new SelectList(this._systemService.ProjectList(), "Id", "vProjectID")
     };
     return View(viewModel);
 }
Exemplo n.º 7
0
        public ActionResult Create(int? id)
        {
            var userName = System.Web.HttpContext.Current.User.Identity.Name;
            var user = _systemService.GetUserAndRole(0, userName);
            if (user == null)
            {
                return RedirectToAction("Index", "Login");
            }

            if (user.ProjectR == 0)
            {
                return RedirectToAction("Index", "Home");
            }

            var item = new WAMS_PROJECT
                           {
                               dBeginDate = DateTime.Now
                           };

            if (id.HasValue)
            {
                // If have eror use store procedure
                item = _service.GetByKeySp(id.Value);
            }

            var model = new ProjectViewModel
            {
                Id = item.Id,
                vProjectID = item.vProjectID,
                vProjectName = item.vProjectName,
                vLocation = item.vLocation,
                vMainContact = item.vMainContact,
                vCompanyName = item.vCompanyName,
                dBeginDate = item.dBeginDate.ToString("dd/MM/yyyy"),
                ClientId = item.ClientId,
                CountryId = item.CountryId,
                StoreId = item.StoreId,
                StatusId = item.StatusId,
                vDescription = item.vDescription,
                Timestamp = item.Timestamp,
                iCreated = item.iCreated,
                dCreated = item.dCreated,
                Countries = new SelectList(this._systemService.CountryList(), "Id", "Name"),
                Client = new SelectList(this._systemService.ClientProjectList(), "Id", "Name"),
                Suppervisor = new SelectList(this._systemService.SuppervisorList(), "vWorkerID", "Suppervisor"),
                StatusProject = new SelectList(this._systemService.GetLookUp(Constants.LuProjectStatus), Constants.LookUpKey, Constants.LookUpValue),
                UserLogin = user
            };

            if (item.dEnd.HasValue)
            {
                model.dEnd = item.dEnd.Value.ToString("dd/MM/yyyy");
            }
            return View(model);
        }
Exemplo n.º 8
0
 public ActionResult Detail(int id)
 {
     var userName = System.Web.HttpContext.Current.User.Identity.Name;
     var user = this._systemService.GetUserAndRole(0, userName);
     if (user == null) return RedirectToAction("Index", "Login");
     if (user.ProjectR == 0) return RedirectToAction("Index", "Home");
     var item = _service.CustomEntity(id);
     var viewModel = new ProjectViewModel
     {
         ProjectCustom = item,
         UserLogin = user
     };
     return View(viewModel);
 }