Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.tTask model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tTask set ");
            strSql.Append("Title=@Title,");
            strSql.Append("TaskContent=@TaskContent,");
            strSql.Append("SaveTime=@SaveTime,");
            strSql.Append("LockTime=@LockTime,");
            strSql.Append("SavaPeo=@SavaPeo,");
            strSql.Append("IsCheck=@IsCheck,");
            strSql.Append("IsCheckPeo=@IsCheckPeo,");
            strSql.Append("IsCheckTime=@IsCheckTime,");
            strSql.Append("TaskLevel=@TaskLevel,");
            strSql.Append("LookDptString=@LookDptString,");
            strSql.Append("SaveDpt=@SaveDpt");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Title",         SqlDbType.NVarChar,   -1),
                new SqlParameter("@TaskContent",   SqlDbType.NVarChar,   -1),
                new SqlParameter("@SaveTime",      SqlDbType.DateTime),
                new SqlParameter("@LockTime",      SqlDbType.DateTime),
                new SqlParameter("@SavaPeo",       SqlDbType.NVarChar,   50),
                new SqlParameter("@IsCheck",       SqlDbType.VarChar,    50),
                new SqlParameter("@IsCheckPeo",    SqlDbType.NVarChar,   50),
                new SqlParameter("@IsCheckTime",   SqlDbType.DateTime),
                new SqlParameter("@TaskLevel",     SqlDbType.NVarChar,  150),
                new SqlParameter("@LookDptString", SqlDbType.NVarChar,   -1),
                new SqlParameter("@SaveDpt",       SqlDbType.Int,         4),
                new SqlParameter("@Id",            SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.Title;
            parameters[1].Value  = model.TaskContent;
            parameters[2].Value  = model.SaveTime;
            parameters[3].Value  = model.LockTime;
            parameters[4].Value  = model.SavaPeo;
            parameters[5].Value  = model.IsCheck;
            parameters[6].Value  = model.IsCheckPeo;
            parameters[7].Value  = model.IsCheckTime;
            parameters[8].Value  = model.TaskLevel;
            parameters[9].Value  = model.LookDptString;
            parameters[10].Value = model.SaveDpt;
            parameters[11].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.tTask DataRowToModel(DataRow row)
 {
     Maticsoft.Model.tTask model = new Maticsoft.Model.tTask();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Title"] != null)
         {
             model.Title = row["Title"].ToString();
         }
         if (row["TaskContent"] != null)
         {
             model.TaskContent = row["TaskContent"].ToString();
         }
         if (row["SaveTime"] != null && row["SaveTime"].ToString() != "")
         {
             model.SaveTime = DateTime.Parse(row["SaveTime"].ToString());
         }
         if (row["LockTime"] != null && row["LockTime"].ToString() != "")
         {
             model.LockTime = DateTime.Parse(row["LockTime"].ToString());
         }
         if (row["SavaPeo"] != null)
         {
             model.SavaPeo = row["SavaPeo"].ToString();
         }
         if (row["IsCheck"] != null)
         {
             model.IsCheck = row["IsCheck"].ToString();
         }
         if (row["IsCheckPeo"] != null)
         {
             model.IsCheckPeo = row["IsCheckPeo"].ToString();
         }
         if (row["IsCheckTime"] != null && row["IsCheckTime"].ToString() != "")
         {
             model.IsCheckTime = DateTime.Parse(row["IsCheckTime"].ToString());
         }
         if (row["TaskLevel"] != null)
         {
             model.TaskLevel = row["TaskLevel"].ToString();
         }
         if (row["LookDptString"] != null)
         {
             model.LookDptString = row["LookDptString"].ToString();
         }
         if (row["SaveDpt"] != null && row["SaveDpt"].ToString() != "")
         {
             model.SaveDpt = int.Parse(row["SaveDpt"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.tTask model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tTask(");
            strSql.Append("Title,TaskContent,SaveTime,LockTime,SavaPeo,IsCheck,IsCheckPeo,IsCheckTime,TaskLevel,LookDptString,SaveDpt)");
            strSql.Append(" values (");
            strSql.Append("@Title,@TaskContent,@SaveTime,@LockTime,@SavaPeo,@IsCheck,@IsCheckPeo,@IsCheckTime,@TaskLevel,@LookDptString,@SaveDpt)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Title",         SqlDbType.NVarChar,   -1),
                new SqlParameter("@TaskContent",   SqlDbType.NVarChar,   -1),
                new SqlParameter("@SaveTime",      SqlDbType.DateTime),
                new SqlParameter("@LockTime",      SqlDbType.DateTime),
                new SqlParameter("@SavaPeo",       SqlDbType.NVarChar,   50),
                new SqlParameter("@IsCheck",       SqlDbType.VarChar,    50),
                new SqlParameter("@IsCheckPeo",    SqlDbType.NVarChar,   50),
                new SqlParameter("@IsCheckTime",   SqlDbType.DateTime),
                new SqlParameter("@TaskLevel",     SqlDbType.NVarChar,  150),
                new SqlParameter("@LookDptString", SqlDbType.NVarChar,   -1),
                new SqlParameter("@SaveDpt",       SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.Title;
            parameters[1].Value  = model.TaskContent;
            parameters[2].Value  = model.SaveTime;
            parameters[3].Value  = model.LockTime;
            parameters[4].Value  = model.SavaPeo;
            parameters[5].Value  = model.IsCheck;
            parameters[6].Value  = model.IsCheckPeo;
            parameters[7].Value  = model.IsCheckTime;
            parameters[8].Value  = model.TaskLevel;
            parameters[9].Value  = model.LookDptString;
            parameters[10].Value = model.SaveDpt;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.tTask GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Title,TaskContent,SaveTime,LockTime,SavaPeo,IsCheck,IsCheckPeo,IsCheckTime,TaskLevel,LookDptString,SaveDpt from tTask ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            Maticsoft.Model.tTask model = new Maticsoft.Model.tTask();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }