コード例 #1
0
        public ActionResult ExportCounterParty(CounterPartyListSeachModel input)
        {
            using (XLWorkbook wb = new XLWorkbook())
            {
                //input.fromDate = DateTime.ParseExact(input.fromDate.Value.ToString("MM/dd/yyyy"), "dd/MM/yyyy", null);
                //input.toDate = DateTime.ParseExact(input.toDate.Value.ToString("MM/dd/yyyy"), "dd/MM/yyyy", null);
                input.length = 0;
                var data = _counterPartyService.searchCounterParty(input);
                if (data.resultList.Any())
                {
                    wb.Worksheets.Add(MapModelToNewTableCounterParty(data.resultList), "CounterPartyTemplate");

                    Response.Clear();
                    Response.Buffer      = true;
                    Response.Charset     = "";
                    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                    Response.AddHeader("content-disposition", $"attachment;filename={DateTime.Now:yyyyMMdd}_CounterPartyTemplate.xlsx");
                    using (MemoryStream myMemoryStream = new MemoryStream())
                    {
                        wb.SaveAs(myMemoryStream);
                        myMemoryStream.WriteTo(Response.OutputStream);
                        Response.End();
                        return(Content("Success"));
                    }
                }
                return(Content("No Data"));
            }
        }
コード例 #2
0
        public CounterPartySearchModel searchCounterParty(CounterPartyListSeachModel model)
        {
            try
            {
                CounterPartySearchModel resultObject = new CounterPartySearchModel();
                SqlParameter[]          prms         = new SqlParameter[]
                {
                    new SqlParameter {
                        ParameterName = "fromDate", DbType = DbType.Date, Value = model.fromDate == null ? (object)DBNull.Value : model.fromDate, Size = Int32.MaxValue
                    },
                    new SqlParameter {
                        ParameterName = "toDate", DbType = DbType.Date, Value = model.toDate == null ? (object)DBNull.Value : model.toDate, Size = Int32.MaxValue
                    },
                    new SqlParameter {
                        ParameterName = "cif", DbType = DbType.String, Value = model.cif == null ? (object)DBNull.Value : model.cif, Size = Int32.MaxValue
                    },
                    new SqlParameter {
                        ParameterName = "shortName", DbType = DbType.String, Value = model.shortName == null ? (object)DBNull.Value : model.shortName, Size = Int32.MaxValue
                    },
                    new SqlParameter {
                        ParameterName = "cpGroupCode", DbType = DbType.String, Value = model.cpGroupCode == null ? (object)DBNull.Value : model.cpGroupCode, Size = Int32.MaxValue
                    },
                    new SqlParameter {
                        ParameterName = "userUpdated", DbType = DbType.String, Value = model.userUpdated == null ? (object)DBNull.Value : model.userUpdated, Size = Int32.MaxValue
                    },
                    new SqlParameter {
                        ParameterName = "status", DbType = DbType.String, Value = model.status == null ? (object)DBNull.Value : model.status, Size = Int32.MaxValue
                    },
                    new SqlParameter {
                        ParameterName = "pageNumber", DbType = DbType.Int32, Value = model.pageNumber, Size = Int32.MaxValue
                    },
                    new SqlParameter {
                        ParameterName = "pageSize", DbType = DbType.Int32, Value = model.pageSize, Size = Int32.MaxValue
                    },


                    new SqlParameter {
                        ParameterName = "resultMessage", DbType = DbType.String, Direction = ParameterDirection.Output, Size = Int32.MaxValue
                    },
                    new SqlParameter {
                        ParameterName = "resultCode", DbType = DbType.Int32, Direction = ParameterDirection.Output, Size = Int32.MaxValue
                    }
                };
                var result = _Repository.ExecWithStoreProcedureCommand(Store_searchCounterParty, prms);
                if (result.errorCode == 0)
                {
                    resultObject = JsonConvert.DeserializeObject <CounterPartySearchModel>(result.errorMessage);
                }
                return(resultObject);
            }
            catch (Exception ex)
            {
                HDBH.Log.WriteLog.Error("CounterPartyService => searchCounterParty", ex);
                return(null);
            }
        }
コード例 #3
0
        public JsonResult Search(CounterPartyListSeachModel model)
        {
            var result = new CounterPartySearchModel();

            result = _counterPartyService.searchCounterParty(model);
            return(Json(new
            {
                recordsTotal = result.totalRecord,
                recordsFiltered = result.totalRecord,
                data = result.resultList
            }));
        }