コード例 #1
0
        public List <NoticeSearchModel> FillNoticeSearchGrid(NoticeSearchModel model)
        {
            ShomaRMEntities          db        = new ShomaRMEntities();
            List <NoticeSearchModel> lstNotice = new List <NoticeSearchModel>();

            try
            {
                DataTable dtTable = new DataTable();
                using (var cmd = db.Database.Connection.CreateCommand())
                {
                    db.Database.Connection.Open();
                    cmd.CommandText = "usp_GetNoticePaginationAndSearchData";
                    cmd.CommandType = CommandType.StoredProcedure;

                    DbParameter paramDF = cmd.CreateParameter();
                    paramDF.ParameterName = "FromDate";
                    paramDF.Value         = model.FromDate;
                    cmd.Parameters.Add(paramDF);

                    DbParameter paramDT = cmd.CreateParameter();
                    paramDT.ParameterName = "ToDate";
                    paramDT.Value         = model.ToDate;
                    cmd.Parameters.Add(paramDT);

                    DbParameter paramPN = cmd.CreateParameter();
                    paramPN.ParameterName = "PageNumber";
                    paramPN.Value         = model.PageNumber;
                    cmd.Parameters.Add(paramPN);

                    DbParameter paramNOR = cmd.CreateParameter();
                    paramNOR.ParameterName = "NumberOfRows";
                    paramNOR.Value         = model.NumberOfRows;
                    cmd.Parameters.Add(paramNOR);

                    DbDataAdapter da = DbProviderFactories.GetFactory("System.Data.SqlClient").CreateDataAdapter();
                    da.SelectCommand = cmd;
                    da.Fill(dtTable);
                    db.Database.Connection.Close();
                }
                foreach (DataRow dr in dtTable.Rows)
                {
                    NoticeSearchModel searchmodel = new NoticeSearchModel();
                    searchmodel.NoticeID     = Convert.ToInt64(dr["NoticeID"].ToString());
                    searchmodel.PropertyName = dr["PropertyName"].ToString();
                    searchmodel.TenantName   = dr["TenantName"].ToString();
                    searchmodel.UnitName     = dr["UnitName"].ToString();
                    searchmodel.Revision_Num = dr["Revision_Num"].ToString();
                    searchmodel.NoticeDate   = dr["NoticeDate"].ToString();
                    lstNotice.Add(searchmodel);
                }
                db.Dispose();
                return(lstNotice.ToList());
            }
            catch (Exception ex)
            {
                db.Database.Connection.Close();
                throw ex;
            }
        }
コード例 #2
0
        /// <summary>
        /// Search the notices
        /// </summary>
        /// <returns></returns>
        public JqGridSearchOut SearchNotices(JqSearchIn si, NoticeSearchModel model)
        {
            var data = SearchNotices(model);

            var notices = Maps(data);

            return(si.Search(notices));
        }
コード例 #3
0
        /// <summary>
        /// Export notices
        /// </summary>
        /// <param name="si"></param>
        /// <param name="gridExportMode"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public HSSFWorkbook Exports(JqSearchIn si, GridExportMode gridExportMode, NoticeSearchModel model)
        {
            var data = gridExportMode == GridExportMode.All ? GetAll() : SearchNotices(model);

            var notices = Maps(data);

            var exportData = si.Export(notices, gridExportMode);

            return(ExcelUtilities.CreateWorkBook(exportData));
        }
コード例 #4
0
        /// <summary>
        /// Export notices
        /// </summary>
        /// <param name="si"></param>
        /// <param name="gridExportMode"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult Exports(JqSearchIn si, GridExportMode gridExportMode, NoticeSearchModel model)
        {
            var workbook = _noticeService.Exports(si, gridExportMode, model);

            var output = new MemoryStream();

            workbook.Write(output);

            return(File(output.ToArray(), "application/vnd.ms-excel", "Notices.xls"));
        }
コード例 #5
0
        public int BuildPaganationNoticeList(NoticeSearchModel model)
        {
            int             NOP = 0;
            ShomaRMEntities db  = new ShomaRMEntities();

            try
            {
                DataTable dtTable = new DataTable();
                using (var cmd = db.Database.Connection.CreateCommand())
                {
                    db.Database.Connection.Open();
                    cmd.CommandText = "usp_GetNoticePaginationAndSearchData";
                    cmd.CommandType = CommandType.StoredProcedure;

                    DbParameter paramDF = cmd.CreateParameter();
                    paramDF.ParameterName = "FromDate";
                    paramDF.Value         = model.FromDate;
                    cmd.Parameters.Add(paramDF);

                    DbParameter paramDT = cmd.CreateParameter();
                    paramDT.ParameterName = "ToDate";
                    paramDT.Value         = model.ToDate;
                    cmd.Parameters.Add(paramDT);

                    DbParameter paramPN = cmd.CreateParameter();
                    paramPN.ParameterName = "PageNumber";
                    paramPN.Value         = model.PageNumber;
                    cmd.Parameters.Add(paramPN);

                    DbParameter paramNOR = cmd.CreateParameter();
                    paramNOR.ParameterName = "NumberOfRows";
                    paramNOR.Value         = model.NumberOfRows;
                    cmd.Parameters.Add(paramNOR);

                    DbDataAdapter da = DbProviderFactories.GetFactory("System.Data.SqlClient").CreateDataAdapter();
                    da.SelectCommand = cmd;
                    da.Fill(dtTable);
                    db.Database.Connection.Close();
                }
                if (dtTable.Rows.Count > 0)
                {
                    NOP = int.Parse(dtTable.Rows[0]["NumberOfPages"].ToString());
                }
                db.Dispose();
                return(NOP);
            }
            catch (Exception ex)
            {
                db.Database.Connection.Close();
                throw ex;
            }
        }
コード例 #6
0
 /// <summary>
 /// Search notices
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 private IQueryable <Notice> SearchNotices(NoticeSearchModel model)
 {
     return(Fetch(notice => (string.IsNullOrEmpty(model.Keyword) ||
                             (!string.IsNullOrEmpty(notice.Message) && notice.Message.Contains(model.Keyword))) &&
                  (!model.NoticeTypeId.HasValue || notice.NoticeTypeId == model.NoticeTypeId)));
 }
コード例 #7
0
 public string _AjaxBinding(JqSearchIn si, NoticeSearchModel model)
 {
     return(JsonConvert.SerializeObject(_noticeService.SearchNotices(si, model)));
 }
コード例 #8
0
        public ActionResult Index()
        {
            var model = new NoticeSearchModel();

            return(View(model));
        }