Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WebApi.Model.CustomerProperty model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_CustomerProperty(");
            strSql.Append("CustomerSysNo,PropertySysNo,PropertyValue,Status,CreateTime,EditTime)");
            strSql.Append(" values (");
            strSql.Append("@CustomerSysNo,@PropertySysNo,@PropertyValue,@Status,@CreateTime,@EditTime)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@CustomerSysNo", MySqlDbType.Int32,      11),
                new MySqlParameter("@PropertySysNo", MySqlDbType.Int32,      11),
                new MySqlParameter("@PropertyValue", MySqlDbType.VarChar,   500),
                new MySqlParameter("@Status",        MySqlDbType.Int32,      11),
                new MySqlParameter("@CreateTime",    MySqlDbType.DateTime),
                new MySqlParameter("@EditTime",      MySqlDbType.DateTime)
            };
            parameters[0].Value = model.CustomerSysNo;
            parameters[1].Value = model.PropertySysNo;
            parameters[2].Value = model.PropertyValue;
            parameters[3].Value = model.Status;
            parameters[4].Value = model.CreateTime;
            parameters[5].Value = model.EditTime;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebApi.Model.CustomerProperty model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_CustomerProperty set ");
            strSql.Append("CustomerSysNo=@CustomerSysNo,");
            strSql.Append("PropertySysNo=@PropertySysNo,");
            strSql.Append("PropertyValue=@PropertyValue,");
            strSql.Append("Status=@Status,");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("EditTime=@EditTime");
            strSql.Append(" where SysNo=@SysNo");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@CustomerSysNo", MySqlDbType.Int32,      11),
                new MySqlParameter("@PropertySysNo", MySqlDbType.Int32,      11),
                new MySqlParameter("@PropertyValue", MySqlDbType.VarChar,   500),
                new MySqlParameter("@Status",        MySqlDbType.Int32,      11),
                new MySqlParameter("@CreateTime",    MySqlDbType.DateTime),
                new MySqlParameter("@EditTime",      MySqlDbType.DateTime),
                new MySqlParameter("@SysNo",         MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.CustomerSysNo;
            parameters[1].Value = model.PropertySysNo;
            parameters[2].Value = model.PropertyValue;
            parameters[3].Value = model.Status;
            parameters[4].Value = model.CreateTime;
            parameters[5].Value = model.EditTime;
            parameters[6].Value = model.SysNo;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebApi.Model.CustomerProperty DataRowToModel(DataRow row)
 {
     WebApi.Model.CustomerProperty model = new WebApi.Model.CustomerProperty();
     if (row != null)
     {
         if (row["SysNo"] != null && row["SysNo"].ToString() != "")
         {
             model.SysNo = int.Parse(row["SysNo"].ToString());
         }
         if (row["CustomerSysNo"] != null && row["CustomerSysNo"].ToString() != "")
         {
             model.CustomerSysNo = int.Parse(row["CustomerSysNo"].ToString());
         }
         if (row["PropertySysNo"] != null && row["PropertySysNo"].ToString() != "")
         {
             model.PropertySysNo = int.Parse(row["PropertySysNo"].ToString());
         }
         if (row["PropertyValue"] != null)
         {
             model.PropertyValue = row["PropertyValue"].ToString();
         }
         if (row["Status"] != null && row["Status"].ToString() != "")
         {
             model.Status = int.Parse(row["Status"].ToString());
         }
         if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
         {
             model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
         }
         if (row["EditTime"] != null && row["EditTime"].ToString() != "")
         {
             model.EditTime = DateTime.Parse(row["EditTime"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebApi.Model.CustomerProperty GetModel(int SysNo)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select SysNo,CustomerSysNo,PropertySysNo,PropertyValue,Status,CreateTime,EditTime from T_CustomerProperty ");
            strSql.Append(" where SysNo=@SysNo");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@SysNo", MySqlDbType.Int32)
            };
            parameters[0].Value = SysNo;

            WebApi.Model.CustomerProperty model = new WebApi.Model.CustomerProperty();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

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