Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int update(Model.ProcessData_Management model)
        {
            string strSql = "UPDATE processdata_management SET FileName=@FileName,Date=@Date,File=@File,Comment=@Comment WHERE ID=@ID";

            MySqlParameter[] parameters =
            {
                new MySqlParameter("@FileName", MySqlDbType.VarChar, 255),
                new MySqlParameter("@Date",     MySqlDbType.VarChar, 255),
                new MySqlParameter("@File",     MySqlDbType.VarChar, 255),
                new MySqlParameter("@Comment",  MySqlDbType.VarChar, 255),
                new MySqlParameter("@ID",       MySqlDbType.Int32)
            };
            parameters[0].Value = model.FileName;
            parameters[1].Value = model.Date;
            parameters[2].Value = model.File;
            parameters[3].Value = model.Comment;
            parameters[4].Value = model.ID;

            object obj = Utility.MySqlHelper.ExecuteTxtScalar(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 2
0
        public int add(Model.ProcessData_Management model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into processdata_management(");
            strSql.Append("FileName,Date,File,Comment)");
            strSql.Append(" values (");
            strSql.Append("@FileName,@Date,@File,@Comment)");
            strSql.Append(";select @@IDENTITY");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@FileName", MySqlDbType.VarChar, 255),
                new MySqlParameter("@Date",     MySqlDbType.VarChar, 255),
                new MySqlParameter("@File",     MySqlDbType.VarChar, 255),
                new MySqlParameter("@Comment",  MySqlDbType.VarChar, 255),
            };
            parameters[0].Value = model.FileName;
            parameters[1].Value = model.Date;
            parameters[2].Value = model.File;
            parameters[3].Value = model.Comment;
            object obj = Utility.MySqlHelper.ExecuteTxtScalar(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }