Exemplo n.º 1
0
        public void DbUpdate(MySqlDbConnection myDbCon)
        {
            MySqlDbConnection dbcon;
            string            sqlcmd = "";

            // 引数にコネクションが指定されていた場合は指定されたコネクションを使用
            if (myDbCon != null)
            {
                dbcon = myDbCon;
            }
            else
            {
                dbcon = new MySqlDbConnection();
            }

            sqlcmd = "UPDATE maker ";
            sqlcmd = sqlcmd + "SET NAME = @NAME, LABEL = @LABEL, KIND = @KIND, MATCH_STR = @MATCH_STR, MATCH_PRODUCT_NUMBER = @MATCH_PRODUCT_NUMBER ";
            sqlcmd = sqlcmd + "WHERE ID = @ID ";

            MySqlCommand scmd     = new MySqlCommand(sqlcmd, dbcon.getMySqlConnection());
            DataTable    dtSaraly = new DataTable();

            List <MySqlParameter> sqlparams = new List <MySqlParameter>();

            MySqlParameter sqlparam = new MySqlParameter("@NAME", MySqlDbType.VarChar);

            sqlparam.Value = Name;
            sqlparams.Add(sqlparam);

            sqlparam       = new MySqlParameter("@LABEL", MySqlDbType.VarChar);
            sqlparam.Value = Label;
            sqlparams.Add(sqlparam);

            sqlparam       = new MySqlParameter("@KIND", MySqlDbType.Int32);
            sqlparam.Value = Kind;
            sqlparams.Add(sqlparam);

            sqlparam       = new MySqlParameter("@MATCH_STR", MySqlDbType.VarChar);
            sqlparam.Value = MatchStr;
            sqlparams.Add(sqlparam);

            sqlparam       = new MySqlParameter("@MATCH_PRODUCT_NUMBER", MySqlDbType.VarChar);
            sqlparam.Value = MatchProductNumber;
            sqlparams.Add(sqlparam);

            sqlparam       = new MySqlParameter("@ID", MySqlDbType.Int32);
            sqlparam.Value = Id;
            sqlparams.Add(sqlparam);

            dbcon.SetParameter(sqlparams.ToArray());

            dbcon.execSqlCommand(sqlcmd);

            return;
        }
Exemplo n.º 2
0
        public static List <MovieMaker> GetAllData()
        {
            MySqlDbConnection dbcon = new MySqlDbConnection();

            List <MovieMaker> listMMakers = new List <MovieMaker>();

            string queryString = "SELECT ID, NAME, LABEL, KIND, MATCH_STR, MATCH_PRODUCT_NUMBER, REGISTERED_BY, CREATED_AT, UPDATED_AT FROM maker ORDER BY NAME DESC ";

            dbcon.openConnection();

            MySqlCommand command = new MySqlCommand(queryString, dbcon.getMySqlConnection());

            MySqlDataReader reader = command.ExecuteReader();

            do
            {
                while (reader.Read())
                {
                    MovieMaker data = new MovieMaker();

                    int colNo = 0;
                    data.Id                 = MysqlExportCommon.GetDbInt(reader, colNo++);
                    data.Name               = MysqlExportCommon.GetDbString(reader, colNo++);
                    data.Label              = MysqlExportCommon.GetDbString(reader, colNo++);
                    data.Kind               = MysqlExportCommon.GetDbInt(reader, colNo++);
                    data.MatchStr           = MysqlExportCommon.GetDbString(reader, colNo++);
                    data.MatchProductNumber = MysqlExportCommon.GetDbString(reader, colNo++);
                    data.RegisterdBy        = MysqlExportCommon.GetDbString(reader, colNo++);
                    data.CreateDate         = MysqlExportCommon.GetDbDateTime(reader, colNo++);
                    data.UpdateDate         = MysqlExportCommon.GetDbDateTime(reader, colNo++);

                    listMMakers.Add(data);
                }
            } while (reader.NextResult());

            reader.Close();

            dbcon.closeConnection();

            return(listMMakers);
        }
Exemplo n.º 3
0
        public void DbExport(MySqlDbConnection myDbCon)
        {
            MySqlDbConnection dbcon;
            string            sqlcmd = "";

            // 引数にコネクションが指定されていた場合は指定されたコネクションを使用
            if (myDbCon != null)
            {
                dbcon = myDbCon;
            }
            else
            {
                dbcon = new MySqlDbConnection();
            }

            sqlcmd = "INSERT INTO maker ( NAME, LABEL, KIND, MATCH_STR, MATCH_PRODUCT_NUMBER ) ";
            sqlcmd = sqlcmd + "VALUES( @NAME, @LABEL, @KIND, @MATCH_STR, @MATCH_PRODUCT_NUMBER ) ";

            MySqlCommand scmd     = new MySqlCommand(sqlcmd, dbcon.getMySqlConnection());
            DataTable    dtSaraly = new DataTable();

            MySqlParameter[] sqlparams = new MySqlParameter[5];

            sqlparams[0]       = new MySqlParameter("@NAME", SqlDbType.VarChar);
            sqlparams[0].Value = Name;
            sqlparams[1]       = new MySqlParameter("@LABEL", SqlDbType.VarChar);
            sqlparams[1].Value = Label;
            sqlparams[2]       = new MySqlParameter("@KIND", SqlDbType.Int);
            sqlparams[2].Value = Kind;
            sqlparams[3]       = new MySqlParameter("@MATCH_STR", SqlDbType.VarChar);
            sqlparams[3].Value = MatchStr;
            sqlparams[4]       = new MySqlParameter("@MATCH_PRODUCT_NUMBER", SqlDbType.VarChar);
            sqlparams[4].Value = MatchProductNumber;

            dbcon.SetParameter(sqlparams);

            dbcon.execSqlCommand(sqlcmd);

            return;
        }