Example #1
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            entity_ScheduleMain model = null;

            if (type == "add")
            {
                model             = new entity_ScheduleMain();
                model.SID         = Guid.NewGuid().ToString();
                model.Name        = this.tbx_Name.Text;
                model.CreaterTime = DateTime.Now;
                if (bll.Add(model))
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('添加成功!');</script>");
                    Response.Redirect("ScheduleList.aspx?mm=" + new Random().Next(), true);
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('添加失败!');</script>");
                }
            }
            if (type == "update")
            {
                model      = bll.GetModel(ViewState["SID"].ToString());
                model.Name = this.tbx_Name.Text;
                if (bll.Update(model))
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('修改成功!');</script>");
                    Response.Redirect("ScheduleList.aspx?mm=" + new Random().Next(), true);
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('修改失败!');</script>");
                }
            }
        }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(entity_ScheduleMain model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_ScheduleMain set ");
            strSql.Append("Name=@Name");
            strSql.Append(" where SID=@SID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name", SqlDbType.NVarChar, 500),
                new SqlParameter("@SID",  SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.SID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(entity_ScheduleMain model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_ScheduleMain(");
            strSql.Append("SID,Name,CreaterTime)");
            strSql.Append(" values (");
            strSql.Append("@SID,@Name,@CreaterTime)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SID",         SqlDbType.NVarChar,  50),
                new SqlParameter("@Name",        SqlDbType.NVarChar, 500),
                new SqlParameter("@CreaterTime", SqlDbType.DateTime)
            };
            parameters[0].Value = model.SID;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.CreaterTime;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public entity_ScheduleMain DataRowToModel(DataRow row)
        {
            entity_ScheduleMain model = new entity_ScheduleMain();

            if (row != null)
            {
                if (row["SID"] != null)
                {
                    model.SID = row["SID"].ToString();
                }
                if (row["Name"] != null)
                {
                    model.Name = row["Name"].ToString();
                }
                if (row["CreaterTime"] != null)
                {
                    model.CreaterTime = DateTime.Parse(row["CreaterTime"].ToString());
                }
            }
            return(model);
        }
Example #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public entity_ScheduleMain GetModel(string SID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 SID,Name,CreaterTime from T_ScheduleMain ");
            strSql.Append(" where SID=@SID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SID", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = SID;

            entity_ScheduleMain model = new entity_ScheduleMain();
            DataSet             ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(entity_ScheduleMain model)
 {
     return(dal.Update(model));
 }
Example #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(entity_ScheduleMain model)
 {
     return(dal.Add(model));
 }