예제 #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public QAMZN.Model.tb_user_contacts DataRowToModel(DataRow row)
 {
     QAMZN.Model.tb_user_contacts model = new QAMZN.Model.tb_user_contacts();
     if (row != null)
     {
         if (row["contact_id"] != null && row["contact_id"].ToString() != "")
         {
             model.contact_id = int.Parse(row["contact_id"].ToString());
         }
         if (row["name"] != null)
         {
             model.name = row["name"].ToString();
         }
         if (row["email"] != null)
         {
             model.email = row["email"].ToString();
         }
         if (row["phone"] != null)
         {
             model.phone = row["phone"].ToString();
         }
         if (row["sms_mode"] != null && row["sms_mode"].ToString() != "")
         {
             model.sms_mode = int.Parse(row["sms_mode"].ToString());
         }
         if (row["start_hour"] != null && row["start_hour"].ToString() != "")
         {
             model.start_hour = DateTime.Parse(row["start_hour"].ToString());
         }
         if (row["end_hour"] != null && row["end_hour"].ToString() != "")
         {
             model.end_hour = DateTime.Parse(row["end_hour"].ToString());
         }
         if (row["timezone"] != null)
         {
             model.timezone = row["timezone"].ToString();
         }
         if (row["user_id"] != null && row["user_id"].ToString() != "")
         {
             model.user_id = int.Parse(row["user_id"].ToString());
         }
         if (row["createtime"] != null && row["createtime"].ToString() != "")
         {
             model.createtime = DateTime.Parse(row["createtime"].ToString());
         }
     }
     return(model);
 }
예제 #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <QAMZN.Model.tb_user_contacts> DataTableToList(DataTable dt)
        {
            List <QAMZN.Model.tb_user_contacts> modelList = new List <QAMZN.Model.tb_user_contacts>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                QAMZN.Model.tb_user_contacts model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return(modelList);
        }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(QAMZN.Model.tb_user_contacts model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_user_contacts set ");
            strSql.Append("name=@name,");
            strSql.Append("email=@email,");
            strSql.Append("phone=@phone,");
            strSql.Append("sms_mode=@sms_mode,");
            strSql.Append("start_hour=@start_hour,");
            strSql.Append("end_hour=@end_hour,");
            strSql.Append("timezone=@timezone");
            strSql.Append(" where contact_id=@contact_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name",       SqlDbType.VarChar,    50),
                new SqlParameter("@email",      SqlDbType.VarChar,   200),
                new SqlParameter("@phone",      SqlDbType.VarChar,    50),
                new SqlParameter("@sms_mode",   SqlDbType.Int,         4),
                new SqlParameter("@start_hour", SqlDbType.DateTime),
                new SqlParameter("@end_hour",   SqlDbType.DateTime),
                new SqlParameter("@timezone",   SqlDbType.VarChar,    50),
                new SqlParameter("@contact_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.email;
            parameters[2].Value = model.phone;
            parameters[3].Value = model.sms_mode;
            parameters[4].Value = model.start_hour;
            parameters[5].Value = model.end_hour;
            parameters[6].Value = model.timezone;
            parameters[7].Value = model.contact_id;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(QAMZN.Model.tb_user_contacts model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_user_contacts(");
            strSql.Append("name,email,phone,sms_mode,start_hour,end_hour,timezone,user_id,createtime)");
            strSql.Append(" values (");
            strSql.Append("@name,@email,@phone,@sms_mode,@start_hour,@end_hour,@timezone,@user_id,@createtime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name",       SqlDbType.VarChar,    50),
                new SqlParameter("@email",      SqlDbType.VarChar,   200),
                new SqlParameter("@phone",      SqlDbType.VarChar,    50),
                new SqlParameter("@sms_mode",   SqlDbType.Int,         4),
                new SqlParameter("@start_hour", SqlDbType.DateTime),
                new SqlParameter("@end_hour",   SqlDbType.DateTime),
                new SqlParameter("@timezone",   SqlDbType.VarChar,    50),
                new SqlParameter("@user_id",    SqlDbType.Int,         4),
                new SqlParameter("@createtime", SqlDbType.DateTime)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.email;
            parameters[2].Value = model.phone;
            parameters[3].Value = model.sms_mode;
            parameters[4].Value = model.start_hour;
            parameters[5].Value = model.end_hour;
            parameters[6].Value = model.timezone;
            parameters[7].Value = model.user_id;
            parameters[8].Value = model.createtime;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #5
0
 /// <summary>
 /// 获取联系人信息详情
 /// </summary>
 /// <param name="userid">用户编号</param>
 public string GetContactsInfo(int contact_id)
 {
     model = dal.GetModel(contact_id);
     if (model != null)
     {
         return("\"contact_id\":\"" + model.contact_id
                + "\",\"name\":\"" + QGYHelper.FormatCode.FormatUrlEncode(model.name)
                + "\",\"email\":\"" + QGYHelper.FormatCode.FormatUrlEncode(model.email)
                + "\",\"phone\":\"" + model.phone
                + "\",\"sms_mode\":\"" + model.sms_mode
                + "\",\"start_hour\":\"" + model.start_hour
                + "\",\"end_hour\":\"" + model.end_hour
                + "\",\"timezone\":\"" + QGYHelper.FormatCode.FormatUrlEncode(model.timezone)
                + "\"");
     }
     else
     {
         return("");
     }
 }
예제 #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public QAMZN.Model.tb_user_contacts GetModel(int contact_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 contact_id,name,email,phone,sms_mode,start_hour,end_hour,timezone,user_id,createtime from tb_user_contacts ");
            strSql.Append(" where contact_id=@contact_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@contact_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = contact_id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(QAMZN.Model.tb_user_contacts model)
 {
     return(dal.Add(model));
 }
예제 #8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool UpdateContacts(QAMZN.Model.tb_user_contacts model)
 {
     return(dal.Update(model));
 }