예제 #1
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, InoroutrecordEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #2
0
        public ActionResult SaveForm(string keyValue, InoroutrecordEntity entity)
        {
            inoroutrecordbll.SaveForm(keyValue, entity);
            var entitySup = suppliesbll.GetEntity(entity.SUPPLIESID);

            //入库
            if (entity.STATUS == 2)
            {
                entitySup.NUM += entity.NUM;
            }
            else
            {
                entitySup.NUM -= entity.NUM;
            }
            suppliesbll.SaveForm(entitySup.ID, entitySup);
            return(Success("操作成功。"));
        }
예제 #3
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()));
     }
 }
예제 #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 AddSuppliesInOrOutRecode([FromBody] JObject json)
        {
            try
            {
                string  res    = json.Value <string>("json");
                dynamic dy     = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userid = dy.userid;
                string  id     = dy.SuppliesId ?? "";
                //获取用户基本信息
                OperatorProvider.AppUserId = userid;  //设置当前用户
                Operator curUser = OperatorProvider.Provider.Current();
                if (null == curUser)
                {
                    return(new { code = -1, count = 0, info = "请求失败,请登录!" });
                }
                var entityInorOut = new InoroutrecordEntity
                {
                    SUPPLIESCODE     = dy.SuppliesCode,
                    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,
                    SUPPLIESID        = dy.SuppliesId,
                    INOROUTTIME       = dy.InOrOutTime,

                    STATUS    = int.Parse(dy.Status),
                    STATUNAME = dy.StatusName,
                };
                if (dy.Status == "1")
                {
                    entityInorOut.OUTREASON     = dy.OutReason;
                    entityInorOut.OUTREASONNAME = dy.OutReasonName;
                }
                var inoroutrecordbll = new InoroutrecordBLL();
                inoroutrecordbll.SaveForm("", entityInorOut);
                //修改对应的数据
                var entity = suppliesbll.GetEntity(id);
                if (dy.Status == "1")
                {
                    entity.NUM = entity.NUM - int.Parse(dy.Num.ToString());
                }
                if (dy.Status == "2")
                {
                    entity.NUM = entity.NUM + int.Parse(dy.Num.ToString());
                }
                suppliesbll.SaveForm(id, entity);
            }
            catch (Exception)
            {
                return(new { code = -0, count = 0, info = "保存失败" });
            }
            return(new { code = 0, count = 0, info = "保存成功" });
        }
예제 #6
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 = "保存成功" });
 }
예제 #7
0
        /// <summary>
        /// 审核表单
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="aentity"></param>
        /// <param name="DetailData"></param>
        public string AuditForm(string keyValue, AptitudeinvestigateauditEntity aentity, string DetailData)
        {
            string message = "";
            ManyPowerCheckEntity mpcEntity = new ManyPowerCheckEntity();
            Operator             curUser   = ERCHTMS.Code.OperatorProvider.Provider.Current();
            SuppliesacceptEntity entity    = GetEntity(keyValue);
            var res = DbFactory.Base().BeginTrans();

            try
            {
                aentity.APTITUDEID = keyValue;
                aentity.ID         = Guid.NewGuid().ToString();
                aentity.FlowId     = entity.FlowId;
                res.Insert <AptitudeinvestigateauditEntity>(aentity);
                if (aentity.AUDITRESULT == "0")
                {
                    var createdept = departmentservice.GetEntityByCode(entity.CreateUserDeptCode);
                    mpcEntity = manypowercheckservice.CheckAuditForNext(curUser, "应急物资领用审批", "", createdept.DepartmentId, "", keyValue);
                    if (null != mpcEntity)
                    {
                        entity.FlowId = mpcEntity.ID;
                    }
                    else
                    {
                        List <SuppliesAcceptDetailEntity> detail = JsonConvert.DeserializeObject <List <SuppliesAcceptDetailEntity> >(DetailData);
                        Boolean         yz       = true;
                        SuppliesService sService = new SuppliesService();
                        foreach (var item in detail)
                        {
                            var supplies = sService.GetEntity(item.SuppliesId);
                            if (item.AcceptNum <= supplies.NUM)
                            {
                                res.Update <SuppliesAcceptDetailEntity>(item);
                                supplies.NUM = supplies.NUM - item.AcceptNum;
                                res.Update <SuppliesEntity>(supplies);
                                var entityInorOut = new InoroutrecordEntity
                                {
                                    USERID            = supplies.USERID,
                                    USERNAME          = supplies.USERNAME,
                                    DEPARTID          = supplies.DEPARTID,
                                    DEPARTNAME        = supplies.DEPARTNAME,
                                    INOROUTTIME       = DateTime.Now,
                                    SUPPLIESCODE      = supplies.SUPPLIESCODE,
                                    SUPPLIESTYPE      = supplies.SUPPLIESTYPE,
                                    SUPPLIESTYPENAME  = supplies.SUPPLIESTYPENAME,
                                    SUPPLIESNAME      = supplies.SUPPLIESNAME,
                                    SUPPLIESUNTIL     = supplies.SUPPLIESUNTIL,
                                    SUPPLIESUNTILNAME = supplies.SUPPLIESUNTILNAME,
                                    NUM          = item.AcceptNum,
                                    STORAGEPLACE = supplies.STORAGEPLACE,
                                    MOBILE       = supplies.MOBILE,
                                    SUPPLIESID   = supplies.ID,
                                    STATUS       = 1
                                };
                                entityInorOut.Create();
                                res.Insert <InoroutrecordEntity>(entityInorOut);
                            }
                            else
                            {
                                message += supplies.SUPPLIESNAME + "库存不足,无法申领,实际库存为" + supplies.NUM + ";";
                                yz       = false;
                            }
                        }
                        if (yz == false)
                        {
                            res.Rollback();
                            return(message);
                        }
                        entity.FlowId = "-100";
                        entity.Status = 3;
                    }
                }
                else
                {
                    entity.FlowId = "-100";
                    entity.Status = 2;
                }
                //entity.IsLastAudit = null;
                entity.DetailData = null;
                res.Update(entity);
                res.Commit();
                return(message);
            }
            catch (Exception ex)
            {
                res.Rollback();
                throw ex;
            }
        }
예제 #8
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public string SaveForm(string keyValue, SuppliesacceptEntity entity)
        {
            string message = "";
            ManyPowerCheckEntity mpcEntity = new ManyPowerCheckEntity();
            Operator             curUser   = ERCHTMS.Code.OperatorProvider.Provider.Current();

            entity.Status = entity.IsSubmit;
            var res = DbFactory.Base().BeginTrans();

            if (!string.IsNullOrEmpty(keyValue))
            {
                var result = GetEntity(keyValue);
                if (result == null)
                {
                    entity.Create();
                }
                else
                {
                    entity.Modify(keyValue);
                }
            }
            else
            {
                entity.Create();
            }
            res.Delete <SuppliesAcceptDetailEntity>(t => t.RecId == entity.Id);
            var num = 0;

            if (!entity.DetailData.IsEmpty())
            {
                foreach (var spec in entity.DetailData)
                {
                    spec.CreateDate = DateTime.Now.AddSeconds(-num);
                    spec.Create();
                    spec.RecId = entity.Id;
                    res.Insert(spec);
                    num++;
                }
            }
            try
            {
                if (entity.IsSubmit == 1)
                {
                    mpcEntity = manypowercheckservice.CheckAuditForNext(curUser, "应急物资领用审批", "", curUser.DeptId, "", keyValue);
                    if (null != mpcEntity)
                    {
                        entity.FlowId = mpcEntity.ID;
                    }
                    else
                    {
                        //审核通过时更新库存,添加库存变更记录
                        Boolean         yz       = true; //判断是否库存数量满足申领条件
                        SuppliesService sService = new SuppliesService();
                        foreach (var item in entity.DetailData)
                        {
                            var supplies = sService.GetEntity(item.SuppliesId);
                            if (item.AcceptNum <= supplies.NUM)
                            {
                                supplies.NUM = supplies.NUM - item.AcceptNum;
                                res.Update <SuppliesEntity>(supplies);
                                var entityInorOut = new InoroutrecordEntity
                                {
                                    USERID            = supplies.USERID,
                                    USERNAME          = supplies.USERNAME,
                                    DEPARTID          = supplies.DEPARTID,
                                    DEPARTNAME        = supplies.DEPARTNAME,
                                    INOROUTTIME       = DateTime.Now,
                                    SUPPLIESCODE      = supplies.SUPPLIESCODE,
                                    SUPPLIESTYPE      = supplies.SUPPLIESTYPE,
                                    SUPPLIESTYPENAME  = supplies.SUPPLIESTYPENAME,
                                    SUPPLIESNAME      = supplies.SUPPLIESNAME,
                                    SUPPLIESUNTIL     = supplies.SUPPLIESUNTIL,
                                    SUPPLIESUNTILNAME = supplies.SUPPLIESUNTILNAME,
                                    NUM          = item.AcceptNum,
                                    STORAGEPLACE = supplies.STORAGEPLACE,
                                    MOBILE       = supplies.MOBILE,
                                    SUPPLIESID   = supplies.ID,
                                    STATUS       = 1
                                };
                                entityInorOut.Create();
                                res.Insert <InoroutrecordEntity>(entityInorOut);
                            }
                            else
                            {
                                message += supplies.SUPPLIESNAME + "库存不足,无法申领,实际库存为" + supplies.NUM + ";";
                                yz       = false;
                            }
                        }
                        if (yz == false)
                        {
                            res.Rollback();
                            return(message);
                        }
                        entity.FlowId = "";
                        entity.Status = 3;
                    }
                }
                entity.DetailData = null;
                if (!string.IsNullOrEmpty(keyValue))
                {
                    var result = GetEntity(keyValue);
                    if (result == null)
                    {
                        res.Insert(entity);
                    }
                    else
                    {
                        res.Update(entity);
                    }
                }
                else
                {
                    res.Insert(entity);
                }
                res.Commit();
                return(message);
            }
            catch (System.Exception ex)
            {
                res.Rollback();
                throw ex;
            }
        }