public Superman() : base("Superman") { AttackPower = 25; HealPower = 10; Health = new Excellent(100); Health.Hero = this; }
public Darkseid() : base("Darkseid") { AttackPower = 15; HealPower = 10; Health = new Excellent(100); Health.Hero = this; }
protected void Page_Load(object sender, EventArgs e) { lbID.Text = Request.Params["eid"]; ex = Excellent.GetExcellent(new Guid(lbID.Text)); this.Title = ex.Title; SetPics(lbID.Text); }
private void GetCurrentRess() { Ress = new StateList <Res>(); if (_excellent == null) { _excellent = new Excellent(); _excellent.DateCreated = DateTime.Now.AddHours(-TrainSettings.Instance.Timezone); } foreach (Res item in _excellent.Ress) { Ress.Add(item); } //foreach (Res titem in _excellent.TempAddRess.Keys) //{ // if (_excellent.TempAddRess[titem] == "add") // { // Ress.Add(titem); // } // else // { // Ress.Remove(titem); // } //} //Ress = _excellent.Ress; }
private List <Excellent> getTempSelect() { List <Excellent> tmp = new List <Excellent>(); foreach (GridViewRow row in gridComments.Rows) { try { CheckBox cbx = (CheckBox)row.FindControl("chkSelect"); if (cbx != null && cbx.Checked) { Excellent crl = Excellents.Find( delegate(Excellent c) { return(c.Id == (Guid)gridComments.DataKeys[row.RowIndex].Value); }); if (crl != null) { tmp.Add(crl); } } } catch (Exception e) { Utils.Log(string.Format("Error processing selected row in comments data grid: {0}", e.Message)); } } return(tmp); }
protected void GridList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { HtmlAnchor a1 = e.Row.Cells[0].FindControl("a1") as HtmlAnchor; HtmlAnchor aPages = e.Row.Cells[0].FindControl("aPages") as HtmlAnchor; Excellent crl = e.Row.DataItem as Excellent; Res rs = Res.GetRes(crl.MastPic); if (rs != null) { a1.HRef = rs.GetResTempFilePath(); } aPages.HRef = GetEditHtml(crl.Id.ToString()); Label ltDays = e.Row.Cells[0].FindControl("ltDays") as Label; Label ltAddress = e.Row.Cells[0].FindControl("ltAddress") as Label; Excellent ex = e.Row.DataItem as Excellent; if (ex != null) { ltDays.Text = ex.TrainingDate.ToShortDateString(); ltAddress.Text = ex.CityTown; } } }
protected void Page_Load(object sender, EventArgs e) { lbID.Text = Request.Params["eid"]; ex = Excellent.GetExcellent(new Guid(lbID.Text)); this.Title = ex.Title; SetPics(lbID.Text); }
private void ApproveExcellent(Excellent cm) { bool found = false; for (int i = 0; i < Excellent.Excellents.Count; i++) { if (Excellent.Excellents[i].Id == cm.Id) { if (!cm.IsPublished) { Excellent.Excellents[i].IsPublished = true; Excellent.Excellents[i].DateModified = DateTime.Now; Excellent.Excellents[i].Save(); } found = true; break; } if (found) { break; } } }
public bool HasNoChildrenAndApped(Guid comId) { Excellent p = Excellent.GetExcellent(comId); if (p.IsPublished && Page.User.IsInRole("administrators")) { return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Table table = new Table(); table.Style.Add(HtmlTextWriterStyle.Width, "100%"); table.Style.Add(HtmlTextWriterStyle.BorderWidth, "0"); PlaceHolder.Controls.Add(table); TableRow tr = new TableRow(); table.Rows.Add(tr); List <Excellent> exs = Excellent.Excellents.FindAll( delegate(Excellent ex) { return(ex.IsPublished == true); }); exs.Sort(delegate(Excellent a1, Excellent a2) { return(a2.DateCreated.CompareTo(a1.DateCreated)); }); int num = 0; int rowCellCount = 0; for (int i = 0; i < exs.Count; i++) { Excellent exl = exs[i]; if (num < 4) { TableCell tc = new TableCell(); tc.Style.Add(HtmlTextWriterStyle.TextAlign, "center"); tc.Text = "<div><img style='border: 1px solid #C0C0C0' width='135px' height='100px' src='" + SetImageUrl(exl.MastPic.ToString()) + "' /></div><div><a href='" + Utils.AbsoluteWebRoot + @"Views\ExcellentView.aspx?eid=" + exl.Id + "'>" + exl.Title + "</a></div>"; if (rowCellCount < 2) { tr.Cells.Add(tc); rowCellCount++; num++; } if (rowCellCount == 2 && num != 4) { tr = new TableRow(); table.Rows.Add(tr); rowCellCount = 0; } } } } }
private void RemoveExcellents(Excellent cm) { bool found = false; for (int i = 0; i < Excellent.Excellents.Count; i++) { if (Excellent.Excellents[i].Id == cm.Id) { Excellent.Excellents[i].Delete(); Excellent.Excellents[i].Save(); found = true; break; } if (found) { break; } } }
protected void Page_Load(object sender, EventArgs e) { txtTitle.Focus(); #region Regist Callback String cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context"); String callbackScript; callbackScript = "function CallServer(arg, context)" + "{ " + cbReference + ";}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true); #endregion if (!Page.IsPostBack && !Page.IsCallback) { BindTeacher(); _id = HttpContext.Current.Request.QueryString["id"]; if (_id != null && _id != string.Empty) { _excellent = Excellent.GetExcellent(new Guid(_id)); } if (_excellent != null) { ViewState.Add("IsActionNew", false); fistLoadPageMastId = _excellent.MastPic; isFistLoadPage = true; BindExcellent(); } else { IsActionNew = true; ViewState.Add("IsActionNew", true); } } else { IsActionNew = (bool)ViewState["IsActionNew"]; } }
/// <summary> /// Saves an existing field to the database /// </summary> /// <param name="category">field to be saved</param> public override void UpdateExcellent(Excellent info) { string connString = ConfigurationManager.ConnectionStrings[connStringName].ConnectionString; string providerName = ConfigurationManager.ConnectionStrings[connStringName].ProviderName; DbProviderFactory provider = DbProviderFactories.GetFactory(providerName); using (DbConnection conn = provider.CreateConnection()) { conn.ConnectionString = connString; conn.Open(); using (DbCommand cmd = conn.CreateCommand()) { string sqlQuery = "UPDATE " + tablePrefix + "Excellent " + "SET Title=@Title,CityTown=@CityTown,Teacher=@Teacher,TrainingDate=@TrainingDate,MastPic=@MastPic,IsPublished=@IsPublished,Author=@Author " + "WHERE ExcellentID = @ExcellentID "; if (parmPrefix != "@") sqlQuery = sqlQuery.Replace("@", parmPrefix); cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; DbParameter dpID = provider.CreateParameter(); dpID.ParameterName = parmPrefix + "ExcellentID"; dpID.Value = info.Id.ToString(); cmd.Parameters.Add(dpID); DbParameter dpTitle = provider.CreateParameter(); dpTitle.ParameterName = parmPrefix + "Title"; dpTitle.Value = info.Title.ToString(); cmd.Parameters.Add(dpTitle); DbParameter dpCityTown = provider.CreateParameter(); dpCityTown.ParameterName = parmPrefix + "CityTown"; dpCityTown.Value = info.CityTown; cmd.Parameters.Add(dpCityTown); DbParameter dpTeacher = provider.CreateParameter(); dpTeacher.ParameterName = parmPrefix + "Teacher"; dpTeacher.Value = info.Teacher; cmd.Parameters.Add(dpTeacher); DbParameter dpTrainingDate = provider.CreateParameter(); dpTrainingDate.ParameterName = parmPrefix + "TrainingDate"; dpTrainingDate.Value = info.TrainingDate; cmd.Parameters.Add(dpTrainingDate); DbParameter dpMastPic = provider.CreateParameter(); dpMastPic.ParameterName = parmPrefix + "MastPic"; dpMastPic.Value = info.MastPic; cmd.Parameters.Add(dpMastPic); DbParameter dpIsPublished = provider.CreateParameter(); dpIsPublished.ParameterName = parmPrefix + "IsPublished"; dpIsPublished.Value = info.IsPublished; cmd.Parameters.Add(dpIsPublished); DbParameter dpAuthor = provider.CreateParameter(); dpAuthor.ParameterName = parmPrefix + "Author"; dpAuthor.Value = info.Author; cmd.Parameters.Add(dpAuthor); cmd.ExecuteNonQuery(); } UpdateRessForExcellent(info, conn, provider); } }
/// <summary> /// Returns a field /// </summary> /// <param name="id">Id of Excellent to return</param> /// <returns></returns> public override Excellent SelectExcellent(Guid id) { Excellent excellent = new Excellent(); string connString = ConfigurationManager.ConnectionStrings[connStringName].ConnectionString; string providerName = ConfigurationManager.ConnectionStrings[connStringName].ProviderName; DbProviderFactory provider = DbProviderFactories.GetFactory(providerName); using (DbConnection conn = provider.CreateConnection()) { conn.ConnectionString = connString; using (DbCommand cmd = conn.CreateCommand()) { string sqlQuery = "SELECT ExcellentID,Title,CityTown,Teacher,TrainingDate, " + " MastPic,IsPublished,Author " + "FROM " + tablePrefix + "Excellent " + "WHERE ExcellentID = " + parmPrefix + "id"; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; DbParameter dpID = provider.CreateParameter(); dpID.ParameterName = parmPrefix + "id"; dpID.Value = id.ToString(); cmd.Parameters.Add(dpID); conn.Open(); using (DbDataReader rdr = cmd.ExecuteReader()) { if (rdr.HasRows) { rdr.Read(); excellent.Id = rdr.GetGuid(0); excellent.Title = rdr.GetString(1); excellent.CityTown = rdr.GetString(2); excellent.Teacher = rdr.GetString(3); excellent.TrainingDate = rdr.GetDateTime(4); excellent.MastPic = rdr.GetGuid(5); excellent.IsPublished = rdr.GetBoolean(6); excellent.Author = rdr.GetString(7); } } //Ress sqlQuery = "SELECT ResID " + "FROM " + tablePrefix + "ExcellentRes " + "WHERE ExcellentID = " + parmPrefix + "id"; cmd.CommandText = sqlQuery; using (DbDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { if (!rdr.IsDBNull(0)) excellent.Ress.Add(Res.GetRes(rdr.GetGuid(0))); } } excellent.Ress.MarkOld(); } } return excellent; }
/// <summary> /// Deletes a field from the database /// </summary> /// <param name="info">field to be removed</param> public override void DeleteExcellent(Excellent info) { string connString = ConfigurationManager.ConnectionStrings[connStringName].ConnectionString; string providerName = ConfigurationManager.ConnectionStrings[connStringName].ProviderName; DbProviderFactory provider = DbProviderFactories.GetFactory(providerName); using (DbConnection conn = provider.CreateConnection()) { conn.ConnectionString = connString; conn.Open(); using (DbCommand cmd = conn.CreateCommand()) { string sqlQuery = "DELETE FROM " + tablePrefix + "Excellent WHERE ExcellentID = " + parmPrefix + "ExcellentID;"+ "DELETE FROM " + tablePrefix + "ExcellentRes WHERE ExcellentID = " + parmPrefix + "ExcellentID"; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; DbParameter dpID = provider.CreateParameter(); dpID.ParameterName = parmPrefix + "ExcellentID"; dpID.Value = info.Id.ToString(); cmd.Parameters.Add(dpID); cmd.ExecuteNonQuery(); } } foreach (Res rs in info.Ress) { rs.Delete(); rs.Save(); } }
/// <summary> /// Updates an existing Excellent in the data store specified by the provider. /// </summary> public abstract void UpdateExcellent(Excellent excellent);
private void RemoveExcellents(Excellent cm) { bool found = false; for (int i = 0; i < Excellent.Excellents.Count; i++) { if (Excellent.Excellents[i].Id == cm.Id) { Excellent.Excellents[i].Delete(); Excellent.Excellents[i].Save(); found = true; break; } if (found) { break; } } }
/// <summary> /// Persists a new Excellent in the current provider. /// </summary> public static void InsertExcellent(Excellent excellent) { LoadProviders(); _provider.InsertExcellent(excellent); }
public static string GetAppInfo(Guid id) { string msg = Excellent.GetExcellent(id).IsPublished ? "已发布" : "未发布"; return(msg); }
/// <summary> /// Deletes a Excellent from the data store specified by the provider. /// </summary> public abstract void DeleteExcellent(Excellent excellent);
private void UpdateRessForExcellent(Excellent parent, DbConnection conn, DbProviderFactory provider) { string table = "ExcellentRes"; string key = "ExcellentID"; string sqlQuery = "DELETE FROM " + tablePrefix + table + " WHERE " + key + " = " + parmPrefix + "id"; using (DbCommand cmd = conn.CreateCommand()) { cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; DbParameter dpID = provider.CreateParameter(); dpID.ParameterName = parmPrefix + "id"; dpID.Value = parent.Id.ToString(); cmd.Parameters.Add(dpID); cmd.ExecuteNonQuery(); foreach (Res info in parent.Ress) { cmd.CommandText = "INSERT INTO " + tablePrefix + table + " (" + key + ", ResID) " + "VALUES (" + parmPrefix + "pid, " + parmPrefix + "ResID)"; cmd.Parameters.Clear(); DbParameter dpcID = provider.CreateParameter(); dpcID.ParameterName = parmPrefix + "pid"; dpcID.Value = parent.Id.ToString(); cmd.Parameters.Add(dpcID); DbParameter dpInfoID = provider.CreateParameter(); dpInfoID.ParameterName = parmPrefix + "ResID"; dpInfoID.Value = info.Id.ToString(); cmd.Parameters.Add(dpInfoID); cmd.ExecuteNonQuery(); } } }
private void ApproveExcellent(Excellent cm) { bool found = false; for (int i = 0; i < Excellent.Excellents.Count; i++) { if (Excellent.Excellents[i].Id == cm.Id) { if (!cm.IsPublished) { Excellent.Excellents[i].IsPublished = true; Excellent.Excellents[i].DateModified = DateTime.Now; Excellent.Excellents[i].Save(); } found = true; break; } if (found) { break; } } }
/// <summary> /// Deletes the specified Excellent from the current provider. /// </summary> public static void DeleteExcellent(Excellent excellent) { LoadProviders(); _provider.DeleteExcellent(excellent); }
private void GetCurrentRess() { Ress = new StateList<Res>(); if (_excellent == null) { _excellent = new Excellent(); _excellent.DateCreated = DateTime.Now.AddHours(-TrainSettings.Instance.Timezone); } foreach (Res item in _excellent.Ress) { Ress.Add(item); } //foreach (Res titem in _excellent.TempAddRess.Keys) //{ // if (_excellent.TempAddRess[titem] == "add") // { // Ress.Add(titem); // } // else // { // Ress.Remove(titem); // } //} //Ress = _excellent.Ress; }
/// <summary> /// Inserts a new Excellent into the data store specified by the provider. /// </summary> public abstract void InsertExcellent(Excellent excellent);
/// <summary> /// Updates an exsiting Excellent. /// </summary> public static void UpdateExcellent(Excellent excellent) { LoadProviders(); _provider.UpdateExcellent(excellent); }
/// <summary> /// Persists a new Excellent in the current provider. /// </summary> public static void InsertExcellent(Excellent excellent) { LoadProviders(); _provider.InsertExcellent(excellent); }
protected void Page_Load(object sender, EventArgs e) { txtTitle.Focus(); #region Regist Callback String cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context"); String callbackScript; callbackScript = "function CallServer(arg, context)" + "{ " + cbReference + ";}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true); #endregion if (!Page.IsPostBack && !Page.IsCallback) { BindTeacher(); _id = HttpContext.Current.Request.QueryString["id"]; if (_id != null && _id != string.Empty) { _excellent = Excellent.GetExcellent(new Guid(_id)); } if (_excellent != null) { ViewState.Add("IsActionNew", false); fistLoadPageMastId = _excellent.MastPic; isFistLoadPage = true; BindExcellent(); } else { IsActionNew = true; ViewState.Add("IsActionNew", true); } } else { IsActionNew = (bool)ViewState["IsActionNew"]; } }
/// <summary> /// Updates an existing Excellent in the data store specified by the provider. /// </summary> public abstract void UpdateExcellent(Excellent excellent);
/// <summary> /// Updates an exsiting Excellent. /// </summary> public static void UpdateExcellent(Excellent excellent) { LoadProviders(); _provider.UpdateExcellent(excellent); }
/// <summary> /// Deletes a Excellent from the data store specified by the provider. /// </summary> public abstract void DeleteExcellent(Excellent excellent);
/// <summary> /// Deletes the specified Excellent from the current provider. /// </summary> public static void DeleteExcellent(Excellent excellent) { LoadProviders(); _provider.DeleteExcellent(excellent); }
/// <summary> /// Inserts a new Excellent into the data store specified by the provider. /// </summary> public abstract void InsertExcellent(Excellent excellent);