Exemple #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(LPWeb.Model.Template_Wfl_CompletionEmails model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Template_Wfl_CompletionEmails(");
            strSql.Append("TemplTaskid,TemplEmailId,Enabled)");
            strSql.Append(" values (");
            strSql.Append("@TemplTaskid,@TemplEmailId,@Enabled)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TemplTaskid",  SqlDbType.Int, 4),
                new SqlParameter("@TemplEmailId", SqlDbType.Int, 4),
                new SqlParameter("@Enabled",      SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.TemplTaskid;
            parameters[1].Value = model.TemplEmailId;
            parameters[2].Value = model.Enabled;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LPWeb.Model.Template_Wfl_CompletionEmails model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Template_Wfl_CompletionEmails set ");
            strSql.Append("TemplTaskid=@TemplTaskid,");
            strSql.Append("TemplEmailId=@TemplEmailId,");
            strSql.Append("Enabled=@Enabled");
            strSql.Append(" where CompletionEmailId=@CompletionEmailId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TemplTaskid",       SqlDbType.Int, 4),
                new SqlParameter("@TemplEmailId",      SqlDbType.Int, 4),
                new SqlParameter("@Enabled",           SqlDbType.Bit, 1),
                new SqlParameter("@CompletionEmailId", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.TemplTaskid;
            parameters[1].Value = model.TemplEmailId;
            parameters[2].Value = model.Enabled;
            parameters[3].Value = model.CompletionEmailId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LPWeb.Model.Template_Wfl_CompletionEmails GetModel(int CompletionEmailId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 CompletionEmailId,TemplTaskid,TemplEmailId,Enabled from Template_Wfl_CompletionEmails ");
            strSql.Append(" where CompletionEmailId=@CompletionEmailId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CompletionEmailId", SqlDbType.Int, 4)
            };
            parameters[0].Value = CompletionEmailId;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["CompletionEmailId"] != null && ds.Tables[0].Rows[0]["CompletionEmailId"].ToString() != "")
                {
                    model.CompletionEmailId = int.Parse(ds.Tables[0].Rows[0]["CompletionEmailId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TemplTaskid"] != null && ds.Tables[0].Rows[0]["TemplTaskid"].ToString() != "")
                {
                    model.TemplTaskid = int.Parse(ds.Tables[0].Rows[0]["TemplTaskid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TemplEmailId"] != null && ds.Tables[0].Rows[0]["TemplEmailId"].ToString() != "")
                {
                    model.TemplEmailId = int.Parse(ds.Tables[0].Rows[0]["TemplEmailId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Enabled"] != null && ds.Tables[0].Rows[0]["Enabled"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Enabled"].ToString() == "1") || (ds.Tables[0].Rows[0]["Enabled"].ToString().ToLower() == "true"))
                    {
                        model.Enabled = true;
                    }
                    else
                    {
                        model.Enabled = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }