Exemple #1
0
        public ResResultModel GetPandianAssetByBarcode(string appKey, string userName, object pandianId, string barcode)
        {
            try
            {
                object userId = null;
                SecurityService.DoCheckLogin(appKey, userName, out userId);

                if (string.IsNullOrWhiteSpace(barcode))
                {
                    return(ResResult.Response(false, "参数barcode值不能为空字符串", ""));
                }

                var gId = Guid.Empty;
                if (pandianId != null)
                {
                    Guid.TryParse(pandianId.ToString(), out gId);
                }
                if (gId.Equals(Guid.Empty))
                {
                    return(ResResult.Response(false, "参数pandianId值不正确", ""));
                }

                var            sqlWhere = @"and pd.Id = @PandianId and ais.Barcode = @Barcode ";
                SqlParameter[] parms    =
                {
                    new SqlParameter("@PandianId", SqlDbType.UniqueIdentifier),
                    new SqlParameter("@Barcode",   SqlDbType.VarChar, 36)
                };
                parms[0].Value = gId;
                parms[1].Value = barcode;

                var bll  = new PandianAsset();
                var list = bll.GetListByJoin(sqlWhere, parms.ToArray());
                if (list == null || list.Count == 0)
                {
                    return(ResResult.Response(false, "数据不存在或已被删除", ""));
                }

                var pdaModel = new PdaPandianAssetInfo();
                var item     = list[0];

                pdaModel.PandianId   = item.PandianId;
                pdaModel.AssetId     = item.AssetId;
                pdaModel.Named       = item.Named;
                pdaModel.PandianUser = item.UserName;

                pdaModel.PandianAssetStatus = item.Status;
                pdaModel.PictureUrl         = "";
                pdaModel.AssetName          = item.AssetName;
                pdaModel.Barcode            = item.Barcode;
                pdaModel.Category           = item.Category;
                pdaModel.SpecModel          = item.SpecModel;
                pdaModel.OwnedCompany       = item.OwnedCompany;
                pdaModel.UseCompany         = item.UseCompany;
                pdaModel.UseDepmt           = item.UseDepmt;
                pdaModel.Region             = item.Region;
                pdaModel.StoreLocation      = item.StoreLocation;
                pdaModel.UsePerson          = item.UsePerson;
                pdaModel.Unit = item.Unit;

                return(ResResult.Response(true, "调用成功", JsonConvert.SerializeObject(pdaModel)));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Exemple #2
0
        public ResResultModel GetPandianAssetList(PdaPandianAssetModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, "未找到任何参数", ""));
                }

                if (model.PageIndex < 1)
                {
                    model.PageIndex = 1;
                }
                if (model.PageSize < 10)
                {
                    model.PageSize = 10;
                }
                int totalRecord = 0;

                var pandianId = Guid.Empty;
                if (model.PandianId != null)
                {
                    Guid.TryParse(model.PandianId.ToString(), out pandianId);
                }
                //if (pandianId.Equals(Guid.Empty)) return ResResult.Response(false, "参数PandianId值为“" + model.PandianId + "”不正确", "");

                var status = Enum.GetName(typeof(EnumData.EnumPandianAssetStatus), model.Status);
                //if (string.IsNullOrWhiteSpace(status)) return ResResult.Response(false, "参数Status值为“" + model.Status + "”不正确", "");

                var          sqlWhere = new StringBuilder(100);
                var          parms    = new ParamsHelper();
                SqlParameter parm     = null;

                if (!pandianId.Equals(Guid.Empty))
                {
                    sqlWhere.Append("and PandianId = @PandianId ");
                    parm       = new SqlParameter("@PandianId", SqlDbType.UniqueIdentifier);
                    parm.Value = pandianId;
                    parms.Add(parm);
                }

                if (model.Status > -1)
                {
                    sqlWhere.Append("and pda.Status = @Status ");
                    parm       = new SqlParameter("@Status", SqlDbType.NVarChar, 20);
                    parm.Value = status;
                    parms.Add(parm);
                }

                var bll  = new PandianAsset();
                var list = bll.GetListByJoin(model.PageIndex, model.PageSize, out totalRecord, sqlWhere.ToString(), parms.ToArray());

                var pdaList = new List <PdaPandianAssetInfo>();
                foreach (var item in list)
                {
                    var pdaModel = new PdaPandianAssetInfo();
                    pdaModel.PandianId   = item.PandianId;
                    pdaModel.AssetId     = item.AssetId;
                    pdaModel.Named       = item.Named;
                    pdaModel.PandianUser = item.UserName;
                    pdaModel.TotalQty    = list.Count;
                    pdaModel.Remark      = item.Remark;

                    pdaModel.PandianAssetStatus = item.Status;
                    pdaModel.PictureUrl         = "";
                    pdaModel.AssetName          = item.AssetName;
                    pdaModel.Barcode            = item.Barcode;
                    pdaModel.SNCode             = item.SNCode;
                    pdaModel.Category           = item.Category;
                    pdaModel.CategoryId         = item.CategoryId;
                    pdaModel.SpecModel          = item.SpecModel;
                    pdaModel.OwnedCompany       = item.OwnedCompany;
                    pdaModel.UseCompany         = item.UseCompany;
                    pdaModel.UseDepmt           = item.UseDepmt;
                    pdaModel.Region             = item.Region;
                    pdaModel.StoreLocation      = item.StoreLocation;
                    pdaModel.UsePerson          = item.UsePerson;
                    pdaModel.Unit = item.Unit;

                    pdaList.Add(pdaModel);
                }

                var totals = bll.GetTotal(pandianId);

                var dgData = "{\"total\":" + pdaList.Count + ",\"rows\":" + JsonConvert.SerializeObject(pdaList) + ",\"footer\":[{\"TotalPan\":" + totals[0] + ",\"TotalYpan\":" + totals[1] + ",\"TotalNotPan\":" + totals[2] + "}]}";
                return(ResResult.Response(true, "", dgData));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }