chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,191 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.IO;
|
||||
using WebLib;
|
||||
|
||||
namespace Education.Forms.課程企劃
|
||||
{
|
||||
public partial class ChangePlace : FormBase
|
||||
{
|
||||
private DAC_訓練課程企劃 Dao課程企劃;
|
||||
private DAC_場地異動 Dao場地異動;
|
||||
private int 課程ID;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
FunctionName = "訓練課程企劃書 >> 場地異動";
|
||||
Title = FunctionName;
|
||||
if (!IsPostBack)
|
||||
hf課程ID.Value = Request["ID"];
|
||||
課程ID = DAC.GetInt32(hf課程ID.Value);
|
||||
|
||||
Dao場地異動 = new DAC_場地異動(conn);
|
||||
Dao課程企劃 = new DAC_訓練課程企劃(conn);
|
||||
|
||||
Form_View = fv場地;
|
||||
Grid_View = gv場地;
|
||||
|
||||
Grid_View.DataBind();
|
||||
|
||||
if (!IsPostBack)
|
||||
UpdateUI();
|
||||
|
||||
btnSelect.OnClientClick = String.Format("selectPlace(\"{0}\", \"{1}\", \"{2}\"); return false;",
|
||||
hf場地編號.ClientID, lb新場地編號名稱.ClientID, txt場地名稱.ClientID);
|
||||
btnClear.OnClientClick = String.Format("clearPlace(\"{0}\", \"{1}\", \"{2}\"); return false;",
|
||||
hf場地編號.ClientID, lb新場地編號名稱.ClientID, txt場地名稱.ClientID);
|
||||
|
||||
if (Master is PopupForm popupForm)
|
||||
{
|
||||
popupForm.RefreshOpener = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdateUI()
|
||||
{
|
||||
訓練課程企劃List v1 = Dao課程企劃.SelectOne(課程ID);
|
||||
if (v1.Count > 0)
|
||||
{
|
||||
lb課程企劃.Text = String.Format("[{0}] {1}", v1[0].顯示編號, v1[0].訓練名稱);
|
||||
|
||||
場地異動List v2 = Dao場地異動.Select最後異動(課程ID);
|
||||
if (v2.Count > 0 && v2[0].場地編號 == 0 && !String.IsNullOrEmpty(v2[0].場地名稱))
|
||||
{
|
||||
lb場地編號名稱.Text = String.Format("{0}(自由輸入)", v2[0].場地名稱);
|
||||
}
|
||||
else
|
||||
{
|
||||
場地 place = GetData.取得選定場地(課程ID);
|
||||
lb場地編號名稱.Text = String.Format("[{0:0000}] {1}", place.編號, place.場地名稱);
|
||||
}
|
||||
|
||||
gv場地異動.DataBind();
|
||||
}
|
||||
}
|
||||
|
||||
protected string GetFormControlId(string id)
|
||||
{
|
||||
if (fv場地.PageIndex >= 0)
|
||||
{
|
||||
Control ctrl = fv場地.FindControl(id);
|
||||
if (ctrl != null)
|
||||
return fv場地.FindControl(id).ClientID;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnSelect_Click(object sender, EventArgs e)
|
||||
{
|
||||
hf場地編號.Value = DAC.GetString(fv場地.SelectedValue);
|
||||
lb新場地編號名稱.Text = String.Format("[{0:0000}] {1}", fv場地.SelectedValue, Get場地名稱(fv場地.SelectedValue));
|
||||
|
||||
int 編號 = DAC.GetInt32(fv場地.SelectedValue);
|
||||
場地List d = Dao場地.SelectOne(編號);
|
||||
if (d.Count > 0)
|
||||
{
|
||||
txt場地名稱.Text = d[0].場地名稱;
|
||||
txt場地名稱.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnClear_Click(object sender, EventArgs e)
|
||||
{
|
||||
hf場地編號.Value = "";
|
||||
lb新場地編號名稱.Text = "";
|
||||
txt場地名稱.Text = "";
|
||||
txt場地名稱.Enabled = true;
|
||||
}
|
||||
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (hf場地編號.Value.Length == 0 && String.IsNullOrEmpty(txt場地名稱.Text))
|
||||
{
|
||||
lbMessage選擇場地.Text = "請從場地清單選擇或直接輸入場地名稱!";
|
||||
return;
|
||||
}
|
||||
|
||||
場地異動 newValue = new 場地異動();
|
||||
newValue.課程企劃編號 = 課程ID;
|
||||
newValue.場地編號 = DAC.GetInt32(hf場地編號.Value);
|
||||
newValue.場地名稱 = txt場地名稱.Text;
|
||||
newValue.DB_CRUSR = UserId;
|
||||
Dao場地異動.InsertOne(newValue);
|
||||
|
||||
UpdateUI();
|
||||
txt場地名稱.Enabled = true;
|
||||
|
||||
ClientShowMessage("儲存成功!");
|
||||
}
|
||||
|
||||
protected void dsForm場地_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
|
||||
{
|
||||
e.ObjectInstance = Dao場地;
|
||||
}
|
||||
|
||||
protected void ds場地異動_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
|
||||
{
|
||||
e.ObjectInstance = Dao場地異動;
|
||||
}
|
||||
|
||||
protected void btnPlaceSearch_Click(object sender, EventArgs e)
|
||||
{
|
||||
gv場地.DataBind();
|
||||
}
|
||||
|
||||
protected void fv場地_DataBound(object sender, EventArgs e)
|
||||
{
|
||||
if (fv場地.CurrentMode == FormViewMode.ReadOnly)
|
||||
{
|
||||
int 編號 = DAC.GetInt32(fv場地.SelectedValue);
|
||||
|
||||
Image image1 = (fv場地.FindControl("Image1") as Image);
|
||||
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 = (fv場地.FindControl("Image2") as Image);
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void gv場地異動_RowDeleted(object sender, GridViewDeletedEventArgs e)
|
||||
{
|
||||
UpdateUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user