《ASP.NET辦公自動化系統開發執行個體導航》筆記三 人事管理模組

來源:互聯網
上載者:User
這一章是人事管理系統,但是技術方面和系統管理沒有太大的區別.

主要一個點:如何在.NET中存取映像? Bitmap myPic;
try
{
   //從指定的檔案初始化Bitmap類的新執行個體
   //比如從上傳的檔案裡讀取,那就是new Bitmap(File1.PostedFile.InputStream)
   myPic = new Bitmap(lnkPic.src);
}
catch(Exception ex)
{
   return;
}
//從指定的現有映像並使用指定的大小初始化Bitmap類的新執行個體
Bitmap smallPic = new Bitmap(myPic, 100, 100);
//建立緩衝區
MemoryStream stream = new MemoryStream();
//設定以圖片的格式寫入緩衝區
picSmall.Save(stream, ImageFormat.Jpeg);
//將緩衝區內容轉換為位元組數組
byte[] byteArray = stream.ToArray();
PhotoAccess.UpdateEmpPic(empID, byteArray);

將資料庫中的映像資料顯示到頁面中,可以通過Response的輸出資料流來實現.

Response.ContentType = "image/pjepg";
Response.OutputStream.Write((byte[])dr["pic"], 0, (int)dr["pic_size"]);
Response.End();

使用DataFormatString設定指定列中的各項的顯示格式字串
比如對時間進行格式化顯示:

<asp:BoundColumn DataField="logindate" HeaderText="登入時間" DataFormatString="{0:d}"></asp:BoundColumn>
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.