Beispiel #1
0
        public ResResultModel GetPandianAssetList(PdaPandianAssetModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, ""));
                }

                var userId = WebCommon.GetUserId();
                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);
                }

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

                sqlWhere.AppendFormat("and pda.Status = {0} ", (int)EnumPandianAssetStatus.未盘点);
                if (!pandianId.Equals(Guid.Empty))
                {
                    sqlWhere.Append("and PandianId = @PandianId ");
                    parm       = new SqlParameter("@PandianId", SqlDbType.UniqueIdentifier);
                    parm.Value = pandianId;
                    parms.Add(parm);
                }

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

                var totals = bll.GetTotal(pandianId);

                var dgData = "{\"total\":" + totalRecord + ",\"rows\":" + JsonConvert.SerializeObject(list) + ",\"footer\":[{\"TotalPan\":" + totals[0] + ",\"TotalYpan\":" + totals[1] + ",\"TotalNotPan\":" + totals[2] + "}]}";
                return(ResResult.Response(true, "", dgData));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Beispiel #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, ""));
            }
        }