chore: 首次簽入 Thinkyu ASP.NET 專案

- 加入 Visual Studio / ASP.NET .gitignore
- 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
2026-09-10 09:42:37 +08:00
commit 577060bc78
2496 changed files with 501389 additions and 0 deletions
@@ -0,0 +1,354 @@
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using WebLib;
namespace Education.Forms.
{
public partial class : FormBase
{
private bool fileOK = false;
private int ;
private string ;
protected void Page_Load(object sender, EventArgs e)
{
FunctionName = "場地基本資料";
= Server.MapPath(Education.PublicVariable.);
Form_View = FormView1;
Grid_View = GridView1;
FormView_DataSource = dsForm;
GridView_DataSource = dsGrid;
AddTabButton(MultiView1, 0, btnSearchTab);
AddTabButton(MultiView1, 1, btnProcessTab);
if (!IsPostBack)
{
BindSearchDDL();
ActivateTab(MultiView1, 1);
}
else
{
Grid_View.DataBind();
Form_View.DataBind();
}
if (Form_View.CurrentMode != FormViewMode.ReadOnly)
{
Grid_View.Visible = false;
}
}
private void BindSearchDDL()
{
ddl場地地區.DataSource = Dao場地.Select地區ForDropDown();
ddl場地地區.DataTextField = "Name";
ddl場地地區.DataValueField = "Value";
ddl場地地區.DataBind();
ddl場地教室類型.DataSource = Dao場地.Select教室類型ForDropDown();
ddl場地教室類型.DataTextField = "Name";
ddl場地教室類型.DataValueField = "Value";
ddl場地教室類型.DataBind();
}
protected override void CalcFields(object sender, ObjectDataSourceMethodEventArgs e)
{
base.CalcFields(sender, e);
}
protected override void FormView_ReadOnlyDataBound(object sender, EventArgs e)
{
base.FormView_ReadOnlyDataBound(sender, e);
int = 0;
Label lb編號 = FindControl<Label>(Form_View, "lb編號");
if (lb編號 != null)
= DAC.GetInt32(lb編號.Text);
Image image1 = FindControl<Image>(Form_View, "Image1");
if (image1 != null)
{
string[] tmp = image1.ImageUrl.Split('?');
if (tmp.Length > 0 && !File.Exists(Server.MapPath(tmp[0])))
{
image1.ImageUrl = "~/picture/nopicture.jpg";
image1.Attributes.Remove("onclick");
image1.Style.Remove("cursor");
}
else
{
image1.Attributes.Add("onclick", GetOpenWindowJS("../Common/ShowLargePicture.aspx", "_picture", "pic", String.Format(Education.PublicVariable. + "{0:000000}_1.jpg", )));
image1.Style.Add("cursor", "pointer");
}
}
Image image2 = FindControl<Image>(Form_View, "Image2");
if (image2 != null)
{
string[] tmp = image2.ImageUrl.Split('?');
if (tmp.Length > 0 && !File.Exists(Server.MapPath(tmp[0])))
{
image2.ImageUrl = "~/picture/nopicture.jpg";
image2.Attributes.Remove("onclick");
image2.Style.Remove("cursor");
}
else
{
image2.Attributes.Add("onclick", GetOpenWindowJS("../Common/ShowLargePicture.aspx", "_picture", "pic", String.Format(Education.PublicVariable. + "{0:000000}_2.jpg", )));
image2.Style.Add("cursor", "pointer");
}
}
System.Data.DataTable 滿 = Dao場地.Select滿意度統計();
if (滿.Rows.Count > 0)
{
Label lb5分 = FindControl<Label>(Form_View, "lb5分");
Label lb4分 = FindControl<Label>(Form_View, "lb4分");
Label lb3分 = FindControl<Label>(Form_View, "lb3分");
Label lb2分 = FindControl<Label>(Form_View, "lb2分");
Label lb1分 = FindControl<Label>(Form_View, "lb1分");
Label lb總分 = FindControl<Label>(Form_View, "lb總分");
if (lb5分 != null)
lb5分.Text = DAC.GetString(滿.Rows[0]["場地滿意度5"]);
if (lb4分 != null)
lb4分.Text = DAC.GetString(滿.Rows[0]["場地滿意度4"]);
if (lb3分 != null)
lb3分.Text = DAC.GetString(滿.Rows[0]["場地滿意度3"]);
if (lb2分 != null)
lb2分.Text = DAC.GetString(滿.Rows[0]["場地滿意度2"]);
if (lb1分 != null)
lb1分.Text = DAC.GetString(滿.Rows[0]["場地滿意度1"]);
if (lb總分 != null)
lb總分.Text = String.Format("{0:##0.00}", 滿.Rows[0]["場地滿意度總分"]);
}
RegisterPostbackTrigger(Form_View.FindControl("btnUploadPhoto1"));
RegisterPostbackTrigger(Form_View.FindControl("btnUploadPhoto2"));
}
protected override void FormView_InsertDataBound(object sender, EventArgs e)
{
base.FormView_InsertDataBound(sender, e);
FormViewSetControlValue("txt價格", "0");
FormViewSetControlValue("txt坪數", "0");
FormViewSetControlValue("txt容納人數", "0");
FormViewSetControlValue("txt捷運分鐘", "0");
FormViewSetControlValue("txt公車分鐘", "0");
FormViewSetControlValue("txt火車分鐘", "0");
FormViewSetControlValue("txt步行分鐘", "0");
}
protected override void FormView_ItemInserted(object sender, FormViewInsertedEventArgs e)
{
base.FormView_ItemInserted(sender, e);
//FileUpload fu1 = Form_View.FindControl("fuPhoto1") as FileUpload;
//FileUpload fu2 = Form_View.FindControl("fuPhoto2") as FileUpload;
// 儲存照片與縮圖(fu1, fu2, 新編號);
BindSearchDDL();
}
protected override void FormView_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
{
base.FormView_ItemUpdated(sender, e);
//FileUpload fu1 = Form_View.FindControl("fuPhoto1") as FileUpload;
//FileUpload fu2 = Form_View.FindControl("fuPhoto2") as FileUpload;
//儲存照片與縮圖(fu1, fu2, DAC.GetInt32(e.Keys["編號"]));
BindSearchDDL();
}
protected override void FormView_ItemDeleting(object sender, FormViewDeleteEventArgs e)
{
base.FormView_ItemDeleting(sender, e);
if (Dao場地.IsOccipued(DAC.GetInt32(e.Keys["編號"])))
{
ClientShowMessage("此場地已經選用過,不可刪除!");
e.Cancel = true;
}
}
protected override void FormView_ItemDeleted(object sender, FormViewDeletedEventArgs e)
{
base.FormView_ItemDeleted(sender, e);
// 刪除縮圖與大圖
string s1 = String.Format("{0}T_{1:000000}_1.jpg", , e.Keys["編號"]);
string s2 = String.Format("{0}T_{1:000000}_2.jpg", , e.Keys["編號"]);
string s3 = String.Format("{0}{1:000000}_1.jpg", , e.Keys["編號"]);
string s4 = String.Format("{0}{1:000000}_2.jpg", , e.Keys["編號"]);
if (File.Exists(s1))
File.Delete(s1);
if (File.Exists(s2))
File.Delete(s2);
if (File.Exists(s3))
File.Delete(s3);
if (File.Exists(s4))
File.Delete(s4);
BindSearchDDL();
}
protected override void FormView_DataSource_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
{
base.FormView_DataSource_Inserted(sender, e);
= DAC.GetInt32(e.ReturnValue);
}
protected override void FormView_ItemCommand(object sender, FormViewCommandEventArgs e)
{
base.FormView_ItemCommand(sender, e);
if (e.CommandName == "刪除圖片1")
{
string s1 = String.Format("{0}T_{1:000000}_1.jpg", , DAC.GetInt32(e.CommandArgument));
string s3 = String.Format("{0}{1:000000}_1.jpg", , DAC.GetInt32(e.CommandArgument));
if (File.Exists(s1))
File.Delete(s1);
if (File.Exists(s3))
File.Delete(s3);
Form_View.DataBind();
}
if (e.CommandName == "刪除圖片2")
{
string s2 = String.Format("{0}T_{1:000000}_2.jpg", , DAC.GetInt32(e.CommandArgument));
string s4 = String.Format("{0}{1:000000}_2.jpg", , DAC.GetInt32(e.CommandArgument));
if (File.Exists(s2))
File.Delete(s2);
if (File.Exists(s4))
File.Delete(s4);
Form_View.DataBind();
}
if (e.CommandName == "上傳照片1")
{
FileUpload fu = FindControl<FileUpload>(Form_View, "fuPhoto1");
CheckPhoto(fu, out fileOK);
(fu, DAC.GetInt32(e.CommandArgument), 1);
Form_View.DataBind();
}
if (e.CommandName == "上傳照片2")
{
FileUpload fu = FindControl<FileUpload>(Form_View, "fuPhoto2");
CheckPhoto(fu, out fileOK);
(fu, DAC.GetInt32(e.CommandArgument), 2);
Form_View.DataBind();
}
}
protected override void GridView_DataSource_Selected(object sender, ObjectDataSourceStatusEventArgs e)
{
base.GridView_DataSource_Selected(sender, e);
if (MultiView1.ActiveViewIndex == 0)
{
if (e.ReturnValue is List list && list.Count > 0)
ActivateTab(MultiView1, 1);
else
lbMessage.Text = "找不到合乎條件的資料";
}
}
protected void (FileUpload fu1, int , int )
{
if (fileOK)
{
string tFullName = String.Format("{0}T_{1:000000}_{2}.jpg", , , );
MemoryStream ms = PictureProcess.(fu1.PostedFile.InputStream, 300, 300);
File.WriteAllBytes(tFullName, ms.ToArray());
ms.Dispose();
tFullName = String.Format("{0}{1:000000}_{2}.jpg", , , );
ms = PictureProcess.(fu1.PostedFile.InputStream, 1200, 1200);
File.WriteAllBytes(tFullName, ms.ToArray());
ms.Dispose();
}
/*
if (file2OK)
{
string tFullName = String.Format("{0}T_{1:000000}_2.jpg", 圖檔儲存路徑, 編號);
MemoryStream ms = PictureProcess.縮圖(fu2.PostedFile.InputStream, 270, 270);
File.WriteAllBytes(tFullName, ms.ToArray());
ms.Dispose();
tFullName = String.Format("{0}{1:000000}_2.jpg", 圖檔儲存路徑, 編號);
ms = PictureProcess.縮圖(fu2.PostedFile.InputStream, 1200, 1200);
File.WriteAllBytes(tFullName, ms.ToArray());
ms.Dispose();
}
*/
}
protected void cvPhoto1_ServerValidate(object source, ServerValidateEventArgs args)
{
FileUpload fu = FindControl<FileUpload>(Form_View, "fuPhoto1");
args.IsValid = CheckPhoto(fu, out fileOK);
}
protected void cvPhoto2_ServerValidate(object source, ServerValidateEventArgs args)
{
FileUpload fu = FindControl<FileUpload>(Form_View, "fuPhoto2");
args.IsValid = CheckPhoto(fu, out fileOK);
}
protected bool CheckPhoto(FileUpload fu, out bool fileOK)
{
// 處理上傳照片
string ext = "";
fileOK = false;
if (fu.HasFile && fu.PostedFile.ContentType.ToLower().IndexOf("image") >= 0)
{
// 檢查副檔名
ext = Path.GetExtension(fu.FileName).ToLower();
String[] allowedExt = { ".gif", ".jpeg", ".jpg", ".png" };
for (int i = 0; i < allowedExt.Length; i++)
{
if (ext == allowedExt[i])
{
fileOK = true;
}
}
// 檢查檔案大小
if (fileOK && fu.PostedFile.ContentLength < 5242880)
fileOK = true;
else
fileOK = false;
return fileOK;
}
else
{
return false;
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
Grid_View.PageIndex = 0;
Grid_View.DataBind();
}
protected void btnClear_Click(object sender, EventArgs e)
{
ddl場地地區.SelectedValue = "";
txt場地價格1.Text = "";
txt場地價格2.Text = "";
txt場地人數1.Text = "";
txt場地人數2.Text = "";
ddl場地教室類型.SelectedValue = "";
txt場地滿意度1.Text = "";
txt場地滿意度2.Text = "";
}
protected void dsForm_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
{
e.ObjectInstance = Dao場地;
}
}
}