This site is developed to XHTML and CSS2 W3C standards.
If you see this paragraph, your browser does not support those standards and you
need to upgrade. Visit WaSP
for a variety of options.
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Text.RegularExpressions;
namespace acess3
{
class ShipImport
{
internal static string connString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\Database31.mdb"; //Connection String zu .mdb
internal static OleDbConnection con = new OleDbConnection(connString);
internal static OleDbCommand cmd = new OleDbCommand(@"SELECT * FROM Schiffe", con);
internal static void ShipImportMethod()
{
string Import = global.iForm3.txtImport.Text;
Import = Import.Replace("\n", "\t");
Import = Import.Replace("(" , "");
Import = Import.Replace(")", "");
string[] ImportArray = Import.Split('\t', '/');
try
{
if(IstVorhanden(ImportArray[0].ToString(), ImportArray[7].ToString(), ImportArray[9].ToString()) == 0)
{
using (con = new OleDbConnection(connString))
{
try
{
string InsertString =
@"INSERT INTO Schiffe " +
"(Schiffsname, Venad, Rumpf, Captain, Angriffswert, Schilde, Panzerung, Struktur, Wendigkeit" +
", Angriffszeit, Angriffsenergie, Techlevel, Module, Kommandopunkte) " +
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
using (OleDbCommand InsertCmd = new OleDbCommand(InsertString, con))
{
OleDbParameter par1 = cmd.Parameters.Add("@p1", OleDbType.VarChar);
par1.Value = ImportArray[0];
OleDbParameter par2 = cmd.Parameters.Add("@p2", OleDbType.VarChar);
par2.Value = ImportArray[2];
OleDbParameter par3 = cmd.Parameters.Add("@p3", OleDbType.VarChar);
par3.Value = ImportArray[7];
OleDbParameter par4 = cmd.Parameters.Add("@p4", OleDbType.VarChar);
par4.Value = ImportArray[9];
OleDbParameter par5 = cmd.Parameters.Add("@p5", OleDbType.Integer);
par5.Value = ImportArray[41];
OleDbParameter par6 = cmd.Parameters.Add("@p6", OleDbType.Integer);
par6.Value = ImportArray[45];
OleDbParameter par7 = cmd.Parameters.Add("@p7", OleDbType.Integer);
par7.Value = ImportArray[49];
OleDbParameter par8 = cmd.Parameters.Add("@p8", OleDbType.Integer);
par8.Value = ImportArray[53];
OleDbParameter par9 = cmd.Parameters.Add("@p9", OleDbType.Integer);
par9.Value = ImportArray[57];
OleDbParameter par10 = cmd.Parameters.Add("@p10", OleDbType.VarChar);
par10.Value = ImportArray[34];
OleDbParameter par11 = cmd.Parameters.Add("@p11", OleDbType.Integer);
par11.Value = ImportArray[37];
OleDbParameter par12 = cmd.Parameters.Add("@p12", OleDbType.Integer);
par12.Value = ImportArray[16];
OleDbParameter par13 = cmd.Parameters.Add("@p13", OleDbType.Integer);
par13.Value = ImportArray[18];
OleDbParameter par14 = cmd.Parameters.Add("@p14", OleDbType.Integer);
par14.Value = ImportArray[20];
}
}
catch (OleDbException ex)
{
MessageBox.Show(ex.Message);
}
}
}
else if(IstVorhanden(ImportArray[0].ToString(), ImportArray[7].ToString(), ImportArray[9].ToString()) == 1)
{
using (con = new OleDbConnection(connString))
{
try
{
string InsertString =
@"UPDATE Schiffe " +
"(Schiffsname, Venad, Rumpf, Captain, Angriffswert, Schilde, Panherung, Struktur, Wendigkeit" +
", Angriffszeit, Angriffsenergie, Techlevel, Module, Kommandopunkte) " +
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
using (OleDbCommand InsertCmd = new OleDbCommand(InsertString, con))
{
OleDbParameter par1 = cmd.Parameters.Add("@p1", OleDbType.VarChar);
par1.Value = ImportArray[0];
OleDbParameter par2 = cmd.Parameters.Add("@p2", OleDbType.VarChar);
par2.Value = ImportArray[2];
OleDbParameter par3 = cmd.Parameters.Add("@p3", OleDbType.VarChar);
par3.Value = ImportArray[7];
OleDbParameter par4 = cmd.Parameters.Add("@p4", OleDbType.VarChar);
par4.Value = ImportArray[9];
OleDbParameter par5 = cmd.Parameters.Add("@p5", OleDbType.Integer);
par5.Value = ImportArray[41];
OleDbParameter par6 = cmd.Parameters.Add("@p6", OleDbType.Integer);
par6.Value = ImportArray[45];
OleDbParameter par7 = cmd.Parameters.Add("@p7", OleDbType.Integer);
par7.Value = ImportArray[49];
OleDbParameter par8 = cmd.Parameters.Add("@p8", OleDbType.Integer);
par8.Value = ImportArray[53];
OleDbParameter par9 = cmd.Parameters.Add("@p9", OleDbType.Integer);
par9.Value = ImportArray[57];
OleDbParameter par10 = cmd.Parameters.Add("@p10", OleDbType.VarChar);
par10.Value = ImportArray[34];
OleDbParameter par11 = cmd.Parameters.Add("@p11", OleDbType.Integer);
par11.Value = ImportArray[37];
OleDbParameter par12 = cmd.Parameters.Add("@p12", OleDbType.Integer);
par12.Value = ImportArray[16];
OleDbParameter par13 = cmd.Parameters.Add("@p13", OleDbType.Integer);
par13.Value = ImportArray[18];
OleDbParameter par14 = cmd.Parameters.Add("@p14", OleDbType.Integer);
par14.Value = ImportArray[20];
}
}
catch (OleDbException ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
catch (OleDbException ex)
{
MessageBox.Show(ex.Message);
}
}
private static int IstVorhanden(string p,string p_2,string p_3)
{
//throw new System.NotImplementedException();
int ret = 0;
using (OleDbConnection con1 = new OleDbConnection(connString))
{
con1.Open();
try
{
string pruefen = @"SELECT COUNT(Ship_ID) FROM Schiffe
WHERE Schiffsname = '" + p + "' AND Venad = '" + p_2 + "' AND Rumpf = '" + p_3 + "'";
using (OleDbCommand pruefCmd = new OleDbCommand(pruefen, con1))
{
OleDbParameter par1 = cmd.Parameters.Add("@p1", OleDbType.VarChar);
par1.Value = p;
OleDbParameter par2 = cmd.Parameters.Add("@p2", OleDbType.VarChar);
par2.Value = p_2;
OleDbParameter par3 = cmd.Parameters.Add("@p3", OleDbType.VarChar);
par3.Value = p_3;
ret = int.Parse(pruefCmd.ExecuteScalar().ToString());
}
return ret;
}
catch (OleDbException ex)
{
MessageBox.Show(ex.Message);
return ret;
}
}
}
}
}