Example #1
0
        protected void buttonOK_Click(object sender, EventArgs e)
        {
            DateTime startTime = DateTime.MinValue;
            DateTime endTime = DateTime.MinValue;

            if (CheckInput(ref startTime, ref endTime))
            {
                try
                {
                    var bulletin = new saBulletinInfo();
                    bulletin.sTitle = this.txtTitle.Text.Trim();
                    bulletin.sContent = this.txtContent.Text.Trim();
                    bulletin.tStartTime = startTime;
                    bulletin.tEndTime = endTime;
                    bulletin.iBulletinLevel = int.Parse(ddlBulletinLevel.SelectedValue);
                    bulletin.iBulletinType = int.Parse(ddlBulletinType.SelectedValue);


                    if (this.IsModifyAction)
                    {
                        int id;
                        int.TryParse(Request["iBulletinId"], out id);
                        bulletin.iIden = id;
                        bulletin.bUsable = true;
                        bulletin.tUpdateTime = DbServer.Current.ServerDateTime;
                        saBulletin.Current.UpdateBulletin(bulletin);

                        Response.Clear();
                        ClientScript.RegisterStartupScript(this.GetType(), string.Empty,
                            "<script type=\"text/javascript\">alert('{0}');location.href='BulletinManage.aspx';</script>".FormatEx(Resources.GlobalResources.ModifiedSuccess));
                    }
                    else
                    {
                        bulletin.iIden = IdenGenerator.Current.NewIden(saBulletinInfo.sTableName);
                        bulletin.iCreator = iUserID;
                        bulletin.bUsable = true;
                        bulletin.tCreateTime = DbServer.Current.ServerDateTime;
                        bulletin.tUpdateTime = bulletin.tCreateTime;
                        saBulletin.Current.CreateBulletin(bulletin);

                        Response.Clear();
                        ClientScript.RegisterStartupScript(this.GetType(), string.Empty,
                            "<script type=\"text/javascript\">alert('{0}');location.href='BulletinManage.aspx';</script>".FormatEx(Resources.GlobalResources.AddedSuccess));
                    }
                }
                catch (Exception ex)
                {
                    hasError = true;
                    errorMsg = ex.Message;
                }
            }
            else
            {
                hasError = true;
            }
        }
Example #2
0
 public void UpdateBulletin(saBulletinInfo bulletin)
 {
     dal.Update(bulletin);
 }
Example #3
0
 public void CreateBulletin(saBulletinInfo bulletin)
 {
     dal.Create(bulletin);
 }
Example #4
0
 public void Create(saBulletinInfo model)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append(" insert into saBulletin(");
     strSql.Append(" iIden,sTitle,sContent,tStartTime,tEndTime,iBulletinType,iBulletinLevel,tCreateTime,iCreator,tUpdateTime,bUsable)");
     strSql.Append(" values (");
     strSql.Append(" @iIden,@sTitle,@sContent,@tStartTime,@tEndTime,@iBulletinType,@iBulletinLevel,@tCreateTime,@iCreator,@tUpdateTime,@bUsable)");
     Database db = DatabaseFactory.CreateDatabase();
     DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
     db.AddInParameter(dbCommand, "iIden", DbType.Int32, model.iIden);
     db.AddInParameter(dbCommand, "sTitle", DbType.String, model.sTitle);
     db.AddInParameter(dbCommand, "sContent", DbType.String, model.sContent);
     db.AddInParameter(dbCommand, "tStartTime", DbType.DateTime, model.tStartTime);
     db.AddInParameter(dbCommand, "tEndTime", DbType.DateTime, model.tEndTime);
     db.AddInParameter(dbCommand, "iBulletinType", DbType.Int32, model.iBulletinType);
     db.AddInParameter(dbCommand, "iBulletinLevel", DbType.Int32, model.iBulletinLevel);
     db.AddInParameter(dbCommand, "tCreateTime", DbType.DateTime, model.tCreateTime);
     db.AddInParameter(dbCommand, "iCreator", DbType.Int32, model.iCreator);
     db.AddInParameter(dbCommand, "tUpdateTime", DbType.DateTime, model.tUpdateTime);
     db.AddInParameter(dbCommand, "bUsable", DbType.Boolean, model.bUsable);
     db.ExecuteScalar(dbCommand);
 }
Example #5
0
 /// <summary>
 /// 对象实体绑定数据
 /// </summary>
 public static saBulletinInfo ReaderBind(IDataReader dataReader)
 {
     if (dataReader == null)
         return null;
     saBulletinInfo model = new saBulletinInfo();
     object ojb;
     ojb = dataReader["iIden"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.iIden = (int)ojb;
     }
     model.sTitle = dataReader["sTitle"].ToString();
     model.sContent = dataReader["sContent"].ToString();
     ojb = dataReader["tStartTime"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.tStartTime = (DateTime)ojb;
     }
     ojb = dataReader["tEndTime"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.tEndTime = (DateTime)ojb;
     }
     ojb = dataReader["iBulletinType"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.iBulletinType = (int)ojb;
     }
     ojb = dataReader["iBulletinLevel"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.iBulletinLevel = (int)ojb;
     }
     ojb = dataReader["tCreateTime"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.tCreateTime = (DateTime)ojb;
     }
     ojb = dataReader["iCreator"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.iCreator = (int)ojb;
     }
     ojb = dataReader["tUpdateTime"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.tUpdateTime = (DateTime)ojb;
     }
     ojb = dataReader["bUsable"];
     if (ojb != null && ojb != DBNull.Value)
     {
         model.bUsable = (bool)ojb;
     }
     return model;
 }
Example #6
0
 public void Update(saBulletinInfo model)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append(" update saBulletin set ");
     strSql.Append(" sTitle=@sTitle,");
     strSql.Append(" sContent=@sContent,");
     strSql.Append(" tStartTime=@tStartTime,");
     strSql.Append(" tEndTime=@tEndTime,");
     strSql.Append(" iBulletinType=@iBulletinType,");
     strSql.Append(" iBulletinLevel=@iBulletinLevel,");
     strSql.Append(" tUpdateTime=@tUpdateTime");
     strSql.Append(" where iIden=@iIden");
     Database db = DatabaseFactory.CreateDatabase();
     DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
     db.AddInParameter(dbCommand, "iIden", DbType.Int32, model.iIden);
     db.AddInParameter(dbCommand, "sTitle", DbType.String, model.sTitle);
     db.AddInParameter(dbCommand, "sContent", DbType.String, model.sContent);
     db.AddInParameter(dbCommand, "tStartTime", DbType.DateTime, model.tStartTime);
     db.AddInParameter(dbCommand, "tEndTime", DbType.DateTime, model.tEndTime);
     db.AddInParameter(dbCommand, "iBulletinType", DbType.Int32, model.iBulletinType);
     db.AddInParameter(dbCommand, "iBulletinLevel", DbType.Int32, model.iBulletinLevel);
     db.AddInParameter(dbCommand, "tUpdateTime", DbType.DateTime, model.tUpdateTime);
     db.ExecuteNonQuery(dbCommand);
 }