Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int update(Model.ProcessData_Sample_Info model)
        {
            string strSql = "UPDATE processdata_sample_info 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));
            }
        }
Esempio n. 2
0
        public int add(Model.ProcessData_Sample_Info model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into processdata_sample_info(");
            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));
            }
        }