Exemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.mail_template GetModel(string call_index)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            Model.mail_template model = new Model.mail_template();
            //利用反射获得属性的所有公共属性
            PropertyInfo[] pros = model.GetType().GetProperties();
            foreach (PropertyInfo p in pros)
            {
                str1.Append(p.Name + ",");//拼接字段
            }
            strSql.Append("select top 1 " + str1.ToString().Trim(','));
            strSql.Append(" from " + databaseprefix + "mail_template");
            strSql.Append(" where call_index=@call_index");
            SqlParameter[] parameters =
            {
                new SqlParameter("@call_index", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = call_index;
            DataTable dt = DbHelperSQL.Query(strSql.ToString(), parameters).Tables[0];

            if (dt.Rows.Count > 0)
            {
                return(DataRowToModel(dt.Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.mail_template DataRowToModel(DataRow row)
 {
     Model.mail_template model = new Model.mail_template();
     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["call_index"] != null)
         {
             model.call_index = row["call_index"].ToString();
         }
         if (row["maill_title"] != null)
         {
             model.maill_title = row["maill_title"].ToString();
         }
         if (row["content"] != null)
         {
             model.content = row["content"].ToString();
         }
         if (row["is_sys"] != null && row["is_sys"].ToString() != "")
         {
             model.is_sys = int.Parse(row["is_sys"].ToString());
         }
     }
     return model;
 }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.mail_template model)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            //利用反射获得属性的所有公共属性
            PropertyInfo[]      pros  = model.GetType().GetProperties();
            List <SqlParameter> paras = new List <SqlParameter>();

            strSql.Append("update " + databaseprefix + "mail_template set ");
            foreach (PropertyInfo pi in pros)
            {
                //如果不是主键则追加sql字符串
                if (!pi.Name.Equals("id"))
                {
                    //判断属性值是否为空
                    if (pi.GetValue(model, null) != null)
                    {
                        str1.Append(pi.Name + "=@" + pi.Name + ",");                          //声明参数
                        paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值
                    }
                }
            }
            strSql.Append(str1.ToString().Trim(','));
            strSql.Append(" where id=@id ");
            paras.Add(new SqlParameter("@id", model.id));
            return(DbHelperSQL.ExecuteSql(strSql.ToString(), paras.ToArray()) > 0);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.mail_template DataRowToModel(DataRow row)
 {
     Model.mail_template model = new Model.mail_template();
     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["call_index"] != null)
         {
             model.call_index = row["call_index"].ToString();
         }
         if (row["maill_title"] != null)
         {
             model.maill_title = row["maill_title"].ToString();
         }
         if (row["content"] != null)
         {
             model.content = row["content"].ToString();
         }
         if (row["is_sys"] != null && row["is_sys"].ToString() != "")
         {
             model.is_sys = int.Parse(row["is_sys"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.mail_template model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "mail_template(");
            strSql.Append("title,call_index,maill_title,content)");
            strSql.Append(" values (");
            strSql.Append("@title,@call_index,@maill_title,@content)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@title",       SqlDbType.NVarChar, 100),
                new SqlParameter("@call_index",  SqlDbType.NVarChar,  50),
                new SqlParameter("@maill_title", SqlDbType.NVarChar, 100),
                new SqlParameter("@content",     SqlDbType.NText)
            };
            parameters[0].Value = model.title;
            parameters[1].Value = model.call_index;
            parameters[2].Value = model.maill_title;
            parameters[3].Value = model.content;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.mail_template model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + databaseprefix + "mail_template set ");
            strSql.Append("title=@title,");
            strSql.Append("call_index=@call_index,");
            strSql.Append("maill_title=@maill_title,");
            strSql.Append("content=@content");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@title",       SqlDbType.NVarChar, 100),
                new SqlParameter("@call_index",  SqlDbType.NVarChar,  50),
                new SqlParameter("@maill_title", SqlDbType.NVarChar, 100),
                new SqlParameter("@content",     SqlDbType.NText),
                new SqlParameter("@id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.title;
            parameters[1].Value = model.call_index;
            parameters[2].Value = model.maill_title;
            parameters[3].Value = model.content;
            parameters[4].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void ShowInfo(int _id)
        {
            BLL.mail_template   bll   = new BLL.mail_template();
            Model.mail_template model = bll.GetModel(_id);

            txtTitle.Text     = model.title;
            txtCallIndex.Text = model.call_index;
            txtMailTitle.Text = model.maill_title;
            txtContent.Value  = model.content;
        }
Exemplo n.º 8
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.mail_template GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,title,call_index,maill_title,content,is_sys from " + databaseprefix + "mail_template ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["call_index"] != null && ds.Tables[0].Rows[0]["call_index"].ToString() != "")
                {
                    model.call_index = ds.Tables[0].Rows[0]["call_index"].ToString();
                }
                if (ds.Tables[0].Rows[0]["maill_title"] != null && ds.Tables[0].Rows[0]["maill_title"].ToString() != "")
                {
                    model.maill_title = ds.Tables[0].Rows[0]["maill_title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "")
                {
                    model.content = ds.Tables[0].Rows[0]["content"].ToString();
                }
                if (ds.Tables[0].Rows[0]["is_sys"] != null && ds.Tables[0].Rows[0]["is_sys"].ToString() != "")
                {
                    model.is_sys = int.Parse(ds.Tables[0].Rows[0]["is_sys"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
        private bool DoAdd()
        {
            bool result = true;
            Model.mail_template model = new Model.mail_template();
            BLL.mail_template bll = new BLL.mail_template();

            model.call_index = txtCallIndex.Text.Trim();
            model.title = txtTitle.Text.Trim();
            model.maill_title = txtMailTitle.Text.Trim();
            model.content = txtContent.Value;
            if (bll.Add(model) < 1)
            {
                result = false;
            }
            return result;
        }
Exemplo n.º 10
0
        private bool DoEdit(int _id)
        {
            bool result = true;

            BLL.mail_template   bll   = new BLL.mail_template();
            Model.mail_template model = bll.GetModel(_id);

            model.call_index  = txtCallIndex.Text.Trim();
            model.title       = txtTitle.Text.Trim();
            model.maill_title = txtMailTitle.Text.Trim();
            model.content     = txtContent.Value;
            if (!bll.Update(model))
            {
                result = false;
            }
            return(result);
        }
Exemplo n.º 11
0
        private bool DoAdd()
        {
            Model.mail_template model = new Model.mail_template();
            BLL.mail_template   bll   = new BLL.mail_template();

            model.title       = txtTitle.Text.Trim();
            model.call_index  = txtCallIndex.Text.Trim();
            model.maill_title = txtMailTitle.Text.Trim();
            model.content     = txtContent.Value;

            if (bll.Add(model) > 0)
            {
                AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加邮件模板:" + model.title); //记录日志
                return(true);
            }
            return(false);
        }
Exemplo n.º 12
0
        private bool DoAdd()
        {
            Model.mail_template model = new Model.mail_template();
            BLL.mail_template bll = new BLL.mail_template();

            model.title = txtTitle.Text.Trim();
            model.call_index = txtCallIndex.Text.Trim();
            model.maill_title = txtMailTitle.Text.Trim();
            model.content = txtContent.Value;

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加邮件模板:" + model.title); //记录日志
                return true;
            }
            return false;
        }
Exemplo n.º 13
0
        private bool DoAdd()
        {
            bool result = true;

            Model.mail_template model = new Model.mail_template();
            BLL.mail_template   bll   = new BLL.mail_template();

            model.call_index  = txtCallIndex.Text.Trim();
            model.title       = txtTitle.Text.Trim();
            model.maill_title = txtMailTitle.Text.Trim();
            model.content     = txtContent.Value;
            if (bll.Add(model) < 1)
            {
                result = false;
            }
            return(result);
        }
Exemplo n.º 14
0
 /// <summary>
 /// 将对象转换实体
 /// </summary>
 public Model.mail_template DataRowToModel(DataRow row)
 {
     Model.mail_template model = new Model.mail_template();
     if (row != null)
     {
         //利用反射获得属性的所有公共属性
         Type modelType = model.GetType();
         for (int i = 0; i < row.Table.Columns.Count; i++)
         {
             //查找实体是否存在列表相同的公共属性
             PropertyInfo proInfo = modelType.GetProperty(row.Table.Columns[i].ColumnName);
             if (proInfo != null && row[i] != DBNull.Value)
             {
                 proInfo.SetValue(model, row[i], null);//用索引值设置属性值
             }
         }
     }
     return(model);
 }
Exemplo n.º 15
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.mail_template   bll   = new BLL.mail_template();
            Model.mail_template model = bll.GetModel(_id);

            model.title       = txtTitle.Text.Trim();
            model.call_index  = txtCallIndex.Text.Trim();
            model.maill_title = txtMailTitle.Text.Trim();
            model.content     = txtContent.Value;

            if (bll.Update(model))
            {
                AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改邮件模板:" + model.title); //记录日志
                result = true;
            }

            return(result);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.mail_template model)
        {
            int newId;

            using (OleDbConnection conn = new OleDbConnection(DbHelperOleDb.connectionString))
            {
                conn.Open();
                using (OleDbTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into " + databaseprefix + "mail_template(");
                        strSql.Append("title,call_index,maill_title,content)");
                        strSql.Append(" values (");
                        strSql.Append("@title,@call_index,@maill_title,@content)");
                        OleDbParameter[] parameters =
                        {
                            new OleDbParameter("@title",       OleDbType.VarChar, 100),
                            new OleDbParameter("@call_index",  OleDbType.VarChar,  50),
                            new OleDbParameter("@maill_title", OleDbType.VarChar, 100),
                            new OleDbParameter("@content",     OleDbType.VarChar)
                        };
                        parameters[0].Value = model.title;
                        parameters[1].Value = model.call_index;
                        parameters[2].Value = model.maill_title;
                        parameters[3].Value = model.content;
                        DbHelperOleDb.ExecuteSql(conn, trans, strSql.ToString(), parameters);
                        //取得新插入的ID
                        newId = GetMaxId(conn, trans);
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(-1);
                    }
                }
            }
            return(newId);
        }
Exemplo n.º 17
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.mail_template model)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder(); //数据字段
            StringBuilder str2   = new StringBuilder(); //数据参数

            //利用反射获得属性的所有公共属性
            PropertyInfo[]      pros  = model.GetType().GetProperties();
            List <SqlParameter> paras = new List <SqlParameter>();

            strSql.Append("insert into " + databaseprefix + "mail_template(");
            foreach (PropertyInfo pi in pros)
            {
                //如果不是主键则追加sql字符串
                if (!pi.Name.Equals("id"))
                {
                    //判断属性值是否为空
                    if (pi.GetValue(model, null) != null)
                    {
                        str1.Append(pi.Name + ",");                                           //拼接字段
                        str2.Append("@" + pi.Name + ",");                                     //声明参数
                        paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值
                    }
                }
            }
            strSql.Append(str1.ToString().Trim(','));
            strSql.Append(") values (");
            strSql.Append(str2.ToString().Trim(','));
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY;");
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), paras.ToArray());

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.mail_template GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,title,call_index,maill_title,content,is_sys from dt_mail_template ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Model.mail_template model = new Model.mail_template();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["call_index"] != null && ds.Tables[0].Rows[0]["call_index"].ToString() != "")
                {
                    model.call_index = ds.Tables[0].Rows[0]["call_index"].ToString();
                }
                if (ds.Tables[0].Rows[0]["maill_title"] != null && ds.Tables[0].Rows[0]["maill_title"].ToString() != "")
                {
                    model.maill_title = ds.Tables[0].Rows[0]["maill_title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "")
                {
                    model.content = ds.Tables[0].Rows[0]["content"].ToString();
                }
                if (ds.Tables[0].Rows[0]["is_sys"] != null && ds.Tables[0].Rows[0]["is_sys"].ToString() != "")
                {
                    model.is_sys = int.Parse(ds.Tables[0].Rows[0]["is_sys"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.mail_template model)
 {
     return(dal.Add(model));
 }
Exemplo n.º 20
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.mail_template model)
 {
     return(dal.Update(model));
 }