private void button5_Click(object sender, EventArgs e) { var props = new SqlProps("200.0.1.20", "CalcArchive", true, "sa", "1"); SqlDb.Execute(props, "DELETE FROM SingleValues"); SqlDb.Execute(props, "DELETE FROM SingleStrValues"); SqlDb.Execute(props, "DELETE FROM BaseValues"); SqlDb.Execute(props, "DELETE FROM HourValues"); SqlDb.Execute(props, "DELETE FROM DayValues"); SqlDb.Execute(props, "DELETE FROM PeriodicStrValues"); SqlDb.Execute(props, "DELETE FROM AbsoluteValues"); SqlDb.Execute(props, "DELETE FROM AbsoluteStrValues"); SqlDb.Execute(props, "DELETE FROM AbsoluteDayValues"); SqlDb.Execute(props, "DELETE FROM MomentsValues"); SqlDb.Execute(props, "DELETE FROM Intervals"); SqlDb.Execute(props, "DELETE FROM Ranges"); SqlDb.Execute(props, "DELETE FROM Params"); SqlDb.Execute(props, "DELETE FROM Projects"); SqlDb.Execute(props, "DELETE FROM ReportParams"); SqlDb.Execute(props, "DELETE FROM Reports"); SqlDb.Execute(props, "DELETE FROM HandInputValues"); SqlDb.Execute(props, "DELETE FROM AbsoluteEditValues"); SqlDb.Execute(props, "DELETE FROM HandInputProjects"); }
//Загрузка свойств из словаря protected override void ReadInf(DicS <string> dic) { bool e = dic["IdentType"].ToUpper() != "WINDOWS"; string server = dic["SQLServer"], db = dic["Database"]; SqlProps = new SqlProps(server, db, e, dic["Login"], dic["Password"]); }
private void SqlButton_Click(object sender, EventArgs e) { var props = new SqlProps("200.0.1.20", "CalcArchiveTemplate", true, "sa", "1"); SqlDb.Execute(props, "DELETE FROM Proba"); using (var rec = new BulkSql(props, "Proba")) { for (int i = 1; i <= 5; i++) { rec.AddNew(); rec.Put("IntF", 10 * i); double?d = 1.1 * i; if (i % 2 == 0) { d = null; } rec.Put("DoubleF", d); string s = i + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"; if (i % 2 == 0) { s = null; } rec.Put("StrF", s, true); rec.Put("BoolF", i % 2 == 0); rec.Put("TimeF", DateTime.Now); } rec.Update(); } //SqlDb.Execute(con, "DELETE FROM Projects"); //var d = DateTime.Now; //var bulk = new BulkSql("Projects", con); //for (int i = 0; i < 100000; i++) //{ // bulk.AddNew(); // bulk.Put("Project", "Pr" + i); // bulk.Put("ProjectName", "Name" + i); // bulk.Put("SourceChange", DateTime.Now); // bulk.Put("TimeChange", DateTime.Now); // bulk.Put("TimeAdd", DateTime.UtcNow); //} //bulk.Update(); //bulk.Close(); //MessageBox.Show(DateTime.Now.Subtract(d).TotalSeconds.ToString()); }
private void DataSetButton_Click(object sender, EventArgs e) { var props = new SqlProps("200.0.1.20", "CalcArchiveTemplate", true, "sa", "1"); SqlDb.Execute(props, "DELETE FROM Proba"); using (var rec = new DataSetSql(props, "SELECT * FROM Proba")) { rec.AddNew(); rec.Put("IntF", 10); rec.Put("DoubleF", 20.5); rec.Put("StrF", "sss"); rec.Put("BoolF", true); rec.Put("TimeF", DateTime.Now); rec.Update(); rec.AddNew(); rec.Put("IntF", 20); double?d = null; rec.Put("DoubleF", d); rec.Put("StrF", ""); rec.Put("BoolF", false); rec.Put("TimeF", DateTime.UtcNow); rec.AddNew(); rec.Put("IntF", 30); rec.Update(); rec.AddNew(); rec.MoveFirst(); MessageBox.Show(rec.GetBool("BoolF") + " " + rec.GetBoolNull("BoolF") + " " + rec.GetInt("IntF") + " " + rec.GetIntNull("IntF") + " " + rec.GetDouble("DoubleF") + " " + rec.GetDoubleNull("DoubleF") + " " + rec.GetString("StrF") + " " + rec.GetTime("TimeF") + " " + rec.GetTimeNull("TimeF")); rec.MoveNext(); MessageBox.Show(rec.GetBool("BoolF") + " " + rec.GetBoolNull("BoolF") + " " + rec.GetInt("IntF") + " " + rec.GetIntNull("IntF") + " " + rec.GetDouble("DoubleF") + " " + rec.GetDoubleNull("DoubleF") + " " + rec.GetString("StrF") + " " + rec.GetTime("TimeF") + " " + rec.GetTimeNull("TimeF")); rec.MoveNext(); MessageBox.Show(rec.GetBool("BoolF") + " " + rec.GetBoolNull("BoolF") + " " + rec.GetInt("IntF") + " " + rec.GetIntNull("IntF") + " " + rec.GetDouble("DoubleF") + " " + rec.GetDoubleNull("DoubleF") + " " + rec.GetString("StrF") + " " + rec.GetTime("TimeF") + " " + rec.GetTimeNull("TimeF")); rec.MovePrevious(); MessageBox.Show(rec.GetBool("BoolF") + " " + rec.GetBoolNull("BoolF") + " " + rec.GetInt("IntF") + " " + rec.GetIntNull("IntF") + " " + rec.GetDouble("DoubleF") + " " + rec.GetDoubleNull("DoubleF") + " " + rec.GetString("StrF") + " " + rec.GetTime("TimeF") + " " + rec.GetTimeNull("TimeF")); rec.MoveLast(); MessageBox.Show(rec.GetBool("BoolF") + " " + rec.GetBoolNull("BoolF") + " " + rec.GetInt("IntF") + " " + rec.GetIntNull("IntF") + " " + rec.GetDouble("DoubleF") + " " + rec.GetDoubleNull("DoubleF") + " " + rec.GetString("StrF") + " " + rec.GetTime("TimeF") + " " + rec.GetTimeNull("TimeF")); MessageBox.Show(rec.FindLast("IntF", 10).ToString()); MessageBox.Show(rec.GetBool("BoolF") + " " + rec.GetBoolNull("BoolF") + " " + rec.GetInt("IntF") + " " + rec.GetIntNull("IntF") + " " + rec.GetDouble("DoubleF") + " " + rec.GetDoubleNull("DoubleF") + " " + rec.GetString("StrF") + " " + rec.GetTime("TimeF") + " " + rec.GetTimeNull("TimeF")); MessageBox.Show(rec.MoveLast() + " " + rec.MoveNext()); MessageBox.Show(rec.EOF + " " + rec.BOF); MessageBox.Show(rec.MoveFirst() + " " + rec.MovePrevious()); MessageBox.Show(rec.EOF + " " + rec.BOF); MessageBox.Show(rec.RecordCount.ToString()); rec.MoveLast(); rec.Put("IntF", 40); rec.Put("DoubleF", 200); rec.Put("StrF", "ooo"); bool?b = null; rec.Put("BoolF", b); rec.Put("TimeF", DateTime.Now); MessageBox.Show(rec.GetBool("BoolF") + " " + rec.GetBoolNull("BoolF") + " " + rec.GetInt("IntF") + " " + rec.GetIntNull("IntF") + " " + rec.GetDouble("DoubleF") + " " + rec.GetDoubleNull("DoubleF") + " " + rec.GetString("StrF") + " " + rec.GetTime("TimeF") + " " + rec.GetTimeNull("TimeF")); rec.Update(); } //SqlDb.Execute(con, "DELETE FROM Projects"); //var d = DateTime.Now; //var bulk = new DataSetSql("SELECT * FROM Projects", con); //for (int i = 0; i < 1000; i++) //{ // bulk.AddNew(); // bulk.Put("Project", "Pr" + i); // bulk.Put("ProjectName", "Name" + i); // bulk.Put("SourceChange", DateTime.Now); // bulk.Put("TimeChange", DateTime.Now); // bulk.Put("TimeAdd", DateTime.UtcNow); //} //bulk.Update(); //bulk.Close(); //MessageBox.Show(DateTime.Now.Subtract(d).TotalSeconds.ToString()); }