public string SaveAsNew(string Program) { DbLibrary DbLibraryControl = new DbLibrary(); DataSet DsAddGameResult = new DataSet(); DataSet DsLogResult = new DataSet(); try { DsAddGameResult = DbLibraryControl.QueryDataSet(string.Format(@"insert into GameBasicInfo values (N'{0}',{1},{2},{3},{4},{5},{6},{7}, N'{8}',{9},{10},'{11}',{12},{13},'{14}','{15}',{16}); select SCOPE_IDENTITY() as GamePK;", this.GameName, this.MinPlayer, this.MaxPlayer, this.Time, this.Difficulty, this.Luck, this.Strategy, this.Interaction, this.ImgName, this.RentalNumber, this.IsExtension, this.RentalStartDate, this.Rent, this.Deposit, this.TeachingUrl, this.Description, this.IsOpen ), "AddGameResult"); foreach (string TreeItemPK in this.GameCategory) { DbLibraryControl.Query(string.Format(@"insert into GameCategory values ({0},{1})", DsAddGameResult.Tables["AddGameResult"].Rows[0]["GamePK"].ToString(), TreeItemPK)); } } catch (Exception ex) { DsLogResult = DbLibraryControl.QueryDataSet(string.Format(@"insert into Log values ('{0}', '{1}', 'SaveAsNew', GetDate()); select SCOPE_IDENTITY() as LogPK;", ex.ToString().Replace("'", ""), Program), "LogResult"); return(DsLogResult.Tables["LogResult"].Rows[0]["LogPK"].ToString()); } return("0"); }
public GameBasicInfoStorage(int PK) { DbLibrary DbLibraryControl = new DbLibrary(); DataTable DtGameBasicInfoResult = new DataTable(); DtGameBasicInfoResult = DbLibraryControl.QueryDataSet(string.Format(@"select * from GameBasicInfo where PK = {0}", PK), "GameBasicInfoResult").Tables["GameBasicInfoResult"]; if (DtGameBasicInfoResult.Rows.Count != 0) { this.GameName = DtGameBasicInfoResult.Rows[0]["GameName"].ToString(); this.MinPlayer = Convert.ToInt16(DtGameBasicInfoResult.Rows[0]["MinPlayer"]); this.MaxPlayer = Convert.ToInt16(DtGameBasicInfoResult.Rows[0]["MaxPlayer"]); this.Time = Convert.ToInt16(DtGameBasicInfoResult.Rows[0]["Time"]); this.Difficulty = Convert.ToInt16(DtGameBasicInfoResult.Rows[0]["Difficulty"]); this.Luck = Convert.ToInt16(DtGameBasicInfoResult.Rows[0]["Luck"]); this.Strategy = Convert.ToInt16(DtGameBasicInfoResult.Rows[0]["Strategy"]); this.Interaction = Convert.ToInt16(DtGameBasicInfoResult.Rows[0]["Interaction"]); this.ImgName = DtGameBasicInfoResult.Rows[0]["ImgName"].ToString(); this.RentalNumber = Convert.ToInt16(DtGameBasicInfoResult.Rows[0]["RentalNumber"]); this.IsExtension = Convert.ToUInt16(DtGameBasicInfoResult.Rows[0]["IsExtension"]); this.RentalStartDate = Convert.ToDateTime(DtGameBasicInfoResult.Rows[0]["RentalStartDate"]).ToString("yyyy-MM-dd"); this.Rent = Convert.ToInt16(DtGameBasicInfoResult.Rows[0]["Rent"]); this.Deposit = Convert.ToInt16(DtGameBasicInfoResult.Rows[0]["Deposit"]); this.TeachingUrl = DtGameBasicInfoResult.Rows[0]["TeachingUrl"].ToString(); this.Description = DtGameBasicInfoResult.Rows[0]["Description"].ToString(); this.IsOpen = Convert.ToUInt16(DtGameBasicInfoResult.Rows[0]["IsOpen"]); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //列表預設值 hfSortColumn.Value = "GBI.GameName"; hfSortValue.Value = "asc"; hfPerPageDataCount.Value = "5"; hfCurPage.Value = "1"; hfTotalPage.Value = "1"; hfTableMode.Value = "0"; btnTableMode.Text = GetLocalResourceObject("PictureMode").ToString(); divListTable.Visible = true; divPictureTable.Visible = false; btnSearchClick(null, null); } //類型 DataSet DsGameTypes = DbLibraryControl.QueryDataSet("select TI.* from Tree as T inner join TreeItem as TI on TI.TreePK = T.PK where T.Name = 'GameType'", "GameTypesResult"); foreach (DataRow row in DsGameTypes.Tables["GameTypesResult"].Rows) { Label lblType = new Label() { CssClass = "checkbox-inline" }; CheckBox cblType = new CheckBox { Text = row["Name"].ToString() + " ", Checked = false }; cblType.InputAttributes["value"] = row["PK"].ToString(); lblType.Controls.Add(cblType); divType.Controls.Add(lblType); } }
protected void Page_Load(object sender, EventArgs e) { Action = Request.QueryString["Action"]; PK = Request.QueryString["PK"]; //縮圖 if (Session["FileUploadControl"] == null && GamePhotoFile.HasFile) { //This condition occurs for first time you upload a file Session["FileUploadControl"] = GamePhotoFile; lblPhotoName.Text = GamePhotoFile.FileName; } else if (Session["FileUploadControl"] != null && (!GamePhotoFile.HasFile)) { //This condition will occur on next postbacks GamePhotoFile = (FileUpload)Session["FileUploadControl"]; lblPhotoName.Text = GamePhotoFile.FileName; } else if (GamePhotoFile.HasFile) { //when Session will have File but user want to change the file Session["FileUploadControl"] = GamePhotoFile; lblPhotoName.Text = GamePhotoFile.FileName; } //類型 string[] DelPKs = hfDelTypePKs.Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); DataSet DsGameTypes = DbLibraryControl.QueryDataSet("select TI.* from Tree as T inner join TreeItem as TI on TI.TreePK = T.PK where T.Name = 'GameType'", "GameTypesResult"); foreach (DataRow row in DsGameTypes.Tables["GameTypesResult"].Rows) { Label lblType = new Label() { CssClass = "checkbox-inline" }; CheckBox cblType = new CheckBox { Text = row["Name"].ToString() + " ", Checked = false }; cblType.InputAttributes["value"] = row["PK"].ToString(); //刪除的PK需隱藏 if ((DelPKs.Count() != 0) && (DelPKs.Contains(row["PK"].ToString()))) { cblType.InputAttributes["style"] = "display:none;"; lblType.Style["display"] = "none"; } lblType.Controls.Add(cblType); divType.Controls.Add(lblType); } if (Action == "Add") { divAdd.Visible = true; } else { divAdd.Visible = false; } }