public object GetGoodInventory(Dictionary <string, object> dicParas) { try { string errMsg = string.Empty; string id = dicParas.ContainsKey("id") ? (dicParas["id"] + "") : string.Empty; if (string.IsNullOrEmpty(id)) { errMsg = "盘点流水号不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } int iId = Convert.ToInt32(id); IData_GoodInventoryService data_GoodInventoryService = BLLContainer.Resolve <IData_GoodInventoryService>(); if (!data_GoodInventoryService.Any(a => a.ID == iId)) { errMsg = "该盘点信息不存在"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } var result = from a in data_GoodInventoryService.GetModels(p => p.ID == iId).FirstOrDefault().AsDictionary() select new { name = a.Key, value = a.Value }; return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, result)); } catch (Exception e) { return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message)); } }
public object QueryGoodInventory(Dictionary <string, object> dicParas) { try { XCCloudUserTokenModel userTokenKeyModel = (XCCloudUserTokenModel)dicParas[Constant.XCCloudUserTokenModel]; string storeId = (userTokenKeyModel.DataModel as UserDataModel).StoreID; string errMsg = string.Empty; object[] conditions = dicParas.ContainsKey("conditions") ? (object[])dicParas["conditions"] : null; SqlParameter[] parameters = new SqlParameter[0]; string sqlWhere = string.Empty; if (conditions != null && conditions.Length > 0) { if (!QueryBLL.GenDynamicSql(conditions, "a.", ref sqlWhere, ref parameters, out errMsg)) { return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } } string sql = @"select a.ID, c.DictKey as InventoryTypeStr, (case when a.InventoryType=1 then d.WorkStation when a.InventoryType=3 then e.HeadName else '' end) as InventoryIndexName, a.InventoryTime, a.UserID, b.RealName, a.InventoryCount, a.Note from Data_GoodInventory a " + " left join Base_UserInfo b on a.UserID=b.UserID " + " left join (select b.* from Dict_System a inner join Dict_System b on a.ID=b.PID where a.DictKey='盘点类别' and a.PID=0) c on convert(varchar, a.InventoryType)=c.DictValue " + " left join Data_Workstation d on a.InventoryType=1 and a.InventoryIndex=d.ID " + " left join Data_Head e on a.InventoryType=3 and a.InventoryIndex=e.ID " + " where a.StoreID='" + storeId + "'"; sql = sql + sqlWhere; IData_GoodInventoryService data_GoodInventoryService = BLLContainer.Resolve <IData_GoodInventoryService>(); var data_GoodInventory = data_GoodInventoryService.SqlQuery <Data_GoodInventoryList>(sql, parameters).ToList(); return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn, data_GoodInventory)); } catch (Exception e) { return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message)); } }
public object AddGoodInventory(Dictionary <string, object> dicParas) { try { XCCloudUserTokenModel userTokenKeyModel = (XCCloudUserTokenModel)dicParas[Constant.XCCloudUserTokenModel]; string storeId = (userTokenKeyModel.DataModel as UserDataModel).StoreID; string logId = userTokenKeyModel.LogId; string errMsg = string.Empty; string barCode = dicParas.ContainsKey("barCode") ? (dicParas["barCode"] + "") : string.Empty; string inventoryType = dicParas.ContainsKey("inventoryType") ? (dicParas["inventoryType"] + "") : string.Empty; string inventoryIndex = dicParas.ContainsKey("inventoryIndex") ? (dicParas["inventoryIndex"] + "") : string.Empty; string predictCount = dicParas.ContainsKey("predictCount") ? (dicParas["predictCount"] + "") : string.Empty; string inventoryCount = dicParas.ContainsKey("inventoryCount") ? (dicParas["inventoryCount"] + "") : string.Empty; string totalPrice = dicParas.ContainsKey("totalPrice") ? (dicParas["totalPrice"] + "") : string.Empty; string note = dicParas.ContainsKey("note") ? (dicParas["note"] + "") : string.Empty; #region 参数验证 if (string.IsNullOrEmpty(barCode)) { errMsg = "商品条码barCode不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (string.IsNullOrEmpty(inventoryType)) { errMsg = "盘点类别inventoryType不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (!string.IsNullOrEmpty(inventoryIndex) && !Utils.isNumber(inventoryIndex)) { errMsg = "盘点位置索引inventoryIndex格式不正确"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (string.IsNullOrEmpty(predictCount)) { errMsg = "预估数量predictCount不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (string.IsNullOrEmpty(inventoryCount)) { errMsg = "盘点数量inventoryCount不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (string.IsNullOrEmpty(totalPrice)) { errMsg = "库存金额totalPrice不能为空"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (!Utils.isNumber(predictCount)) { errMsg = "预估数量predictCount格式不正确"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (!Utils.isNumber(inventoryCount)) { errMsg = "盘点数量inventoryCount格式不正确"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } if (!Utils.IsDecimal(totalPrice)) { errMsg = "库存金额totalPrice格式不正确"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } #endregion IData_GoodInventoryService data_GoodInventoryService = BLLContainer.Resolve <IData_GoodInventoryService>(); var data_GoodInventory = new Data_GoodInventory(); Utils.GetModel(dicParas, ref data_GoodInventory); data_GoodInventory.StoreID = storeId; data_GoodInventory.InventoryTime = DateTime.Now; data_GoodInventory.UserID = Convert.ToInt32(logId); if (!data_GoodInventoryService.Add(data_GoodInventory)) { errMsg = "添加商品盘点信息失败"; return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg)); } return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn)); } catch (DbEntityValidationException e) { return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, e.EntityValidationErrors.ToErrors())); } catch (Exception e) { return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message)); } }