SQLiteConnection m_dbConnection = new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;");
public void createDB()
{
if (!File.Exists("MySqliteDatabase.sqlite"))
{
SQLiteConnection.CreateFile("MySqliteDatabase.sqlite");
m_dbConnection.Open();
string sql = "create table qmsutility (ID INTEGER PRIMARY KEY AUTOINCREMENT, instName varchar(20), bankId varchar(20), " +
"timeDate varchar(20), counterName varchar(20),totCounter varchar(20), copiesNo varchar(20),closingTime varchar(20), " +
"tokenSlip9 varchar(20),tokenSlipA varchar(20), tokenSlipB varchar(20)," +
"cla1 varchar(20), cla2 varchar(20),cla3 varchar(20), cla4 varchar(20)," +
"cla5 varchar(20), cla6 varchar(20),cla7 varchar(20), cla8 varchar(20)," +
"cla9 varchar(20), cla10 varchar(20),cla11 varchar(20), cla12 varchar(20)," +
"cla13 varchar(20), cla14 varchar(20),cla15 varchar(20), cla16 varchar(20), recordFileName varchar(60) NOT NULL UNIQUE)";
SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();
m_dbConnection.Close();
}
}
Â
public void insertData(Model modelData)
{
m_dbConnection.Open();
SQLiteCommand selectSQL = new SQLiteCommand("SELECT count(*) FROM qmsutility WHERE recordFileName='"+recordFileName.Text+"'", m_dbConnection);
int count = Convert.ToInt32(selectSQL.ExecuteScalar());
if (count == 0)
{
SQLiteCommand insertSQL = new SQLiteCommand("INSERT INTO qmsutility (instName, bankId, timeDate, counterName, totCounter," +
"copiesNo, closingTime, tokenSlip9, tokenSlipA, tokenSlipB, cla1, cla2, cla3, cla4, cla5, cla6,cla7,cla8,cla9,cla10," +
"cla11, cla12,cla13,cla14,cla15,cla16,recordFileName) VALUES (@instName, @bankId, @timeDate, @counterName, @totCounter,@copiesNo, " +
"@closingTime, @tokenSlip9, @tokenSlipA, @tokenSlipB, @cla1, @cla2, @cla3, @cla4," +
" @cla5, @cla6, @cla7, @cla8, @cla9, @cla10, @cla11, @cla12, @cla13, @cla14, @cla15, @cla16, @recordFileName" +
")", m_dbConnection);
insertSQL.Parameters.AddWithValue("@instName", modelData.instName);
insertSQL.Parameters.AddWithValue("@bankId", modelData.bankId);
insertSQL.Parameters.AddWithValue("@timeDate", modelData.timeDate);
insertSQL.Parameters.AddWithValue("@counterName", modelData.counterName);
insertSQL.Parameters.AddWithValue("@totCounter", modelData.totCounter);
insertSQL.Parameters.AddWithValue("@copiesNo", modelData.copiesNo);
insertSQL.Parameters.AddWithValue("@closingTime", modelData.closingTime);
insertSQL.Parameters.AddWithValue("@tokenSlip9", modelData.tokenSlip9);
insertSQL.Parameters.AddWithValue("@tokenSlipA", modelData.tokenSlipA);
insertSQL.Parameters.AddWithValue("@tokenSlipB", modelData.tokenSlipB);
insertSQL.Parameters.AddWithValue("@cla1", modelData.cla1);
insertSQL.Parameters.AddWithValue("@cla2", modelData.cla2);
insertSQL.Parameters.AddWithValue("@cla3", modelData.cla3);
insertSQL.Parameters.AddWithValue("@cla4", modelData.cla4);
insertSQL.Parameters.AddWithValue("@cla5", modelData.cla5);
insertSQL.Parameters.AddWithValue("@cla6", modelData.cla6);
insertSQL.Parameters.AddWithValue("@cla7", modelData.cla7);
insertSQL.Parameters.AddWithValue("@cla8", modelData.cla8);
insertSQL.Parameters.AddWithValue("@cla9", modelData.cla9);
insertSQL.Parameters.AddWithValue("@cla10", modelData.cla10);
insertSQL.Parameters.AddWithValue("@cla11", modelData.cla11);
insertSQL.Parameters.AddWithValue("@cla12", modelData.cla12);
insertSQL.Parameters.AddWithValue("@cla13", modelData.cla13);
insertSQL.Parameters.AddWithValue("@cla14", modelData.cla14);
insertSQL.Parameters.AddWithValue("@cla15", modelData.cla15);
insertSQL.Parameters.AddWithValue("@cla16", modelData.cla16);
insertSQL.Parameters.AddWithValue("@recordFileName", modelData.recordFileName);
try
{
insertSQL.ExecuteNonQuery();
MessageBox.Show("Data Inserted Successfully");
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
else {
MessageBox.Show("Record Name Already Exist");
}
m_dbConnection.Close();
}
Â
public class Model
{
public string instName { get; set; }
public string bankId { get; set; }
public string timeDate { get; set; }
public string counterName { get; set; }
public string totCounter { get; set; }
public string copiesNo { get; set; }
public string closingTime { get; set; }
public string tokenSlip9 { get; set; }
public string tokenSlipA { get; set; }
public string tokenSlipB { get; set; }
public string cla1 { get; set; }
public string cla2 { get; set; }
public string cla3 { get; set; }
public string cla4 { get; set; }
public string cla5 { get; set; }
public string cla6 { get; set; }
public string cla7 { get; set; }
public string cla8 { get; set; }
public string cla9 { get; set; }
public string cla10 { get; set; }
public string cla11 { get; set; }
public string cla12 { get; set; }
public string cla13 { get; set; }
public string cla14 { get; set; }
public string cla15 { get; set; }
public string cla16 { get; set; }
public string recordFileName { get; set; }
}
Â
Â
public void updateDB(Model modelData)
{
m_dbConnection.Open();
string sql_update = "UPDATE qmsutility SET instName = @instName, bankId = @bankId," +
"timeDate = @timeDate," +
"counterName = @counterName," +
"totCounter = @totCounter, copiesNo = @copiesNo," +
"closingTime = @closingTime, tokenSlip9 = @tokenSlip9," +
"tokenSlipA = @tokenSlipA, tokenSlipB = @tokenSlipB," +
"cla1 = @cla1, cla2 = @cla2," +
"cla3 = @cla3, cla4 = @cla4," +
"cla5 = @cla5, cla6 = @cla6," +
"cla7 = @cla7, cla8 = @cla8," +
"cla9 = @cla9, cla10 = @cla10," +
"cla11 = @cla11, cla12 = @cla12," +
"cla13 = @cla13, cla14 = @cla14," +
"cla15 = @cla15, cla16 = @cla16, recordFileName=@recordFileName Where ID = @ID";
SQLiteCommand command = new SQLiteCommand(sql_update, m_dbConnection);
command.Parameters.AddWithValue("@instName", modelData.instName);
command.Parameters.AddWithValue("@bankId", modelData.bankId);
command.Parameters.AddWithValue("@timeDate", modelData.timeDate);
command.Parameters.AddWithValue("@counterName", modelData.counterName);
command.Parameters.AddWithValue("@totCounter", modelData.totCounter);
command.Parameters.AddWithValue("@copiesNo", modelData.copiesNo);
command.Parameters.AddWithValue("@closingTime", modelData.closingTime);
command.Parameters.AddWithValue("@tokenSlip9", modelData.tokenSlip9);
command.Parameters.AddWithValue("@tokenSlipA", modelData.tokenSlipA);
command.Parameters.AddWithValue("@tokenSlipB", modelData.tokenSlipB);
command.Parameters.AddWithValue("@cla1", modelData.cla1);
command.Parameters.AddWithValue("@cla2", modelData.cla2);
command.Parameters.AddWithValue("@cla3", modelData.cla3);
command.Parameters.AddWithValue("@cla4", modelData.cla4);
command.Parameters.AddWithValue("@cla5", modelData.cla5);
command.Parameters.AddWithValue("@cla6", modelData.cla6);
command.Parameters.AddWithValue("@cla7", modelData.cla7);
command.Parameters.AddWithValue("@cla8", modelData.cla8);
command.Parameters.AddWithValue("@cla9", modelData.cla9);
command.Parameters.AddWithValue("@cla10", modelData.cla10);
command.Parameters.AddWithValue("@cla11", modelData.cla11);
command.Parameters.AddWithValue("@cla12", modelData.cla12);
command.Parameters.AddWithValue("@cla13", modelData.cla13);
command.Parameters.AddWithValue("@cla14", modelData.cla14);
command.Parameters.AddWithValue("@cla15", modelData.cla15);
command.Parameters.AddWithValue("@cla16", modelData.cla16);
command.Parameters.AddWithValue("@recordFileName", modelData.recordFileName);
command.Parameters.AddWithValue("@ID", qmsComboBox.SelectedItem);
try
{
command.ExecuteNonQuery();
m_dbConnection.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
Â
Comments5
priligy 30 mg alkol
xwtdjidr
lmsbbswe
enjfywuv
cbjwduag