コード例 #1
0
ファイル: SuppliesBLL.cs プロジェクト: paddy235/ERCHTMS
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, SuppliesEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #2
0
 public ActionResult SaveForm(string keyValue, SuppliesEntity entity)
 {
     try
     {
         Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current();
         if (string.IsNullOrWhiteSpace(entity.SUPPLIESCODE))
         {
             entity.SUPPLIESCODE = suppliesbll.GetMaxCode();
         }
         suppliesbll.SaveForm(keyValue, entity);
         var entityInorOut = new InoroutrecordEntity
         {
             USERID            = user.UserId,
             USERNAME          = user.UserName,
             DEPARTID          = user.DeptId,
             DEPARTNAME        = user.DeptName,
             INOROUTTIME       = DateTime.Now,
             SUPPLIESCODE      = entity.SUPPLIESCODE,
             SUPPLIESTYPE      = entity.SUPPLIESTYPE,
             SUPPLIESTYPENAME  = entity.SUPPLIESTYPENAME,
             SUPPLIESNAME      = entity.SUPPLIESNAME,
             SUPPLIESUNTIL     = entity.SUPPLIESUNTIL,
             SUPPLIESUNTILNAME = entity.SUPPLIESUNTILNAME,
             NUM          = entity.NUM,
             STORAGEPLACE = entity.STORAGEPLACE,
             MOBILE       = entity.MOBILE,
             SUPPLIESID   = entity.ID,
             STATUS       = 0
         };
         var inoroutrecordbll = new InoroutrecordBLL();
         if (keyValue == "")
         {
             inoroutrecordbll.SaveForm("", entityInorOut);
         }
         return(Success("操作成功。"));
     }
     catch (Exception ex)
     {
         return(Error(ex.ToString()));
     }
 }
コード例 #3
0
 public object EditSupplies([FromBody] JObject json)
 {
     try
     {
         string  res    = json.Value <string>("json");
         dynamic dy     = JsonConvert.DeserializeObject <ExpandoObject>(res);
         string  userid = dy.userid;
         string  id     = dy.id ?? "";
         //获取用户基本信息
         OperatorProvider.AppUserId = userid;  //设置当前用户
         Operator curUser = OperatorProvider.Provider.Current();
         if (null == curUser)
         {
             return(new { code = -1, count = 0, info = "请求失败,请登录!" });
         }
         string roleNames = curUser.RoleName;
         var    entity    = new SuppliesEntity
         {
             SUPPLIESCODE     = dy.suppliescode,
             SUPPLIESTYPE     = dy.suppliestype,
             SUPPLIESTYPENAME = dy.suppliestypename,
             MOBILE           = dy.mobile,
             DEPARTID         = dy.departid,
             DEPARTNAME       = dy.departname,
             USERID           = dy.userid,
             USERNAME         = dy.username,
             MAINFUN          = dy.mianfun,
             STORAGEPLACE     = dy.storageplace,
             SUPPLIESUNTIL    = dy.suppliesuntil,
             NUM = dy.num
         };
         suppliesbll.SaveForm(id, entity);
     }
     catch (Exception)
     {
         return(new { code = -0, count = 0, info = "保存失败" });
     }
     return(new { code = 0, count = 0, info = "保存成功" });
 }
コード例 #4
0
        public string ImportSuppliesData()
        {
            int    error   = 0;
            string message = "请选择格式正确的文件再导入!";

            string falseMessage = "";
            int    count        = HttpContext.Request.Files.Count;

            if (count > 0)
            {
                count = 0;
                HttpPostedFileBase file = HttpContext.Request.Files[0];
                if (string.IsNullOrEmpty(file.FileName))
                {
                    return(message);
                }
                if (!(file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xls") || file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xlsx")))
                {
                    return(message);
                }

                string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName);
                file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName));
                Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook();
                wb.Open(Server.MapPath("~/Resource/temp/" + fileName), file.FileName.Substring(file.FileName.IndexOf('.')).Contains("xlsx") ? Aspose.Cells.FileFormatType.Excel2007Xlsx : Aspose.Cells.FileFormatType.Excel2003);
                Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current();

                //判断表头是否正确,以免使用错误模板
                var sheet = wb.Worksheets[0];
                if (sheet.Cells[2, 0].StringValue != "物资类型" || sheet.Cells[2, 1].StringValue != "物资名称" || sheet.Cells[2, 2].StringValue != "规格型号" || sheet.Cells[2, 3].StringValue != "数量" ||
                    sheet.Cells[2, 4].StringValue != "单位" || sheet.Cells[2, 5].StringValue != "存放区域" || sheet.Cells[2, 6].StringValue != "存放地点" || sheet.Cells[2, 7].StringValue != "主要功能")
                {
                    return(message);
                }
                //List<SuppliesEntity> slist = new List<SuppliesEntity>();
                for (int i = 3; i <= sheet.Cells.MaxDataRow; i++)
                {
                    count++;
                    SuppliesEntity entity = new SuppliesEntity();
                    if (string.IsNullOrWhiteSpace(sheet.Cells[i, 1].StringValue))
                    {
                        falseMessage += "</br>" + "第" + (i + 1) + "行物资名称不能为空,未能导入.";
                        error++;
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(sheet.Cells[i, 3].StringValue))
                    {
                        falseMessage += "</br>" + "第" + (i + 1) + "行数量不能为空,未能导入.";
                        error++;
                        continue;
                    }
                    entity.SUPPLIESTYPENAME = sheet.Cells[i, 0].StringValue;
                    var item = new DataItemDetailBLL().GetDataItemListByItemCode("'MAE_SUPPLIESTYPE'").Where(x => x.ItemName == entity.SUPPLIESTYPENAME).ToList().FirstOrDefault();
                    if (item != null)
                    {
                        entity.SUPPLIESTYPE = item.ItemValue;
                    }
                    entity.SUPPLIESNAME      = sheet.Cells[i, 1].StringValue;
                    entity.Models            = sheet.Cells[i, 2].StringValue;
                    entity.NUM               = Convert.ToInt32(sheet.Cells[i, 3].StringValue);
                    entity.SUPPLIESUNTILNAME = sheet.Cells[i, 4].StringValue;
                    var itemUnit = new DataItemDetailBLL().GetDataItemListByItemCode("'MAE_SUPPLIESUNTIL'").Where(x => x.ItemName == entity.SUPPLIESUNTILNAME).ToList().FirstOrDefault();
                    if (itemUnit != null)
                    {
                        entity.SUPPLIESUNTIL = itemUnit.ItemValue;
                    }
                    if (!string.IsNullOrWhiteSpace(sheet.Cells[i, 5].StringValue))
                    {
                        DistrictEntity district = districtbll.GetDistrict(user.OrganizeId, sheet.Cells[i, 5].StringValue);
                        if (district == null)
                        {
                            falseMessage += "</br>" + "第" + (i + 1) + "行区域不是系统内区域,未能导入.";
                            error++;
                            continue;
                        }
                        else
                        {
                            entity.WorkAreaCode = district.DistrictCode;
                            entity.WorkAreaName = district.DistrictName;
                        }
                    }
                    entity.STORAGEPLACE = sheet.Cells[i, 6].StringValue;
                    entity.MAINFUN      = sheet.Cells[i, 7].StringValue;
                    entity.CREATEDATE   = DateTime.Now;
                    entity.DEPARTID     = user.DeptId;
                    entity.DEPARTNAME   = user.DeptName;
                    entity.USERID       = user.UserId;
                    entity.USERNAME     = user.UserName;
                    entity.SUPPLIESCODE = suppliesbll.GetMaxCode();
                    //entity.Create();
                    suppliesbll.SaveForm(entity.ID, entity);
                    var entityInorOut = new InoroutrecordEntity
                    {
                        USERID            = entity.USERID,
                        USERNAME          = entity.USERNAME,
                        DEPARTID          = entity.DEPARTID,
                        DEPARTNAME        = entity.DEPARTNAME,
                        INOROUTTIME       = DateTime.Now,
                        SUPPLIESCODE      = entity.SUPPLIESCODE,
                        SUPPLIESTYPE      = entity.SUPPLIESTYPE,
                        SUPPLIESTYPENAME  = entity.SUPPLIESTYPENAME,
                        SUPPLIESNAME      = entity.SUPPLIESNAME,
                        SUPPLIESUNTIL     = entity.SUPPLIESUNTIL,
                        SUPPLIESUNTILNAME = entity.SUPPLIESUNTILNAME,
                        NUM          = entity.NUM,
                        STORAGEPLACE = entity.STORAGEPLACE,
                        MOBILE       = entity.MOBILE,
                        SUPPLIESID   = entity.ID,
                        STATUS       = 0
                    };
                    var inoroutrecordbll = new InoroutrecordBLL();
                    inoroutrecordbll.SaveForm("", entityInorOut);

                    //slist.Add(entity);
                }

                message = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条。";
                if (error > 0)
                {
                    message += "</br>" + falseMessage;
                }
            }
            return(message);
        }
コード例 #5
0
 public object AddSupplies([FromBody] JObject json)
 {
     try
     {
         string  res    = json.Value <string>("json");
         dynamic dy     = JsonConvert.DeserializeObject <ExpandoObject>(res);
         string  userid = dy.userid;
         //获取用户基本信息
         OperatorProvider.AppUserId = userid;  //设置当前用户
         Operator curUser = OperatorProvider.Provider.Current();
         if (null == curUser)
         {
             return(new { code = -1, count = 0, info = "请求失败,请登录!" });
         }
         var entity = new SuppliesEntity
         {
             SUPPLIESCODE     = suppliesbll.GetMaxCode(),
             SUPPLIESTYPE     = dy.SuppliesType,
             SUPPLIESTYPENAME = dy.SuppliesTypeName,
             SUPPLIESNAME     = dy.SuppliesName,
             NUM = int.Parse(dy.Num.ToString()),
             SUPPLIESUNTILNAME = dy.SuppliesUnitName,
             SUPPLIESUNTIL     = dy.SuppliesUnit,
             STORAGEPLACE      = dy.StoragePlace,
             DEPARTID          = dy.DepartmentId,
             DEPARTNAME        = dy.DepartmentName,
             USERID            = dy.ChargeUserId,
             USERNAME          = dy.ChargeUserName,
             MOBILE            = dy.Mobile,
             CREATEDATE        = dy.CreateTime,
             MAINFUN           = dy.MainFun,
             FILES             = dy.Files,
         };
         suppliesbll.SaveForm("", entity);
         var entityInorOut = new InoroutrecordEntity
         {
             USERID            = entity.USERID,
             USERNAME          = entity.USERNAME,
             DEPARTID          = entity.DEPARTID,
             DEPARTNAME        = entity.DEPARTNAME,
             INOROUTTIME       = DateTime.Now,
             SUPPLIESCODE      = entity.SUPPLIESCODE,
             SUPPLIESTYPE      = entity.SUPPLIESTYPE,
             SUPPLIESTYPENAME  = entity.SUPPLIESTYPENAME,
             SUPPLIESNAME      = entity.SUPPLIESNAME,
             SUPPLIESUNTIL     = entity.SUPPLIESUNTIL,
             SUPPLIESUNTILNAME = entity.SUPPLIESUNTILNAME,
             NUM          = entity.NUM,
             STORAGEPLACE = entity.STORAGEPLACE,
             MOBILE       = entity.MOBILE,
             SUPPLIESID   = entity.ID,
             STATUS       = 0
         };
         var inoroutrecordbll = new InoroutrecordBLL();
         inoroutrecordbll.SaveForm("", entityInorOut);
     }
     catch (Exception)
     {
         return(new { code = -0, count = 0, info = "保存失败" });
     }
     return(new { code = 0, count = 0, info = "保存成功" });
 }