protected void GridList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { HtmlAnchor aPages = e.Row.Cells[0].FindControl("aPages") as HtmlAnchor; CurriculaInfo crl = ((CurriculaInfo)e.Row.DataItem) as CurriculaInfo; aPages.HRef = GetEditHtml(crl.CurriculaId.ToString()); Label ltDes = e.Row.Cells[0].FindControl("ltDes") as Label; Label lbStartDate = e.Row.Cells[0].FindControl("lbStartDate") as Label; Label lbCast = e.Row.Cells[0].FindControl("lbCast") as Label; Label lbCity = e.Row.Cells[0].FindControl("lbCity") as Label; Label lbDays = e.Row.Cells[0].FindControl("lbDays") as Label; CurriculaInfo fd = e.Row.DataItem as CurriculaInfo; if (fd != null) { ltDes.Text = StripString(fd.Curricula.Content, 175, true); lbStartDate.Text = fd.StartDate.ToShortDateString(); lbCast.Text = fd.Cast.ToString(); lbCity.Text = fd.CityTown.ToString(); int iDays = fd.EndDate.Subtract(fd.StartDate).Days + 1; lbDays.Text = iDays.ToString(); } } }
private void DeleteInfo(Guid id) { CurriculaInfo crlinfo = CurriculaInfo.GetCurriculaInfo(id); Curricula crl = Curricula.GetCurriculaByCurriculaInfo(id); crl.RemoveCurriculaInfo(crlinfo); int i = HttpContext.Current.Request.RawUrl.IndexOf('?'); Response.Redirect(HttpContext.Current.Request.RawUrl.Substring(0, i)); }
protected void btnSave_Click(object sender, EventArgs e) { CurriculaInfo cli = new CurriculaInfo(); cli.CurriculaId = _curricula.Id; cli.StartDate = Convert.ToDateTime(txtStart.Text); cli.EndDate = Convert.ToDateTime(txtEnd.Text); cli.CityTown = txtCity.Text; cli.Cast = Convert.ToInt32(txtCast.Text); _curricula.AddCurriculaInfo(cli); Reload(); }
protected void btnSave_Click(object sender, EventArgs e) { CurriculaInfo cli = new CurriculaInfo(); cli.CurriculaId = _curricula.Id; cli.StartDate = Convert.ToDateTime(txtStart.Text); cli.EndDate = Convert.ToDateTime(txtEnd.Text); cli.CityTown = txtCity.Text; cli.Cast = Convert.ToInt32(txtCast.Text); _curricula.AddCurriculaInfo(cli); Reload(); }
/// <summary> /// Updates an exsiting CurriculaInfo. /// </summary> public static void UpdateCurriculaInfo(CurriculaInfo info) { LoadProviders(); _provider.UpdateCurriculaInfo(info); }
/// <summary> /// Gets all categories in database /// </summary> /// <returns>List of categories</returns> public override List<CurriculaInfo> FillCurriculaInfos() { List<CurriculaInfo> infos = new List<CurriculaInfo>(); 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 InfoID, CurriculaID,StartDate,EndDate,Cast,CityTown,IsPublished " + "FROM " + tablePrefix + "CurriculaInfo "; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; conn.Open(); using (DbDataReader rdr = cmd.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { CurriculaInfo inf = new CurriculaInfo(); inf.CurriculaId = rdr.GetGuid(1); inf.StartDate = rdr.GetDateTime(2); inf.EndDate = rdr.GetDateTime(3); inf.Cast = rdr.GetInt32(4); inf.CityTown = rdr.GetString(5); if (rdr.IsDBNull(6)) { inf.IsPublished = rdr.GetBoolean(6); } else { inf.IsPublished = false; } inf.Id = new Guid(rdr.GetGuid(0).ToString()); infos.Add(inf); inf.MarkOld(); } } } } } return infos; }
/// <summary> /// Persists a new CurriculaInfo in the current provider. /// </summary> public static void InsertCurriculaInfo(CurriculaInfo info) { LoadProviders(); _provider.InsertCurriculaInfo(info); }
/// <summary> /// Returns a field /// </summary> /// <param name="id">Id of field to return</param> /// <returns></returns> public override CurriculaInfo SelectCurriculaInfo(Guid id) { List<CurriculaInfo> infos = CurriculaInfo.CurriculaInfos; CurriculaInfo info = new CurriculaInfo(); foreach (CurriculaInfo cat in infos) { if (cat.Id == id) info = cat; } info.MarkOld(); return info; }
/// <summary> /// Saves an existing field to the database /// </summary> /// <param name="category">field to be saved</param> public override void UpdateCurriculaInfo(CurriculaInfo info) { List<CurriculaInfo> infos = CurriculaInfo.CurriculaInfos; infos.Remove(info); infos.Add(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 + "CurriculaInfo " + "SET CurriculaID=@catid,StartDate=@startDate,EndDate=@enddate,Cast=@cast,CityTown=@citytown,IsPublished=@ispublished " + "WHERE InfoID = @infoID "; if (parmPrefix != "@") sqlQuery = sqlQuery.Replace("@", parmPrefix); cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; DbParameter dpID = provider.CreateParameter(); dpID.ParameterName = parmPrefix + "infoid"; dpID.Value = info.Id.ToString(); cmd.Parameters.Add(dpID); DbParameter dpcID = provider.CreateParameter(); dpcID.ParameterName = parmPrefix + "catid"; dpcID.Value = info.CurriculaId.ToString(); cmd.Parameters.Add(dpcID); DbParameter dpStartDate = provider.CreateParameter(); dpStartDate.ParameterName = parmPrefix + "startDate"; dpStartDate.Value = info.StartDate; cmd.Parameters.Add(dpStartDate); DbParameter dpEndDate = provider.CreateParameter(); dpEndDate.ParameterName = parmPrefix + "enddate"; dpEndDate.Value = info.EndDate; cmd.Parameters.Add(dpEndDate); DbParameter dpCast = provider.CreateParameter(); dpCast.ParameterName = parmPrefix + "cast"; dpCast.Value = info.Cast; cmd.Parameters.Add(dpCast); DbParameter dpCityTown = provider.CreateParameter(); dpCityTown.ParameterName = parmPrefix + "citytown"; dpCityTown.Value = info.CityTown; cmd.Parameters.Add(dpCityTown); DbParameter dpIsPublished = provider.CreateParameter(); dpIsPublished.ParameterName = parmPrefix + "ispublished"; dpIsPublished.Value = info.IsPublished; cmd.Parameters.Add(dpIsPublished); cmd.ExecuteNonQuery(); } } }
/// <summary> /// Deletes the specified CurriculaInfo from the current provider. /// </summary> public static void DeleteCurriculaInfo(CurriculaInfo info) { LoadProviders(); _provider.DeleteCurriculaInfo(info); }
/// <summary> /// Deletes a field from the database /// </summary> /// <param name="info">field to be removed</param> public override void DeleteCurriculaInfo(CurriculaInfo info) { List<CurriculaInfo> infos = CurriculaInfo.CurriculaInfos; infos.Remove(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 + "CurriculaInfo WHERE InfoID = " + parmPrefix + "catid"; cmd.CommandText = sqlQuery; cmd.CommandType = CommandType.Text; DbParameter dpID = provider.CreateParameter(); dpID.ParameterName = parmPrefix + "catid"; dpID.Value = info.Id.ToString(); cmd.Parameters.Add(dpID); cmd.ExecuteNonQuery(); } } }
/// <summary> /// Updates an existing CurriculaInfo in the data store specified by the provider. /// </summary> public abstract void UpdateCurriculaInfo(CurriculaInfo curriculaInfo);
/// <summary> /// Updates an exsiting CurriculaInfo. /// </summary> public static void UpdateCurriculaInfo(CurriculaInfo info) { LoadProviders(); _provider.UpdateCurriculaInfo(info); }
public string GetTitle(string p_ID) { return(CurriculaInfo.GetCurriculaInfo(new Guid(p_ID)).Curricula.Title); }
/// <summary> /// Deletes the specified CurriculaInfo from the current provider. /// </summary> public static void DeleteCurriculaInfo(CurriculaInfo info) { LoadProviders(); _provider.DeleteCurriculaInfo(info); }
/// <summary> /// Deletes a Category from the data store specified by the provider. /// </summary> public abstract void DeleteCurriculaInfo(CurriculaInfo curriculaInfo);
/// <summary> /// Deletes a Category from the data store specified by the provider. /// </summary> public abstract void DeleteCurriculaInfo(CurriculaInfo curriculaInfo);
/// <summary> /// Updates an existing CurriculaInfo in the data store specified by the provider. /// </summary> public abstract void UpdateCurriculaInfo(CurriculaInfo curriculaInfo);
/// <summary> /// Inserts a new CurriculaInfo into the data store specified by the provider. /// </summary> public abstract void InsertCurriculaInfo(CurriculaInfo curriculaInfo);
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { CurriculaInfo tc = e.Row.DataItem as CurriculaInfo; //绑定开课日期 Label lblStartDate = e.Row.Cells[1].FindControl("lblStartDate") as Label; string strYear = tc.StartDate.Year.ToString(); string strMonth = tc.StartDate.Month.ToString(); //string strYear = tc.CurriculaInfos[0].StartDate.Year.ToString(); //string strMonth = tc.CurriculaInfos[0].StartDate.Month.ToString(); if (strMonth.Length == 1) { strMonth = "0" + strMonth; } string strDay = tc.StartDate.Day.ToString(); if (strDay.Length == 1) { strDay = "0" + strDay; } lblStartDate.Text = strYear + "年" + strMonth + "月" + strDay + "日——"; strYear = tc.EndDate.Year.ToString(); strMonth = tc.EndDate.Month.ToString(); if (strMonth.Length == 1) { strMonth = "0" + strMonth; } strDay = tc.EndDate.Day.ToString(); if (strDay.Length == 1) { strDay = "0" + strDay; } lblStartDate.Text += strYear + "年" + strMonth + "月" + strDay + "日"; DateTime dtStart = tc.StartDate; DateTime dtEnd = tc.EndDate; int iTotalDays = dtEnd.Subtract(dtStart).Days + 1; Label lblTotalDays = e.Row.Cells[2].FindControl("lblTotalDays") as Label; lblTotalDays.Text = iTotalDays.ToString() + "天"; //绑定地点 Label lblCityTown = e.Row.Cells[3].FindControl("lblCityTown") as Label; lblCityTown.Text = tc.CityTown.ToString(); //绑定Cast Label lbc = e.Row.Cells[4].FindControl("lbCast") as Label; lbc.Text = "¥" + tc.Cast.ToString(); //绑定当前状态 Label lblState = e.Row.Cells[5].FindControl("lblState") as Label; if (DateTime.Now > dtStart) { lblState.Text = "已过期"; } else { lblState.Text = "报名中"; } //绑定积分 Label lblPoint = e.Row.Cells[6].FindControl("lblPoint") as Label; lblPoint.Text = tc.Curricula.Points.ToString() + "分"; //绑定培训币 Label lblScore = e.Row.Cells[7].FindControl("lblScore") as Label; lblScore.Text = tc.Curricula.Scores.ToString() + "币"; } }
/// <summary> /// Persists a new CurriculaInfo in the current provider. /// </summary> public static void InsertCurriculaInfo(CurriculaInfo info) { LoadProviders(); _provider.InsertCurriculaInfo(info); }
/// <summary> /// Inserts a new CurriculaInfo into the data store specified by the provider. /// </summary> public abstract void InsertCurriculaInfo(CurriculaInfo curriculaInfo);