public ActionResult GetByConditionPerPage(string ast_id, string DepartmentID,
                                                  string ast_from_user, string ast_fit_date)
        {
            PropertyAppropriationDTO propertyAppropriation = new PropertyAppropriationDTO();

            propertyAppropriation.ast_id        = ast_id;
            propertyAppropriation.DepartmentID  = DepartmentID;
            propertyAppropriation.ast_from_user = ast_from_user;
            propertyAppropriation.ast_fit_date  = ast_fit_date;
            PropertyAppropriation condition = PropertyAppropriationDTOMapper.MapFromDTO(propertyAppropriation);
            IList list = ManagerFactory.PropertyAppropriationManager.GetByCondition(condition);

            List <PropertyAppropriationDTO> arr    = new List <PropertyAppropriationDTO>();
            Dictionary <String, Object>     result = new Dictionary <String, Object>();
            int sIndex   = this.Request["start"] == null ? 0 : int.Parse(this.Request["start"]);
            int pageSize = this.Request["limit"] == null ? list.Count : int.Parse(this.Request["limit"]);

            for (int i = 0; i < pageSize && (i + sIndex) < list.Count; i++)
            {
                arr.Add(PropertyAppropriationDTOMapper.MapToDTO((PropertyAppropriation)list[i + sIndex]));
            }
            result.Add("rows", arr);
            result.Add("total", list.Count);
            return(this.Json(result));
        }
 public static PropertyAppropriationDTO MapToDTO(PropertyAppropriation model)
 {
     PropertyAppropriationDTO dto = new PropertyAppropriationDTO();
     dto.ast_main_id = model.ast_main_id;
     dto.ast_id = model.ast_id;
     dto.DepartmentID = model.Department == null ? "" : model.Department.DepartmentID;
     dto.DepartmentName = model.Department == null ? "" : model.Department.DepartmentName;
     dto.ast_from_user = model.ast_from_user;
     dto.ast_fit_date = model.ast_fit_date.ToString("yyyy/MM/dd");
     dto.ast_fit_reason = model.ast_fit_reason;
     return dto;
 }
Example #3
0
        public static PropertyAppropriationDTO MapToDTO(PropertyAppropriation model)
        {
            PropertyAppropriationDTO dto = new PropertyAppropriationDTO();

            dto.ast_main_id    = model.ast_main_id;
            dto.ast_id         = model.ast_id;
            dto.DepartmentID   = model.Department == null ? "" : model.Department.DepartmentID;
            dto.DepartmentName = model.Department == null ? "" : model.Department.DepartmentName;
            dto.ast_from_user  = model.ast_from_user;
            dto.ast_fit_date   = model.ast_fit_date.ToString("yyyy/MM/dd");
            dto.ast_fit_reason = model.ast_fit_reason;
            return(dto);
        }
 public static PropertyAppropriation MapFromDTO(PropertyAppropriationDTO dto)
 {
     PropertyAppropriation propertyAppropriation = new PropertyAppropriation();
     propertyAppropriation.ast_main_id = dto.ast_main_id;
     propertyAppropriation.ast_id  = dto.ast_id ;
     propertyAppropriation.Department = dto.DepartmentID == null ? null : ManagerFactory.DepartmentManager.GetDepartment(dto.DepartmentID);
     propertyAppropriation.ast_from_user = dto.ast_from_user;
     if (!string.IsNullOrEmpty(dto.ast_fit_date))
     {
         propertyAppropriation.ast_fit_date = DateTime.Parse(dto.ast_fit_date);
     }
     propertyAppropriation.ast_fit_reason = dto.ast_fit_reason;
     return propertyAppropriation;
 }
        public ActionResult UpdateProperty(string ast_id, string DepartmentID, string ast_user,
                                           string ast_fit_reason)
        {
            var rdto = new ResultDTO();

            PropertyAppropriationDTO propertyAppropriation = new PropertyAppropriationDTO();

            propertyAppropriation.ast_id = ast_id;

            Property p = ManagerFactory.PropertyManager.GetProperty(ast_id);

            if (p.Department == null)
            {
                propertyAppropriation.DepartmentID = "99999999";
            }
            else
            {
                propertyAppropriation.DepartmentID = p.Department.DepartmentID;
            }
            if (p.ast_user == null)
            {
                propertyAppropriation.ast_from_user = "******";
            }
            else
            {
                propertyAppropriation.ast_from_user = p.ast_user;
            }
            propertyAppropriation.ast_fit_reason = ast_fit_reason;
            propertyAppropriation.ast_fit_date   = DateTime.Now.ToString();

            p.ast_user   = ast_user;
            p.Department = ManagerFactory.DepartmentManager.GetDepartment(DepartmentID);

            Model.PropertyAppropriation proApp = PropertyAppropriationDTOMapper.MapFromDTO(propertyAppropriation);
            proApp.ast_fit_date = DateTime.Now;
            try
            {
                ManagerFactory.PropertyManager.SaveProperty(p, proApp);
                rdto.Message = "更新成功";
                rdto.Result  = true;
            }
            catch
            {
                rdto.Message = "更新失败";
                rdto.Result  = false;
            }

            return(this.Json(rdto));
        }
Example #6
0
        public static PropertyAppropriation MapFromDTO(PropertyAppropriationDTO dto)
        {
            PropertyAppropriation propertyAppropriation = new PropertyAppropriation();

            propertyAppropriation.ast_main_id   = dto.ast_main_id;
            propertyAppropriation.ast_id        = dto.ast_id;
            propertyAppropriation.Department    = dto.DepartmentID == null ? null : ManagerFactory.DepartmentManager.GetDepartment(dto.DepartmentID);
            propertyAppropriation.ast_from_user = dto.ast_from_user;
            if (!string.IsNullOrEmpty(dto.ast_fit_date))
            {
                propertyAppropriation.ast_fit_date = DateTime.Parse(dto.ast_fit_date);
            }
            propertyAppropriation.ast_fit_reason = dto.ast_fit_reason;
            return(propertyAppropriation);
        }