/// <summary>
        /// 获取盘点计划列表数据 分页
        /// </summary>
        /// <param name="Mod">查询条件</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">页容量,每页显示条数</param>
        /// <returns></returns>
        public EmsModel.JsonModel GetJsonModel(EmsModel.InventoryPlan Mod, int pageIndex, int pageSize)
        {
            List <EmsModel.InventoryPlan> modList = dal.GetListByPageAndSear(Mod, ((pageIndex - 1) * pageSize) + 1, (pageIndex * pageSize));
            //定义分页数据实体
            PagedDataModel <EmsModel.InventoryPlan> pagedDataModel = null;
            //定义JSON标准格式实体中
            JsonModel jsonModel = null;

            if (modList.Count > 0)
            {
                var list = modList;
                //总条数
                int rowCount = dal.GetListByPageCountAndSear(Mod);
                //总页数
                int pageCount = (int)Math.Ceiling(rowCount * 1.0 / pageSize);
                //将数据封装到PagedDataModel分页数据实体中
                pagedDataModel = new PagedDataModel <EmsModel.InventoryPlan>()
                {
                    PageCount = pageCount,
                    PagedData = list,
                    PageIndex = pageIndex,
                    PageSize  = pageSize,
                    RowCount  = rowCount
                };
                //将分页数据实体封装到JSON标准实体中
                jsonModel = new JsonModel()
                {
                    Data    = pagedDataModel,
                    Msg     = "成功",
                    Status  = "ok",
                    BackUrl = ""
                };
                return(jsonModel);
            }
            else
            {
                jsonModel = new JsonModel()
                {
                    Status = "no",
                    Msg    = "失败"
                };
                return(jsonModel);
            }
        }
Example #2
0
        /// <summary>
        /// 保存房间盘点信息
        /// </summary>
        /// <param name="invenid">盘点单id</param>
        /// <param name="roomid">房间id</param>
        /// <param name="idStr">盘点详情id</param>
        /// <param name="editStr">需要换房间的盘点详情id</param>
        /// <param name="useridcard">用户身份证号</param>
        /// <returns></returns>
        public JsonModel SaveRoomInventory(string invenid, string roomid, string idStr, string editStr, string useridcard)
        {
            //定义JSON标准格式实体中
            JsonModel jsonModel = new JsonModel();

            try
            {
                //事务
                using (SqlTransaction trans = dal.GetTran())
                {
                    try
                    {
                        string[] idArray   = idStr.Split(',');
                        string[] editArray = editStr.Split(',');
                        int      result    = 0;
                        if (!string.IsNullOrEmpty(idStr))
                        {
                            int idcount = 0;
                            foreach (string deid in idArray)
                            {
                                EmsModel.InventoryListDetail ind = dal.GetEmsModel(Convert.ToInt32(deid));
                                ind.IsLoss = true;
                                result     = dal.Update(trans, ind);
                                if (result > 0)
                                {
                                    idcount++;
                                }
                            }
                            if (idArray.Length != idcount)
                            {
                                trans.Rollback();//回滚
                                jsonModel.Status = "no";
                                jsonModel.Msg    = "保存失败";
                                return(jsonModel);
                            }
                        }
                        if (!string.IsNullOrEmpty(editStr))
                        {
                            int editcount = 0;
                            foreach (string editid in editArray)
                            {
                                EmsModel.InventoryListDetail ind = dal.GetEmsModel(Convert.ToInt32(editid));
                                ind.SourceRoomId = ind.RoomId;
                                ind.RoomId       = Convert.ToInt32(roomid);
                                ind.IsLoss       = true;
                                result           = dal.Update(trans, ind);
                                EmsDAL.EquipDetail   dal_equip = new EmsDAL.EquipDetail();
                                EmsModel.EquipDetail equip     = dal_equip.GetEmsModel(ind.EquipId);
                                equip.StorageLocation = roomid;
                                dal_equip.Update(trans, equip);//修改仪器设备详情存放地点
                                if (result > 0)
                                {
                                    editcount++;
                                }
                            }
                            if (editArray.Length != editcount)
                            {
                                trans.Rollback();//回滚
                                jsonModel.Status = "no";
                                jsonModel.Msg    = "保存失败";
                                return(jsonModel);
                            }
                        }
                        EmsDAL.InventoryList   dal_list = new EmsDAL.InventoryList();
                        EmsModel.InventoryList list     = dal_list.GetEmsModelByInvRoomId(invenid, roomid);
                        list.RealQuantity = (!string.IsNullOrEmpty(idStr) ? idArray.Length : 0) + (!string.IsNullOrEmpty(editStr) ? editArray.Length : 0);
                        list.Status       = 1;
                        list.Operator     = useridcard;
                        list.Editor       = useridcard;
                        list.UpdateTime   = DateTime.Now;
                        result            = dal_list.Update(trans, list);
                        if (result == 0)
                        {
                            trans.Rollback();//回滚
                            jsonModel.Status = "no";
                            jsonModel.Msg    = "保存失败";
                            return(jsonModel);
                        }
                        if (dal.GetNotInventoryCount(trans, invenid) == 0)
                        {
                            EmsDAL.InventoryPlan   dal_plan = new EmsDAL.InventoryPlan();
                            EmsModel.InventoryPlan plan     = dal_plan.GetEmsModel(Convert.ToInt32(invenid));
                            plan.Status = 1;
                            result      = dal_plan.Update(trans, plan);
                            if (result == 0)
                            {
                                trans.Rollback();//回滚
                                jsonModel.Status = "no";
                                jsonModel.Msg    = "保存失败";
                                return(jsonModel);
                            }
                        }
                        trans.Commit();//提交
                    }
                    catch (Exception)
                    {
                        trans.Rollback();//回滚
                        throw;
                    }
                }
                jsonModel.Status = "ok";
                jsonModel.Msg    = "操作成功";
                return(jsonModel);
            }
            catch (Exception ex)
            {
                jsonModel.Status = "error";
                jsonModel.Msg    = ex.ToString();
                return(jsonModel);
            }
        }