12-1 -2
VC# Web Blog 12-1 -1-1 12-1.1-1 C:\ ChartModuleSample_CSharp\Application\2001\ Files\ 4096 KB 120 Web.Config httpruntime maxrequestlength executiontimeout 12-2
<system.web> <httpruntime maxrequestlength="8192" executiontimeout="120"/> </system.web> 4096 KB 2001/Files -1 10 10-3.2 12-1.2-1 1. 2. -1 3. -1 12-1 Word 12-2 12-3
VC# JPG 12-3.jpg 12-1 12-4
12-2 12-3 4. 12-5
VC# 5. 12-4 -1 () 12-4 12-1.3-1 -1 Fi_Content SQL Server APPSYS Fi_Content 12-5 12-6 fc_content -1 null 12-6
-2-2 fc_content Fi_Location SQL Server APPSYS Fi_Location 12-7 12-8 12-5 Fi_Content APPSYS APPSYS fc_sid () fl_no + fc_name () 1 fc_sid int 4 Seed+1 2 fl_no smallint 2 =Fi_Location.fl_no 3 fc_name nvarchar 300 4 fc_ext nvarchar 50 ('') 5 fc_size int 4 (0) 6 fc_type nvarchar 100 ('') ContentType 7 fc_desc nvarchar 1000 ('') 8 fc_content image 16 (Null) 9 fc_save tinyint 1 (0) 10 up_time datetime 8 (getdate()) 0 1 2 12-7
VC# 12-6 12-7 APPSYS Fi_Location APPSYS fl_no (/) 1 fl_no smallint 2 2 fl_name nvarchar 100 3 fl_path nvarchar 500 4 fl_url 韬 nvarchar 500 12-8 12-1.4-1 12-8
12-1.4.1 2001/2001.aspx -1 GridView GridView ObjectDataSource <asp:objectdatasource ID="ods_Fi_Content" runat="server" EnablePaging="True" SelectCountMethod="GetCount_Fi_Content" SelectMethod="Select_Fi_Content" SortParameterName="SortColumn" TypeName="ODS_Fi_Content_DataReader"> <SelectParameters> <asp:parameter Name="SortColumn" Type="String" /> <asp:parameter Name="startRowIndex" Type="Int32" /> <asp:parameter Name="maximumRows" Type="Int32" /> <asp:parameter Name="fl_no" Type="Int32" /> <asp:parameter Name="fc_name" Type="String" /> <asp:parameter Name="fc_ext" Type="String" /> <asp:parameter Name="fc_desc" Type="String" /> </SelectParameters> </asp:objectdatasource> ObjectDataSource ODS_Fi_Content_DataReader App_Code/ODS_Fi_Content_ DataReader.cs GridView RowDataBound RowCreated // GridView protected void gv_fi_content_rowdatabound(object sender, GridViewRowEventArgs e) if (e.row.rowtype == DataControlRowType.DataRow) int ckint; e.row.cells[0].rowspan = 2; e.row.cells[6].rowspan = 2; 12-9
VC# e.row.cells[7].rowspan = 2; Literal lt_row = (Literal)e.Row.Cells[7].FindControl("lt_table"); lt_row.text = "</tr><tr>"; ckint = int.parse(databinder.eval(e.row.dataitem, "rownum").tostring()); if ((ckint % 2) == 1) e.row.cells[8].attributes.add("bgcolor", "#F7F7DE"); e.row.cells[8].columnspan = 5; // GridView protected void gv_fi_content_rowcreated(object sender, GridViewRowEventArgs e) if (e.row.rowtype == DataControlRowType.Header) e.row.cells[0].rowspan = 2; e.row.cells[6].rowspan = 2; e.row.cells[7].rowspan = 2; e.row.cells[7].text += "</th></tr><tr>"; e.row.cells[8].attributes.add("bgcolor", "#99FF99"); e.row.cells[8].columnspan = 5; <asp:templatefield HeaderText="" ShowHeader="False"> <ItemTemplate> <a href="<%# Eval("fl_url") %><%# Eval("fc_name") %>" class="abtn" target="_blank"> </a> </ItemTemplate> <HeaderStyle Width="45pt" HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /> </asp:templatefield> 12-10
JavaScript iframe 2001_del.aspx <asp:templatefield HeaderText="" ShowHeader="False"> <ItemTemplate> <a href="javascript:mdel(<%# Eval("fc_sid") %>,'<%# Eval("fc_name") %>');" class="abtn" title=" javascript iframe "> </a> <asp:literal ID="lt_table" runat="server"></asp:literal> </ItemTemplate> <HeaderStyle Width="45pt" HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /> </asp:templatefield> JavaScript mdel() <script language="javascript" type="text/javascript"> function mdel(msid, fcname) if (confirm("" + fcname + "?\n( javascrip iframe )")) update.location.replace("2001_del.aspx?sid=" + msid); </script> GridView 2001_add.aspx <a href="2001_add.aspx?pageid=<%=lb_pageid.text %>& fc_name=<%=server.urlencode(tb_fc_name.text)%>& fc_ext=<%=server.urlencode(tb_fc_ext.text)%>& fc_desc=<%=server.urlencode(tb_fc_desc.text)%>" class="abtn"> </a> 12-11
VC# 12-1.4.2 2001/2001_del.aspx 2001_del.aspx Load protected void Page_Load(object sender, EventArgs e) string merr = ""; int ckint = 0; // Check_Power("2001", false); if (Request["sid"]!= null) if (int.tryparse(request["sid"].trim(), out ckint)) string SqlString = "", tmpstr = ""; string fl_url = "", fl_path = "", fc_name = ""; #region using (SqlConnection Sql_conn = new SqlConnection(WebConfigurationManager.ConnectionStrings[ "AppSysConnectionString"].ConnectionString)) Sql_conn.Open(); SqlString = "Select Top 1 l.fl_url, c.fc_name From Fi_Content c"; SqlString = SqlString + " Inner Join Fi_Location l On c.fl_no = l.fl_no"; SqlString = SqlString + " Where c.fc_sid = @fc_sid"; using (SqlCommand Sql_Command = new SqlCommand()) #region Sql_Command.Connection = Sql_conn; Sql_Command.CommandText = SqlString; Sql_Command.Parameters.AddWithValue("fc_sid", ckint); SqlDataReader Sql_Reader = Sql_Command.ExecuteReader(); 12-12
if (Sql_Reader.Read()) fc_name = Sql_Reader["fc_name"].ToString().Trim(); fl_url = Sql_Reader["fl_url"].ToString().Trim(); fl_path = Server.MapPath(fl_url); else merr = "!\\n"; Sql_Reader.Close(); Sql_Reader.Dispose(); #endregion #region if (merr == "") try File.Delete(fl_path + fc_name); if (File.Exists(fl_path + fc_name)) merr = "!\\n"; catch (Exception ex) tmpstr = ex.message; tmpstr = tmpstr.replace("\\", "\\\\"); merr = merr + fc_name + "!\\n" + tmpstr + "\\n"; #endregion #region if (merr == "") SqlString = "Delete From Fi_Content Where fc_sid = @fc_sid"; Sql_Command.Parameters.Clear(); Sql_Command.CommandText = SqlString; Sql_Command.Parameters.AddWithValue("fc_sid", ckint); 12-13
VC# Sql_Command.ExecuteNonQuery(); #endregion Sql_Command.Dispose(); #endregion else merr = "!\\n"; else merr = "!\\n"; if (merr == "") lt_show.text = "<script language=javascript>alert(\"!\\n\");"; lt_show.text = lt_show.text + "parent.location.reload();</script>"; else lt_show.text = "<script language=javascript>alert(\"" + merr + "\");</script>"; 12-1.4.3 2001/2001_add.aspx 2001_add.aspx 12-9 <div> <div> <div>... 12-14
<!-- Begin --> <div id="fullwindow" style="position: absolute; top: 0px; left: 0px; width: 1024px; height: 768px; display: none"> <table id="fulltable" border="0" cellpadding="0" cellspacing="0" style="background-image: url(../images/msg_back.gif)"> <tr> <td> </tr> </table> </div> <!-- End --> <!-- Begin --> <div id="msg_wait" class="text9pt" style="position: absolute; width: 240px; z-index: 0; display: none;"> <table border="2" cellpadding="2" cellspacing="2" style="width: 240px; height: 100px;" bgcolor="#efefef"> <tr> <td align="center" class="text9pt">...<br />! </tr> </table> </div> <!-- End --> OnClientClick JavaScript msg_show() <asp:button ID="bn_upload" runat="server" Height="22pt" Text="" OnClick="bn_upload_Click" OnClientClick="msg_show()" /> JavaScript msg_show() <div> 12-15
VC# <script language="javascript" type="text/javascript"> function msg_show() var msgobj, fullobj, tableobj; msgobj = document.getelementbyid("msg_wait"); if (msgobj!= null) msgobj.style.left = String((document.body.clientWidth - 240) / 2) + "px"; msgobj.style.top = String((document.body.clientHeight - 240) / 2) + "px"; msgobj.style.display = ""; fullobj = document.getelementbyid("fullwindow"); if (fullobj!= null) fullobj.style.width = document.body.clientwidth + "px"; fullobj.style.height = document.body.clientheight + "px"; fullobj.style.display = ""; tableobj = document.getelementbyid("fulltable"); if (tableobj!= null) tableobj.style.width = document.body.clientwidth + "px"; tableobj.style.height = document.body.clientheight + "px"; tableobj.style.display = ""; function msg_close() var msgobj; msgobj = document.getelementbyid("msg_wait"); if (msgobj!= null) msgobj.style.display = "none"; fullobj = document.getelementbyid("fullwindow"); if (fullobj!= null) fullobj.style.display = "none"; </script> 12-16
12-9 FileUpload <table width="90%" border="1" bgcolor="#f4bd97" cellpadding="0" cellspacing="2" class="text9pt"> <tr> <td bgcolor="lightyellow" class="text12pt"> 1 <td> <asp:fileupload ID="fu_file1" Width="96%" Height="18pt" runat="server" /> <td> <asp:textbox ID="tb_file1" Width="96%" runat="server"></asp:textbox> </tr> <tr> <td bgcolor="lightyellow" class="text12pt"> 2 <td> 12-17
VC# <asp:fileupload ID="fu_file2" Width="96%" Height="18pt" runat="server" /> <td> <asp:textbox ID="tb_file2" Width="96%" runat="server"></asp:textbox> </tr> <tr> <td bgcolor="lightyellow" class="text12pt"> 10 <td> <asp:fileupload ID="fu_file10" Width="96%" Height="18pt" runat="server" /> <td> <asp:textbox ID="tb_file10" Width="96%" runat="server"></asp:textbox> </tr> </table> OnClientClick OnClick OnClientClick JavaScript msg_show() bn_upload_click bn_upload_click FileUpload Fi_Content JavaScript protected void bn_upload_click(object sender, EventArgs e) int icnt = 0, fcnt = 0, fc_size = 0, jcnt = 0; string SqlString = "", merr = "", tmpstr = ""; string fl_url = "", fl_path = "", fc_name = "", fc_ext = "", fc_desc = "", fc_type = ""; 12-18
// ( // Windows Server ASP.NET) using (SqlConnection Sql_conn = new SqlConnection( WebConfigurationManager.ConnectionStrings[ "AppSysConnectionString"].ConnectionString)) SqlDataReader Sql_Reader; Sql_conn.Open(); using (SqlCommand Sql_Command = new SqlCommand()) #region URL SqlString = "Select Top 1 fl_url From Fi_Location Where fl_no = 1"; Sql_Command.CommandText = SqlString; Sql_Command.Connection = Sql_conn; Sql_Reader = Sql_Command.ExecuteReader(); if (Sql_Reader.Read()) fl_url = Sql_Reader["fl_url"].ToString().Trim(); fl_path = Server.MapPath(fl_url); else merr = "!\\n"; Sql_Reader.Close(); Sql_Reader.Dispose(); #endregion #region for (icnt = 1; icnt <= Request.Files.Count; icnt++) FileUpload fu_file = (FileUpload)Page.FindControl("fu_file" + icnt.tostring()); TextBox tb_file = (TextBox)Page.FindControl("tb_file" + icnt.tostring()); 12-19
VC# if (fu_file.hasfile) fc_name = fu_file.filename; fc_ext = Path.GetExtension(fc_name).ToString(); fc_size = fu_file.postedfile.contentlength; fc_type = fu_file.postedfile.contenttype; fc_desc = tb_file.text.trim(); // // xxxx1.extxxxx2.extxxxx3.ext... fcnt = 0; tmpstr = fc_name.replace(fc_ext, ""); while (File.Exists(fl_path + fc_name)) fcnt++; fc_name = tmpstr + fcnt.tostring() + fc_ext; try jcnt = jcnt + 1; #region fu_file.saveas(fl_path + fc_name); #endregion #region SqlString = "Insert Into Fi_Content (fl_no, fc_name, " + "fc_ext, fc_type, fc_size, fc_desc)"; SqlString = SqlString + " Values (1, @fc_name, @fc_ext, @fc_type, @fc_size, @fc_desc)"; Sql_Command.Parameters.Clear(); Sql_Command.CommandText = SqlString; Sql_Command.Connection = Sql_conn; Sql_Command.Parameters.AddWithValue("fc_name", fc_name); 12-20
Sql_Command.Parameters.AddWithValue( "fc_ext", fc_ext.tolower()); Sql_Command.Parameters.AddWithValue("fc_type", fc_type); Sql_Command.Parameters.AddWithValue("fc_size", fc_size); Sql_Command.Parameters.AddWithValue("fc_desc", fc_desc); Sql_Command.ExecuteNonQuery(); #endregion catch (Exception ex) tmpstr = ex.message; tmpstr = tmpstr.replace("\\", "\\\\"); merr = merr + fc_name + "!\\n" + tmpstr + "\\n"; #endregion if (jcnt == 0) merr = "!\\n"; if (merr!= "") // lt_show.text = "<script language=javascript>msg_close();alert(\"" + merr + "\");</script>"; else // lt_show.text = "<script language=javascript>msg_close();alert(\"!\\n\");"; lt_show.text = lt_show.text + "location.replace(\"2001.aspx" + lb_page.text + "\");</script>"; 12-21