Newer
Older
IRIS_COLLECT / IOM_cs / irisDb / service / mySqlImpl / IrisDataCollService_MysqlImpl.cs
yangqianqian on 29 Dec 2020 2 KB first
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace IOM_cs.irisDb.service.mySqlImpl
{
    public class IrisDataCollService_MysqlImpl:IIrisDataCollService
    {
        /// <summary>
        /// 保存编辑
        /// </summary>
        public int UpdateColldata(long irid, String uploadCode, String upLoadUser, String resUpload)
        {
            int iRetval = 0;
            try
            {
                DateTime dt = DateTime.Now;
                // sys_person表
                string sQry = "UPDATE iris_data_coll set " +
                    "FLG_UPLOAD=@v1," +
                    "UPLOAD_USER=@v2," +
                    "UPLOAD_TIME=@v3, " +
                    "RES_UPLOAD=@v4 " +
                    "WHERE ir_id=@v5";

                MySqlCommand aCommand = new MySqlCommand(sQry, _MySqlHelper. mySqlConnection);
                aCommand.CommandTimeout = 0;
                aCommand.Parameters.AddWithValue("@v1", uploadCode);
                aCommand.Parameters.AddWithValue("@v2", upLoadUser);
                aCommand.Parameters.AddWithValue("@v3", dt);
                aCommand.Parameters.AddWithValue("@v4", resUpload);
                aCommand.Parameters.AddWithValue("@v5", irid);

                aCommand.ExecuteNonQuery();
                aCommand.Dispose();
            }
            catch (SqlException exSqlDb)
            {
                iRetval = exSqlDb.ErrorCode;
                if (_MySqlHelper.mySqlConnection.State == ConnectionState.Closed)
                {
                    MessageBox.Show("数据库连接断开,请重启软件!");
                    return -1;
                }
                MessageBox.Show("Update EXCEPTION: " + exSqlDb.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Update EXCEPTION: " + ex.Message);
            }

            return iRetval;
        }

    }
}