static int Main () { DataList user_list = new DataList (); List<string> str = new List<string> (); str.Add ("foo"); user_list.DataSource = str; user_list.DataBind (); StringWriter sw = new StringWriter (); HtmlTextWriter h = new HtmlTextWriter (sw); user_list.RenderControl (h); string expected = string.Format ("<table cellspacing=\"0\" border=\"0\" style=\"border-collapse:collapse;\">{0}" + "\t<tr>{0}" + "\t\t<td></td>{0}" + "\t</tr>{0}" + "</table>", Environment.NewLine); if (sw.ToString () != expected) { Console.WriteLine (sw.ToString ()); return 1; } return 0; }
private void CheckVaultMapFinish(DataList data) { if (data.Count > 0) { try { DlgContentDetailsView view = DlgContentDetailsView.CreateOrGetExisting(Convert.ToInt32(data[0]["content_id"])); view.OnDownloadComplete += new EventHandler(this.dlg_OnDownloadComplete); view.Show(); } catch (Exception exception) { ErrorLog.WriteLine(exception); DlgMessage.ShowDialog(Loc.Get("<LOC>Unable to join this game. You do not have this map, and it cannot be located in the vault.")); } this.skinButtonRefresh.Enabled = true; this.skinButtonJoin.Enabled = true; } else if (ConfigSettings.GetBool("JoinGameAnyway", false)) { ThreadQueue.Quazal.Enqueue(typeof(DataAccess), "GetQueryData", this, "FinishPopVerify", new object[] { "GetGatheringPopulation", new object[] { this.GameName } }); } else { DlgMessage.ShowDialog(Loc.Get("<LOC>Unable to join this game. You do not have this map, and it cannot be located in the vault.")); this.skinButtonRefresh.Enabled = true; this.skinButtonJoin.Enabled = true; } }
public static DataList<ImageInfo> GetImages(String artistName, String albumName, Boolean getOneImage) { try { DataList<ImageInfo> returnList = new DataList<ImageInfo>(); const String select = "SELECT IMAGE_DATA, IMAGE_EXTENSION, WEB_URL FROM ALBUM_IMAGE WHERE ALBUM_NAME = @ALBUM_NAME and ARTIST_NAME = @ARTIST_NAME "; using (DataReader reader = Static.Db.CallReader(select, Static.Db.NewParameter("@ALBUM_NAME", albumName), Static.Db.NewParameter("@ARTIST_NAME", artistName))) { while (reader.Read()) { returnList.Add(new ImageInfo { Data = reader["IMAGE_DATA"], Extension = reader["IMAGE_EXTENSION"], webUrl = reader["WEB_URL"] }); if (getOneImage) break; } } return returnList; } catch (Exception e) { Logging.Error(typeof(ClientDb), e); return null; } }
public void AddShopCart(DataListCommandEventArgs e, DataList DLName) { if (Session["UID"] != null) { SaveSubGoodsClass Goods = null; Goods = GetSubGoodsInformation(e, DLName); if (Goods == null) { //Show wrong information Response.Write("<script>alert('No useful data');</script>"); return; } else { ucObj.AddShopCart(Goods.GoodsID, Goods.MemberPrice, Convert.ToInt32(Session["UID"].ToString()), Goods.GoodsWeight); Response.Write("<script>alert('Congratulations! Add Item Successfully!')</script>"); } } else { Response.Write("<script>alert('Please Log in First!');</script>"); } }
/// <summary> /// 获取评论区域的代码 /// </summary> /// <param name="artID">上属编号</param> /// <param name="page">当前页码</param> /// <param name="pageSize">每页大小</param> /// <returns>局部HTML代码</returns> public string GetCommentList(int artID, int page, int pageSize) { DataList<CommentItem> cmtList = new DataList<CommentItem>(); if (SiteDat.GetDat(string.Format(SiteCache.CommentsListFormat, artID, page)) == null) { SiteDat.SetDat(string.Format(SiteCache.CommentsListFormat, artID, page), new CommentData(conn).SelectComment(artID, page, pageSize, false)); } cmtList = (DataList<CommentItem>)SiteDat.GetDat(string.Format(SiteCache.CommentsListFormat, artID, page)); StringBuilder result = new StringBuilder(); foreach (CommentItem vItem in cmtList) { result.AppendFormat("<a name=\"comment_{0}\"></a>\n", vItem.ID); result.AppendLine("<dl class=\"commentItem\">"); result.AppendLine("\t<dt>"); result.AppendFormat("\t\t<div class=\"commentFace\"><img src=\"http://www.gravatar.com/avatar.php?gravatar_id={0}\"/></div>\n", SiteFun.GravatarID(vItem.Mail)); result.AppendFormat("\t\t<div class=\"commentName\">{0}</div>\n", SiteFun.HtmlEncode(vItem.Author)); result.AppendLine("\t</dt>"); result.AppendLine("\t<dd>"); result.AppendFormat("\t\t<div class=\"commentContent\">{0}</div>\n", SiteFun.Pre(vItem.Content)); result.AppendLine("\t\t<div class=\"commentInfo\">"); result.AppendFormat("\t\t\t<a href=\"{1}\" title=\"{1}\" class=\"commentWebsite\" target=\"_blank\" rel=\"nofollow\">{0}</a>\n", SiteDat.GetLan("Website"), SiteFun.HtmlEncode(vItem.URL)); //result.AppendFormat("\t\t\t<a href=\"mailto:{1}\" title=\"{1}\" class=\"commentMail\" target=\"_blank\" rel=\"nofollow\">{0}</a>\n", SiteDat.GetLan("Mail"), SiteFun.HtmlEncode(vItem.Mail)); //result.AppendFormat("\t\t\t<a href=\"{1}\" class=\"commentRe\">{0}</a>\n", SiteDat.GetLan("Reply"), ""); result.AppendFormat("\t\t\t<span class=\"commentTime\">{0}</span>\n", vItem.Publish); result.AppendLine("\t\t</div>"); if (!string.IsNullOrEmpty(vItem.Reply)) { result.AppendFormat("\t\t<div class=\"commentReply\">{0}</div>\n", vItem.Reply); } result.AppendLine("\t</dd>"); result.AppendLine("</dl>"); } result.AppendFormat("<div class=\"pager\">{0}</div>\n", new SitePages().Make(cmtList.Number, page, pageSize, "javascript:getComments(" + artID.ToString() + ", {0});")); return result.ToString(); }
public System.Guid MockExecutionImpl(IEsbChannel esbChannel, IDSFDataObject dataObject, string inputs, string outputs, out DataList.Contract.ErrorResultTO tmpErrors) { tmpErrors = new ErrorResultTO(); tmpErrors.AddError("Something bad happened"); return Guid.Empty; }
public Id3NetMediaFile(String pathToFile) { try { this.pathToFile = pathToFile; file = new Mp3File(pathToFile, FileAccess.Read); if (file.HasTags) { DataList<Id3Tag> tags = new DataList<Id3Tag>(file.GetAllTags()); tags.Sort(delegate(Id3Tag t1, Id3Tag t2) { if (t2.MajorVersion != t1.MajorVersion) return t2.MajorVersion.CompareTo(t1.MajorVersion); else return t2.MinorVersion.CompareTo(t1.MinorVersion); }); tag = tags[0]; } } catch (Exception e) { Logging.Error(typeof(Id3NetMediaFile), e); } }
/// <summary> /// 最新商品菜单栏 /// </summary> /// <param name="dlName">绑定最新商品的DataList控件</param> public void DLNewGoods(DataList dlName) { SqlCommand myCmd = dbObj.GetCommandProc("proc_NewGoods"); dbObj.ExecNonQuery(myCmd); DataTable dsTable = dbObj.GetDataSet(myCmd, "tbGoods"); dlBind(dlName, dsTable); }
public void can_render_options_from_enumerable_of_simple_objects() { var optionNodes = new DataList("test").Options(new[] { 1, 2 }).ToString() .ShouldHaveHtmlNode("test") .ShouldHaveChildNodesCount(2); optionNodes[0].ShouldBeUnSelectedOption("1", "1"); optionNodes[1].ShouldBeUnSelectedOption("2", "2"); }
public ImageInfo GetImage(MediaFile file) { DataList<ImageInfo> returnList = new DataList<ImageInfo>(); returnList = getImages(file.ArtistName, file.AlbumName, file.fileId, true); if (returnList != null && returnList.Count == 1) return returnList[0]; else return null; }
/// <summary> /// 对DataList控件进行绑定 /// </summary> /// <param name="dlName">DataList控件名</param> /// <param name="dsTable">数据集DataSet的表的集合</param> public void dlBind(DataList dlName,DataTable dsTable) { if (dsTable != null) { dlName.DataSource = dsTable.DefaultView; dlName.DataKeyField = dsTable.Columns[0].ToString(); dlName.DataBind(); } }
public void basic_datalist_renders_with_options_from_dictionary() { var options = new Dictionary<int, string> { { 1, "One" }, { 2, "Two" } }; var html = new DataList("test").Options(options).ToString(); var element = html.ShouldHaveHtmlNode("test"); var optionNodes = element.ShouldHaveChildNodesCount(2); optionNodes[0].ShouldBeUnSelectedOption(1, "One"); optionNodes[1].ShouldBeUnSelectedOption(2, "Two"); }
public ReturnInfo Create(OrderInfo inOrderInfo) { ReturnInfo localReturnInfo = new ReturnInfo(); localReturnInfo.RETURNFLAG = false; localReturnInfo.RETURNINFO = CommonDefineData.UNKNOWN_STATUS; var ctx = WebOperationContext.Current; ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK; CTrace.WriteLine(CTrace.TraceLevel.Debug, "OrderInfo/orderid/POST."); try { DataList<OrderInfo> localDLOrderInfo = new DataList<OrderInfo>(); if (inOrderInfo != null) { localDLOrderInfo.AddNewData(inOrderInfo); //调用Domain进行add OrderInfoHelper localOrderInfoHelper = new OrderInfoHelper(); bool ret = localOrderInfoHelper.Update(localDLOrderInfo); if (ret) { localReturnInfo.RETURNFLAG = true; localReturnInfo.RETURNINFO = CommonDefineData.SUCCESS_STATUS; } } else { return localReturnInfo; } if (localReturnInfo.RETURNFLAG) { ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Created; } else { ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK; } } catch (Exception ex) { LogSystem.WebLogDebug(ex.Message); ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.ExpectationFailed; ctx.OutgoingResponse.StatusDescription = ex.Message; localReturnInfo.RETURNFLAG = false; localReturnInfo.RETURNINFO = CommonDefineData.EXCEPTION_STATUS; } return localReturnInfo; }
//================================================= //功能描述:对datalist进行数据绑定,无排序 //输入参数:sql,查询的SQL语句;dl,需要绑定的datalist控件 //返回值:无 //时间:2013.08.20 //================================================= public static void binddatalist(string sql, DataList dl) { OleDbConnection conn = DB.Getconn(); DataSet ds = getdataset(sql); dl.DataSource = ds.Tables[0].DefaultView; closeConnection(); dl.DataBind(); }
private void Form1_Load(object sender, EventArgs e) { DataList list = new DataList(); list.Add(new DataEdit(1, "Rocky")); list.Add(new DataEdit(2, "Fred")); list.Add(new DataEdit(3, "Mary")); list.Add(new DataEdit(4, "George")); list.BeginEdit(); this.dataListBindingSource.DataSource = list; this.dataListBindingSource.ListChanged += new ListChangedEventHandler(dataListBindingSource_ListChanged); }
public void DLDisplayHat(int IntDisplay, DataList dlName, string TableName) //done { SqlCommand myCmd = dbObj.GetCommandProc("proc_DisplayHat"); SqlParameter Display = new SqlParameter("@Display", SqlDbType.Int, 4); Display.Value = IntDisplay; myCmd.Parameters.Add(Display); dbObj.ExecNonQuery(myCmd); DataTable dsTable = dbObj.GetDataSet(myCmd, TableName); dlBind(dlName, dsTable); }
/// <summary> /// 创建时间:2008-4-18 /// 该方法实现的是将数据绑定到DataList控件中 /// 参数:dl 要绑定的DataList控件的控件的名称 /// 参数:SqlStr 执行的Sql语句 public void EXECBindDataList(DataList dl, string SqlStr) { SqlConnection con = new SqlConnection(GetConStr()); con.Open();//打开数据库连接 SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con); DataSet ds = new DataSet(); ada.Fill(ds); dl.DataSource = ds; dl.DataBind(); con.Close();//关闭数据库连接 }
/// <summary> /// 在首页面中,绑定商品信息 /// </summary> /// <param name="IntDeplay">商品分类标志</param> /// <param name="dlName">绑定商品的DataList控件</param> /// <param name="TableName">数据集标志</param> public void DLDeplayGI(int IntDeplay, DataList dlName, string TableName) { SqlCommand myCmd = dbObj.GetCommandProc("proc_DeplayGI"); //添加参数 SqlParameter Deplay = new SqlParameter("@Deplay", SqlDbType.Int, 4); Deplay.Value = IntDeplay; myCmd.Parameters.Add(Deplay); dbObj.ExecNonQuery(myCmd); DataTable dsTable = dbObj.GetDataSet(myCmd, TableName); dlBind(dlName, dsTable); }
public SaveSubGoodsClass GetSubGoodsInformation(DataListCommandEventArgs e, DataList DLName) { SaveSubGoodsClass Goods = new SaveSubGoodsClass(); Goods.GoodsID = int.Parse(DLName.DataKeys[e.Item.ItemIndex].ToString()); string GoodsStyle = e.CommandArgument.ToString(); int index = GoodsStyle.IndexOf("|"); if (index < -1 || index + 1 >= GoodsStyle.Length) return Goods; Goods.GoodsWeight = float.Parse(GoodsStyle.Substring(0, index)); Goods.MemberPrice = float.Parse(GoodsStyle.Substring(index + 1)); return (Goods); }
public DiscDataStore(string tenant, HandlerConfigurationElement handlerConfig, ModuleConfigurationElement moduleConfig) { //Fill map path _modulename = moduleConfig.Name; _dataList = new DataList(moduleConfig); foreach (DomainConfigurationElement domain in moduleConfig.Domains) { _mappedPaths.Add(domain.Name, new MappedPath(tenant, moduleConfig.AppendTenant, domain.Path, domain.VirtualPath, handlerConfig.GetProperties())); } //Add default _mappedPaths.Add(string.Empty, new MappedPath(tenant, moduleConfig.AppendTenant, PathUtils.Normalize(moduleConfig.Path), moduleConfig.VirtualPath, handlerConfig.GetProperties())); }
public void can_modify_each_option_element_using_the_option_data_item() { var items = new List<FakeModel> { new FakeModel {Price = 1, Title = "One"}, new FakeModel {Price = 2, Title = "Two", Done = true}, }; var optionNodes = new DataList("test").Options(items, x => x.Price, x => x.Title) .EachOption((cb, opt, i) => cb.Disabled(((FakeModel)opt).Done)).ToString() .ShouldHaveHtmlNode("test") .ShouldHaveChildNodesCount(2); optionNodes[0].ShouldNotHaveAttribute("disabled"); optionNodes[1].ShouldHaveAttribute("disabled"); }
public void basic_datalist_renders_select_with_options_from_select_list() { var items = new List<FakeModel> { new FakeModel {Id = 1, Title = "One"}, new FakeModel {Id = 2, Title = "Two"} }; var selectList = new SelectList(items, "Id", "Title", items[0].Id); var html = new DataList("test").Options(selectList).ToString(); var element = html.ShouldHaveHtmlNode("test"); var optionNodes = element.ShouldHaveChildNodesCount(2); optionNodes[0].ShouldBeSelectedOption(items[0].Id, items[0].Title); optionNodes[1].ShouldBeUnSelectedOption(items[1].Id, items[1].Title); }
private void Form1_Load(object sender, EventArgs e) { var list = new DataList(); list.Add(new Data { Id = 213, Name = "abc" }); list.Add(new Data { Id = 113, Name = "qwe" }); list.Add(new Data { Id = 413, Name = "zcx" }); list.Add(new Data { Id = 233, Name = "abc" }); list.Add(new Data { Id = 215, Name = "ler" }); this.dataListBindingSource.DataSource = list; this.sortedBindingSource.DataSource = new Csla.SortedBindingList<Data>(list); var filtered = new Csla.FilteredBindingList<Data>(list); this.filteredBindingSource.DataSource = filtered; //filtered.ApplyFilter("Name", "abc"); }
/// <summary> /// Update ORM /// </summary> /// <param name="DTListOrderInfo">The DT list order info.</param> /// <returns> /// System.Boolean /// </returns> /// <author> /// Stone /// </author> /// <remarks> /// 2012/10/29 17:54 TUTU-PC /// </remarks> public bool Update(DataList<OrderInfo> DTListOrderInfo) { bool ret = true; try { dataHandler.updateDtHelper[] ArrayUpdateDtHelper ={new dataHandler.updateDtHelper(updateDataTableOrderInfo) }; ret &= dataHandler.updateDataTable(DTListOrderInfo, ArrayUpdateDtHelper); } catch (FormatException ex) { CTrace.WriteLine(CTrace.TraceLevel.Fail, "in OrderInfo Update" + ex.Message); } catch (ArgumentNullException ex) { CTrace.WriteLine(CTrace.TraceLevel.Fail, "in OrderInfo Update" + ex.Message); } catch (ArrayTypeMismatchException ex) { CTrace.WriteLine(CTrace.TraceLevel.Fail, "in OrderInfo Update" + ex.Message); } catch (BadImageFormatException ex) { CTrace.WriteLine(CTrace.TraceLevel.Fail, "in OrderInfo Update" + ex.Message); } catch (IndexOutOfRangeException ex) { CTrace.WriteLine(CTrace.TraceLevel.Fail, "in OrderInfo Update" + ex.Message); } catch (NullReferenceException ex) { CTrace.WriteLine(CTrace.TraceLevel.Fail, "in OrderInfo Update" + ex.Message); } catch (TimeoutException ex) { CTrace.WriteLine(CTrace.TraceLevel.Fail, "in OrderInfo Update" + ex.Message); } catch (Exception ex) { CTrace.WriteLine(CTrace.TraceLevel.Fail, "in OrderInfo Update" + ex.Message); throw; } return ret; }
protected void Page_Load(object sender, EventArgs e) { String[] str = new String[] { "str1", "str2", "str3", "str4" }; DataList[] list = new DataList[] { DataEle, DataBook, DataLife, DataOther };//创建datalist控件数组 DataAccess data = new DataAccess(); data.Connection();//链接数据库 str[0] = "SELECT goodsid,goodsname,goodsprice,images FROM [Goods] where goodssort='电子产品' order by goodsid desc"; str[1] = "SELECT goodsid,goodsname,goodsprice,images FROM [Goods] where goodssort='书籍' order by goodsid desc"; str[2] = "SELECT goodsid,goodsname,goodsprice,images FROM [Goods] where goodssort='生活用品' order by goodsid desc"; str[3] = "SELECT goodsid,goodsname,goodsprice,images FROM [Goods] where goodssort='其它' order by goodsid desc"; for (int i = 0; i < 4; i++) { SqlCommand cmd = data.excute(str[i]);//执行sql语句; DataSet ds = data.Fill(cmd); list[i].DataSource = ds.Tables[0].DefaultView; list[i].DataBind();//数据绑定显示; } }
public S3Storage(string tenant, HandlerConfigurationElement handlerConfig, ModuleConfigurationElement moduleConfig) { _tenant = tenant; _modulename = moduleConfig.Name; _dataList = new DataList(moduleConfig); _domains.AddRange( moduleConfig.Domains.Cast<DomainConfigurationElement>().Select(x => string.Format("{0}/", x.Name))); //Make acl _domainsExpires = moduleConfig.Domains.Cast<DomainConfigurationElement>().Where(x => x.Expires != TimeSpan.Zero). ToDictionary(x => x.Name, y => y.Expires); _domainsExpires.Add(string.Empty, moduleConfig.Expires); _domainsAcl = moduleConfig.Domains.Cast<DomainConfigurationElement>().ToDictionary(x => x.Name, y => GetS3Acl(y.Acl)); _moduleAcl = GetS3Acl(moduleConfig.Acl); }
public DataList<ImageInfo> GetImages(string artistName, string albumName, Int64? fileId) { DataList<ImageInfo> returnList = new DataList<ImageInfo>(); ILocalImageProvider localProvider = new LocalDBImageProvider(); returnList = localProvider.GetImages(artistName, albumName, fileId); if (returnList.Count > 0) return returnList; else { IImageProvider webProvider = new LocalDBImageProvider(); returnList = webProvider.GetImages(artistName, albumName, fileId); if (returnList.Count > 0) localProvider.StoreImages(artistName, albumName, returnList); } return returnList; }
public DynoForm(OBDInterface obd2) { m_obdInterface = obd2; m_profile = obd2.GetActiveProfile(); InitializeComponent(); Data = new DataList(); m_bCapture = false; m_dtDynoTime = DateTime.Now; btnStart.Enabled = false; btnReset.Enabled = false; printDocument1.DefaultPageSettings = new PageSettings() { Margins = new Margins(100, 100, 100, 100), Landscape = true }; pageSetupDialog1.Document = printDocument1; }
public void DataPage(string sqlcom, DataList MarketDetailDl, Label lblCurPage, Label lblTnum, Label lblEachPage, HyperLink lnkFirst, HyperLink lnkLast, HyperLink lnkPrev, HyperLink lnkNext, HttpRequest Request) { DataAccess data = new DataAccess(); data.Connection(); SqlCommand cmd = data.excute(sqlcom); DataSet ds = data.Fill(cmd); MarketDetailDl.DataSource = ds.Tables[0].DefaultView; MarketDetailDl.DataBind(); PagedDataSource objPage = new PagedDataSource();//创建分页类 objPage.DataSource = ds.Tables["Table"].DefaultView;//设置数据源 objPage.AllowPaging = true; objPage.PageSize = 5; if (Request.QueryString["Page"] != null) { CurPage = Convert.ToInt32(Request.QueryString["Page"]); CurPage = Math.Min(CurPage, objPage.PageCount); CurPage = Math.Max(CurPage, 1); } else CurPage = 1; objPage.CurrentPageIndex = CurPage - 1; TotalPage = objPage.PageCount; Tnum = objPage.DataSourceCount; EachPage = objPage.Count; lblCurPage.Text = "第 " + CurPage.ToString() + " / " + TotalPage.ToString() + " 页"; lblTnum.Text = "共: " + Tnum + " 条记录"; lblEachPage.Text = "每页有: " + EachPage.ToString() + " 条记录"; if (objPage.CurrentPageIndex != 0) lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage-CurPage +1); if (objPage.CurrentPageIndex != TotalPage - 1) lnkLast.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(TotalPage); if (!objPage.IsFirstPage) lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1); if (!objPage.IsLastPage) lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1); MarketDetailDl.DataSource = objPage; MarketDetailDl.DataBind(); }
/// <summary> /// Hooks up the specified series to the planet. /// </summary> /// <param name="series">The series.</param> public void HookUp(Series series) { this.series = series; this.SetName(this.series.Title); this.SetImage(this.series.Thumbnail); this.SetSummaries(this.CharactersSatellite, this.series.Characters); this.SetSummaries(this.ComicsSatellite, this.series.Comics); this.SetSummaries(this.CreatorsSatellite, this.series.Creators); this.SetSummaries(this.EventsSatellite, this.series.Events); DataList<Summary> next = null; if (this.series.Next != null && this.series.Next.HasData) { next = new DataList<Summary>() { Available = 1, Returned = 1, Items = new Summary[] { this.series.Next } }; } this.SetSummaries(this.NextSeriesSatellite, next); DataList<Summary> previous = null; if (this.series.Previous != null && this.series.Previous.HasData) { previous = new DataList<Summary>() { Available = 1, Returned = 1, Items = new Summary[] { this.series.Previous } }; } this.SetSummaries(this.PreviousSeriesSatellite, previous); }
protected void GHTBuildUnboundSampleDataList(BaseDataList ctl) { DataList lst = (DataList)ctl; lst.ItemTemplate = new MyItemTemplate(); }
/// <summary> /// Create a DataList from a dataset /// </summary> /// <param name="logonId">Logon id</param> /// <param name="queryName">Name given to the data set</param> /// <param name="queryCriteria">The criteria used to create the dataset. /// If there are mutiple critera parameters they should be concatenated into /// one string. /// This can be empty if the dataset will always be created by an identical query /// or if the criteria has been added on to the end of the query name to /// make the cache available for longer.</param> /// <param name="collectionRequest">Information about the collection being requested</param> /// <param name="mappings">Mappings to map each dataset field to the data list /// entity property name</param> /// <returns></returns> public DataList <T> Create(Guid logonId, string queryName, string queryCriteria, CollectionRequest collectionRequest, ImportMapping[] mappings) { if (queryName == null || queryName.Trim() == string.Empty) { throw new Exception("QueryName must be specified"); } if (collectionRequest == null) { throw new Exception("CollectionRequest must be specified"); } if (collectionRequest.StartRow < 0) { throw new Exception("StartRow must be zero or greater"); } DataSet dataSet = null; DataSetsCache dataSetsCache = null; if (Host.DataSetCachingOn) { // Get the datasets cache for the logged on user dataSetsCache = Host.GetDataSetsCache(logonId); //if we move from a higher page to page 1 then the start row will be 0 //we do not require to get a new dataset at this time //if (collectionRequest.StartRow > 0 && !collectionRequest.ForceRefresh) if (!collectionRequest.ForceRefresh) { // The start row is greater than zero and not forcing refresh // so try to get a cached dataset. dataSet = dataSetsCache.Retreive(queryName, queryCriteria); } } if (dataSet == null) { // Create a new dataset ReadDataSetEventArgs args = new ReadDataSetEventArgs(); // Call the event to read the dataset OnReadDataSet(args); dataSet = args.DataSet; if (dataSet == null) { throw new Exception("No data set has been created"); } if (Host.DataSetCachingOn) { // Add the dataset to the cache dataSetsCache.Add(dataSet, queryName, queryCriteria); } } // Assume there is only one table in the dataset. // This may need to be enhanced later. if (dataSet.Tables.Count != 1) { throw new Exception("Database query did not return 1 table"); } DataTable table = dataSet.Tables[0]; DataList <T> dataList = new DataList <T>(); dataList.FirstRowNumber = collectionRequest.StartRow; dataList.TotalRowCount = table.Rows.Count; // Copy the rows from the dataset to the data list ImportData(dataList, mappings, table, collectionRequest.StartRow, collectionRequest.RowCount); return(dataList); }
private void btnExportYearMoneyToExcel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = string.Empty; sfd.Filter = "*.xlsx|*.xlsx"; if (sfd.ShowDialog() == DialogResult.OK) { try { //输出的Excel路径 string excelFile = sfd.FileName; //Excel数据 MemoryStream memoryStream = new MemoryStream(); //创建Workbook NPOI.XSSF.UserModel.XSSFWorkbook workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(); #region 设置Excel样式 //创建单元格设置对象(普通内容) NPOI.SS.UserModel.ICellStyle cellStyleA = workbook.CreateCellStyle(); cellStyleA.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left; cellStyleA.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; cellStyleA.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleA.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleA.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleA.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleA.WrapText = true; //创建单元格设置对象(普通内容) NPOI.SS.UserModel.ICellStyle cellStyleB = workbook.CreateCellStyle(); cellStyleB.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; cellStyleB.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; cellStyleB.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleB.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleB.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleB.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleB.WrapText = true; //创建设置字体对象(内容字体) NPOI.SS.UserModel.IFont fontA = workbook.CreateFont(); fontA.FontHeightInPoints = 16;//设置字体大小 fontA.FontName = "宋体"; cellStyleA.SetFont(fontA); //创建设置字体对象(标题字体) NPOI.SS.UserModel.IFont fontB = workbook.CreateFont(); fontB.FontHeightInPoints = 16;//设置字体大小 fontB.FontName = "宋体"; fontB.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Bold; cellStyleB.SetFont(fontB); #endregion //基本数据 DataTable dtBase = new DataTable(); #region 输出基本数据 //生成列 dtBase.Columns.Add("合同编号", typeof(string)); dtBase.Columns.Add("合同名称", typeof(string)); dtBase.Columns.Add("承担单位", typeof(string)); dtBase.Columns.Add("项目负责人", typeof(string)); dtBase.Columns.Add("联系电话", typeof(string)); dtBase.Columns.Add("职务职称", typeof(string)); dtBase.Columns.Add("周期", typeof(string)); dtBase.Columns.Add("总经费", typeof(string)); dtBase.Columns.Add("第一年度经费", typeof(string)); dtBase.Columns.Add("第二年度经费", typeof(string)); dtBase.Columns.Add("第三年度经费", typeof(string)); dtBase.Columns.Add("第四年度经费", typeof(string)); dtBase.Columns.Add("第五年度经费", typeof(string)); dtBase.Columns.Add("密级", typeof(string)); dtBase.Columns.Add("起止时间", typeof(string)); dtBase.Columns.Add("单位通信地址", typeof(string)); List <Catalog> catalogList = ConnectionManager.Context.table("Catalog").where ("CatalogType='合同书'").select("*").getList <Catalog>(new Catalog()); //生成内容 foreach (Catalog c in catalogList) { List <object> cells = new List <object>(); //项目信息 Project p = ConnectionManager.Context.table("Project").where ("CatalogID = '" + c.CatalogID + "'").select("*").getItem <Project>(new Project()); //合同编号 cells.Add(p.ProjectNumber); //合同名称 cells.Add(p.ProjectName); //承担单位 cells.Add(p.DutyUnit); Person projectMaster = ConnectionManager.Context.table("Person").where ("IsProjectMaster='true' and JobInProject='负责人' and CatalogID = '" + c.CatalogID + "'").select("*").getItem <Person>(new Person()); //项目负责人 cells.Add(projectMaster.PersonName); //联系电话 cells.Add(projectMaster.Telephone); //职务职称 cells.Add(projectMaster.PersonJob); //周期 cells.Add(p.TotalTime); //总经费 cells.Add(p.TotalMoney); //第一年度经费,第二年度经费,第三年度经费,第四年度经费,第五年度经费 for (int kkk = 1; kkk <= 5; kkk++) { cells.Add(ConnectionManager.Context.table("Dicts").where ("CatalogID='" + c.CatalogID + "' and DictName='Year" + kkk + "'").select("DictValue").getValue <string>(string.Empty)); } //密级 cells.Add(p.SecretLevel); //起止时间(拨付时间) List <DateTime> dtList = new List <DateTime>(); DataList dlMoneySendList = ConnectionManager.Context.table("MoneySends").where ("CatalogID='" + c.CatalogID + "'").orderBy("WillTime").select("WillTime").getDataList(); if (dlMoneySendList.getRowCount() >= 1) { foreach (DataItem diiii in dlMoneySendList.getRows()) { DateTime willTime = diiii.get("WillTime") != null?DateTime.Parse(diiii.get("WillTime").ToString()) : DateTime.Now; dtList.Add(willTime); } } if (dtList.Count >= 2) { cells.Add(dtList[0].ToString("yyyy年MM月dd日") + "~" + dtList[dtList.Count - 1].ToString("yyyy年MM月dd日")); } else if (dtList.Count == 1) { cells.Add(dtList[0].ToString("yyyy年MM月dd日") + "~"); } else { cells.Add(""); } //单位通信地址 cells.Add(p.DutyUnitAddress); dtBase.Rows.Add(cells.ToArray()); } #endregion //写入基本数据 writeSheet(workbook, cellStyleA, cellStyleB, dtBase); #region 输出文件并打开文件 //输出到流 workbook.Write(memoryStream); //写Excel文件 File.WriteAllBytes(excelFile, memoryStream.ToArray()); //显示提示 MessageBox.Show("导出完成!路径:" + excelFile, "提示"); //打开Excel文件 System.Diagnostics.Process.Start(excelFile); #endregion } catch (Exception ex) { MessageBox.Show("对不起,导出失败!Ex:" + ex.ToString()); } } }
public List <IIndicatorValue> GetIndicatorData(List <IMarketData> data) { DataList.Clear(); ProcessMarketData(data); return(DataList); }
private void btnExportToExcel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = string.Empty; sfd.Filter = "*.xlsx|*.xlsx"; if (sfd.ShowDialog() == DialogResult.OK) { try { //输出的Excel路径 string excelFile = sfd.FileName; //Excel数据 MemoryStream memoryStream = new MemoryStream(); //创建Workbook NPOI.XSSF.UserModel.XSSFWorkbook workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(); #region 设置Excel样式 //创建单元格设置对象(普通内容) NPOI.SS.UserModel.ICellStyle cellStyleA = workbook.CreateCellStyle(); cellStyleA.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left; cellStyleA.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; cellStyleA.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleA.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleA.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleA.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleA.WrapText = true; //创建单元格设置对象(普通内容) NPOI.SS.UserModel.ICellStyle cellStyleB = workbook.CreateCellStyle(); cellStyleB.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; cellStyleB.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; cellStyleB.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleB.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleB.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleB.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; cellStyleB.WrapText = true; //创建设置字体对象(内容字体) NPOI.SS.UserModel.IFont fontA = workbook.CreateFont(); fontA.FontHeightInPoints = 16;//设置字体大小 fontA.FontName = "宋体"; cellStyleA.SetFont(fontA); //创建设置字体对象(标题字体) NPOI.SS.UserModel.IFont fontB = workbook.CreateFont(); fontB.FontHeightInPoints = 16;//设置字体大小 fontB.FontName = "宋体"; fontB.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Bold; cellStyleB.SetFont(fontB); #endregion //基本数据 DataTable dtBase = new DataTable(); //金额数据 DataTable dtMoney = new DataTable(); //人员数据 DataTable dtPerson = new DataTable(); #region 输出基本数据 //生成列 dtBase.Columns.Add("项目名称", typeof(string)); dtBase.Columns.Add("项目领域", typeof(string)); dtBase.Columns.Add("合同牵头单位", typeof(string)); dtBase.Columns.Add("项目负责人", typeof(string)); dtBase.Columns.Add("项目负责人电话", typeof(string)); dtBase.Columns.Add("研究周期", typeof(string)); dtBase.Columns.Add("项目总经费", typeof(string)); dtBase.Columns.Add("研究目标", typeof(string)); dtBase.Columns.Add("研究内容", typeof(string)); dtBase.Columns.Add("课题名称", typeof(string)); dtBase.Columns.Add("课题单位", typeof(string)); dtBase.Columns.Add("课题负责人", typeof(string)); dtBase.Columns.Add("课题负责人电话", typeof(string)); List <Catalog> catalogList = ConnectionManager.Context.table("Catalog").where ("CatalogType='合同书'").select("*").getList <Catalog>(new Catalog()); //生成内容 foreach (Catalog c in catalogList) { List <object> cells = new List <object>(); //项目信息 Project p = ConnectionManager.Context.table("Project").where ("CatalogID = '" + c.CatalogID + "'").select("*").getItem <Project>(new Project()); //项目名称 cells.Add(p.ProjectName); //项目领域 cells.Add(p.Domains); //项目牵头单位 cells.Add(p.DutyUnit); Person projectMaster = ConnectionManager.Context.table("Person").where ("IsProjectMaster='true' and JobInProject='负责人' and CatalogID = '" + c.CatalogID + "'").select("*").getItem <Person>(new Person()); //项目负责人 cells.Add(projectMaster.PersonName); //项目负责人电话 cells.Add(projectMaster.Telephone); //研究周期 cells.Add(p.TotalTime); //总经费 cells.Add(p.TotalMoney); //研究目标 cells.Add(getTxtContent(c, "研究目标")); //研究内容 cells.Add(string.Empty); StringBuilder sbSubjectNames = new StringBuilder(); StringBuilder sbSubjectUnits = new StringBuilder(); StringBuilder sbSubjectPersons = new StringBuilder(); StringBuilder sbSubjectPhones = new StringBuilder(); //课题列表 List <Subject> subjectList = ConnectionManager.Context.table("Subject").where ("CatalogID = '" + c.CatalogID + "'").select("*").getList <Subject>(new Subject()); foreach (Subject s in subjectList) { sbSubjectNames.AppendLine(s.SubjectName); sbSubjectUnits.AppendLine(s.DutyUnit); Person subjectMaster = ConnectionManager.Context.table("Person").where ("JobInProject='负责人' and CatalogID = '" + c.CatalogID + "' and SubjectID = '" + s.SubjectID + "'").select("*").getItem <Person>(new Person()); sbSubjectPersons.AppendLine(subjectMaster.PersonName); sbSubjectPhones.AppendLine(subjectMaster.Telephone); } cells.Add(sbSubjectNames.ToString()); cells.Add(sbSubjectUnits.ToString()); cells.Add(sbSubjectPersons.ToString()); cells.Add(sbSubjectPhones.ToString()); dtBase.Rows.Add(cells.ToArray()); } #endregion #region 输出金额数据 //生成列 dtMoney.Columns.Add("项目领域", typeof(string)); dtMoney.Columns.Add("项目名称", typeof(string)); dtMoney.Columns.Add("合同编号", typeof(string)); dtMoney.Columns.Add("研究周期", typeof(string)); dtMoney.Columns.Add("总经费", typeof(string)); dtMoney.Columns.Add("各年度经费(万元)", typeof(string)); dtMoney.Columns.Add("各年度拨付时间", typeof(string)); //生成内容 foreach (Catalog c in catalogList) { List <object> cells = new List <object>(); //项目信息 Project p = ConnectionManager.Context.table("Project").where ("CatalogID = '" + c.CatalogID + "'").select("*").getItem <Project>(new Project()); cells.Add(p.Domains); cells.Add(p.ProjectName); cells.Add(p.ProjectNumber); cells.Add(p.TotalTime); cells.Add(p.TotalMoney); //拨付时间 Dictionary <int, List <string> > yearTimeDict = new Dictionary <int, List <string> >(); int lastForIndex = 0; int lastYear = 0; DataList dlMoneySendList = ConnectionManager.Context.table("MoneySends").where ("CatalogID='" + c.CatalogID + "'").orderBy("WillTime").select("WillTime").getDataList(); if (dlMoneySendList.getRowCount() >= 1) { List <string> yearList = new List <string>(); foreach (DataItem diiii in dlMoneySendList.getRows()) { DateTime willTime = diiii.get("WillTime") != null?DateTime.Parse(diiii.get("WillTime").ToString()) : DateTime.Now; if (willTime.Year != lastYear) { yearTimeDict[lastForIndex] = yearList; lastForIndex++; lastYear = willTime.Year; yearList = new List <string>(); } yearList.Add(willTime.ToString("yyyy年MM月dd日")); } yearTimeDict[lastForIndex] = yearList; } //生成各年度经费和时间字符串 StringBuilder sbMoneyNum = new StringBuilder(); StringBuilder sbMoneyTime = new StringBuilder(); for (int kkk = 1; kkk <= 5; kkk++) { sbMoneyNum.AppendLine(ConnectionManager.Context.table("Dicts").where ("CatalogID='" + c.CatalogID + "' and DictName='Year" + kkk + "'").select("DictValue").getValue <string>(string.Empty)); if (yearTimeDict.ContainsKey(kkk)) { foreach (string sss in yearTimeDict[kkk]) { sbMoneyTime.AppendLine(sss); } } else { sbMoneyTime.AppendLine("---"); } } cells.Add(sbMoneyNum.ToString()); cells.Add(sbMoneyTime.ToString()); dtMoney.Rows.Add(cells.ToArray()); } #endregion #region 输出人员数据 #endregion //写入基本数据 writeSheet(workbook, cellStyleA, cellStyleB, dtBase); //写入金额数据 writeSheet(workbook, cellStyleA, cellStyleB, dtMoney); //写入人员数据 writeSheet(workbook, cellStyleA, cellStyleB, dtPerson); #region 输出文件并打开文件 //输出到流 workbook.Write(memoryStream); //写Excel文件 File.WriteAllBytes(excelFile, memoryStream.ToArray()); //显示提示 MessageBox.Show("导出完成!路径:" + excelFile, "提示"); //打开Excel文件 System.Diagnostics.Process.Start(excelFile); #endregion } catch (Exception ex) { MessageBox.Show("对不起,导出失败!Ex:" + ex.ToString()); } } }
public void changeLinks() { int sideType = 0; string admin = Convert.ToString(Request.Cookies["adminId"].Value); //For Customers DataList MyDataListCustomers = (DataList)Page.Master.FindControl("dtlcustomers"); sideType = 1; DataSet dsAdminCustomers = dbListInfo.GetSideLinkInfo(Convert.ToInt32(admin), sideType); if (dsAdminCustomers.Tables[0].Rows.Count > 0) { if (dsAdminCustomers != null && dsAdminCustomers.Tables.Count > 0 && dsAdminCustomers.Tables[0].Rows.Count > 0) { MyDataListCustomers.DataSource = dsAdminCustomers; MyDataListCustomers.DataBind(); } } //for Site Functions DataList MyDataListSiteFunctions = (DataList)Page.Master.FindControl("dtlsitefunctions"); sideType = 2; DataSet dsAdminSiteFunctions = dbListInfo.GetSideLinkInfo(Convert.ToInt32(admin), sideType); if (dsAdminSiteFunctions.Tables[0].Rows.Count > 0) { if (dsAdminSiteFunctions != null && dsAdminSiteFunctions.Tables.Count > 0 && dsAdminSiteFunctions.Tables[0].Rows.Count > 0) { MyDataListSiteFunctions.DataSource = dsAdminSiteFunctions; MyDataListSiteFunctions.DataBind(); } } //for reports DataList MyDataListReports = (DataList)Page.Master.FindControl("dtlreports"); sideType = 3; DataSet dsAdminReports = dbListInfo.GetSideLinkInfo(Convert.ToInt32(admin), sideType); if (dsAdminReports.Tables[0].Rows.Count > 0) { if (dsAdminReports != null && dsAdminReports.Tables.Count > 0 && dsAdminReports.Tables[0].Rows.Count > 0) { MyDataListReports.DataSource = dsAdminReports; MyDataListReports.DataBind(); } } foreach (DataListItem row1 in MyDataListCustomers.Items) { LinkButton MyLinkButton = new LinkButton(); MyLinkButton = (LinkButton)row1.FindControl("lkbCustomers"); string name = MyLinkButton.Text; if (name == "Users") { MyLinkButton.CssClass = "sublinkactive1"; } } dbListInfo.dispose(); }