93 lines
2.9 KiB
C#
93 lines
2.9 KiB
C#
using MySql.Data.MySqlClient;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SQLite;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace AVS
|
|
{
|
|
internal class WeightTolerance
|
|
{
|
|
public string FNSKU { get; set; }
|
|
|
|
public double WEIGHT_TOLERANCE { get; set; }
|
|
public DateTime WEIGHT_TOLERANCE_DATETIME { get; set; }
|
|
public string MARKET_PLACE { get; set; }
|
|
|
|
|
|
private MySqlConnection connection;
|
|
|
|
private string connectionString = "server=utopia-2.c5qech8o9lgg.us-east-1.rds.amazonaws.com;user=itemVerification;password=itemVerification01;database=item_verification_system;";
|
|
|
|
|
|
public MySqlConnection OpenConnection()
|
|
{
|
|
try
|
|
{
|
|
// Open the Mysql connection
|
|
connection = new MySqlConnection(connectionString);
|
|
connection.Open();
|
|
//MessageBox.Show("MySQL connection opened successfully", "Connection Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
Console.WriteLine("Mysql connection opened successfully");
|
|
return connection;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
Console.WriteLine($"Error opening SQLite connection: {ex.Message}");
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public void CloseConnection()
|
|
{
|
|
try
|
|
{
|
|
connection = new MySqlConnection(connectionString);
|
|
// Close the Mysql connection
|
|
connection?.Close();
|
|
Console.WriteLine("Mysql connection closed successfully");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"Error closing SQLite connection: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public class TableColumn
|
|
{
|
|
public string Name { get; set; }
|
|
public string DataType { get; set; }
|
|
}
|
|
|
|
public class WeightToleranceTable
|
|
{
|
|
public static List<TableColumn> GetColumns()
|
|
{
|
|
return new List<TableColumn>
|
|
{
|
|
new TableColumn { Name = "Id", DataType = "INTEGER PRIMARY KEY AUTOINCREMENT" },
|
|
new TableColumn { Name = "FNSKU", DataType = "TEXT" },
|
|
|
|
new TableColumn { Name = "WEIGHT_TOLERANCE_DATETIME", DataType = "DATETIME" },
|
|
new TableColumn { Name = "WEIGHT_TOLERANCE", DataType = "REAL" },
|
|
|
|
new TableColumn { Name = "MARKET_PLACE", DataType = "TEXT" },
|
|
};
|
|
}
|
|
}
|
|
public static string GetColumnsDefinition(List<TableColumn> columns)
|
|
{
|
|
// Convert the list of columns into a string for the CREATE TABLE command
|
|
return string.Join(", ", columns.Select(c => $"{c.Name} {c.DataType}"));
|
|
}
|
|
|
|
}
|
|
}
|