Exemplo n.º 1
0
        public void Insert_RecordField()
        {
            var client  = BigqueryClient.Create(_fixture.ProjectId);
            var dataset = client.GetDataset(_fixture.DatasetId);
            var table   = dataset.GetTable(_fixture.ComplexTypesTableId);
            var guid    = Guid.NewGuid().ToString();
            var row     = new InsertRow
            {
                ["guid"]     = guid,
                ["position"] = new InsertRow {
                    ["x"] = 10L, ["y"] = 20L
                }
            };

            table.Insert(row);
            // We know the format of Guid.ToString() is harmless. More care needed for arbitrary strings, of course!
            var queryResults = client.ExecuteQuery($"SELECT guid, position.x, position.y FROM {table} WHERE guid='{guid}'").Rows
                               .Select(r => new { Guid = (string)r["guid"], X = (long)r["position_x"], Y = (long)r["position_y"] })
                               .ToList();
            var expectedResults = new[]
            {
                new { Guid = guid, X = 10L, Y = 20L }
            };

            Assert.Equal(expectedResults, queryResults);
        }
Exemplo n.º 2
0
        public void Insert_RepeatedField()
        {
            var client  = BigqueryClient.Create(_fixture.ProjectId);
            var dataset = client.GetDataset(_fixture.DatasetId);
            var table   = dataset.GetTable(_fixture.ComplexTypesTableId);
            var guid    = Guid.NewGuid().ToString();
            var row     = new InsertRow
            {
                ["guid"] = guid,
                // The null element will be ignored here (at the server side)
                ["tags"] = new[] { "a", null, "b" }
            };

            table.Insert(row);
            // We know the format of Guid.ToString() is harmless. More care needed for arbitrary strings, of course!
            var queryResults = client.ExecuteQuery($"SELECT guid, tags FROM {table} WHERE guid='{guid}' ORDER BY TAGS").Rows
                               .Select(r => new { Guid = (string)r["guid"], Tag = (string)r["tags"] })
                               .ToList();
            var expectedResults = new[]
            {
                new { Guid = guid, Tag = "a" },
                new { Guid = guid, Tag = "b" }
            };

            Assert.Equal(expectedResults, queryResults);
        }
        public void Insert()
        {
            string projectId = _fixture.ProjectId;
            string datasetId = _fixture.GameDatasetId;
            string tableId   = _fixture.HistoryTableId;

            BigqueryTable table      = BigqueryClient.Create(projectId).GetTable(datasetId, tableId);
            int           rowsBefore = table.ListRows().Rows.Count();

            // Snippet: Insert(string,string,*)
            BigqueryClient client = BigqueryClient.Create(projectId);
            // The insert ID is optional, but can avoid duplicate data
            // when retrying inserts.
            InsertRow row1 = new InsertRow("row1")
            {
                { "player", "Jane" },
                { "level", 3 },
                { "score", 3600 },
                { "game_started", DateTime.UtcNow }
            };
            InsertRow row2 = new InsertRow("row2")
            {
                { "player", "Jeff" },
                { "level", 2 },
                { "score", 2000 },
                { "game_started", DateTime.UtcNow }
            };

            client.Insert(datasetId, tableId, row1, row2);
            // End snippet

            int rowsAfter = table.ListRows().Rows.Count();

            Assert.Equal(rowsBefore + 2, rowsAfter);
        }
Exemplo n.º 4
0
        public void Insert_RepeatedRecordField()
        {
            var client  = BigqueryClient.Create(_fixture.ProjectId);
            var dataset = client.GetDataset(_fixture.DatasetId);
            var table   = dataset.GetTable(_fixture.ComplexTypesTableId);
            var guid    = Guid.NewGuid().ToString();
            var row     = new InsertRow
            {
                ["guid"]  = guid,
                ["names"] = new[] {
                    new InsertRow {
                        ["first"] = "a", ["last"] = "b"
                    },
                    new InsertRow {
                        ["first"] = "x", ["last"] = "y"
                    }
                }
            };

            table.Insert(row);
            var command = new BigqueryCommand($"SELECT guid, name.first, name.last FROM {table}, UNNEST(names) AS name WHERE guid=@guid ORDER BY name.first")
            {
                Parameters = { { "guid", BigqueryParameterType.String, guid } }
            };
            var queryResults = WaitForRows(client, command)
                               .Select(r => new { Guid = (string)r["guid"], FirstName = (string)r["first"], LastName = (string)r["last"] })
                               .ToList();
            var expectedResults = new[]
            {
                new { Guid = guid, FirstName = "a", LastName = "b" },
                new { Guid = guid, FirstName = "x", LastName = "y" }
            };

            Assert.Equal(expectedResults, queryResults);
        }
Exemplo n.º 5
0
        public void Insert_RecordField()
        {
            var client  = BigqueryClient.Create(_fixture.ProjectId);
            var dataset = client.GetDataset(_fixture.DatasetId);
            var table   = dataset.GetTable(_fixture.ComplexTypesTableId);
            var guid    = Guid.NewGuid().ToString();
            var row     = new InsertRow
            {
                ["guid"]     = guid,
                ["position"] = new InsertRow {
                    ["x"] = 10L, ["y"] = 20L
                }
            };

            table.Insert(row);
            var command = new BigqueryCommand($"SELECT guid, position.x, position.y FROM {table} WHERE guid=@guid")
            {
                Parameters = { { "guid", BigqueryParameterType.String, guid } }
            };
            var queryResults = WaitForRows(client, command)
                               .Select(r => new { Guid = (string)r["guid"], X = (long)r["x"], Y = (long)r["y"] })
                               .ToList();
            var expectedResults = new[]
            {
                new { Guid = guid, X = 10L, Y = 20L }
            };

            Assert.Equal(expectedResults, queryResults);
        }
Exemplo n.º 6
0
        public void Insert_RepeatedField()
        {
            var client  = BigqueryClient.Create(_fixture.ProjectId);
            var dataset = client.GetDataset(_fixture.DatasetId);
            var table   = dataset.GetTable(_fixture.ComplexTypesTableId);
            var guid    = Guid.NewGuid().ToString();
            var row     = new InsertRow
            {
                ["guid"] = guid,
                // The null element will be ignored here (at the server side)
                ["tags"] = new[] { "a", null, "b" }
            };

            table.Insert(row);
            var command = new BigqueryCommand($"SELECT guid, tag FROM {table}, UNNEST(tags) AS tag WHERE guid=@guid ORDER BY tag")
            {
                Parameters = { { "guid", BigqueryParameterType.String, guid } }
            };
            var queryResults = WaitForRows(client, command)
                               .Select(r => new { Guid = (string)r["guid"], Tag = (string)r["tag"] })
                               .ToList();
            var expectedResults = new[]
            {
                new { Guid = guid, Tag = "a" },
                new { Guid = guid, Tag = "b" }
            };

            Assert.Equal(expectedResults, queryResults);
        }
Exemplo n.º 7
0
        public void Save()
        {
            if (Changed)
            {
                if (ID >= 0)
                {
                    DBInterface.CommandText = "UPDATE `sellcontroller`.`label` SET `name` = @name, " +
                                              "`comment` = @comment, `color` = @color, `idParent` = @idParent WHERE `idLabel` = @id;";

                    DBInterface.AddParameter("@name", MySql.Data.MySqlClient.MySqlDbType.String, Name);
                    DBInterface.AddParameter("@comment", MySql.Data.MySqlClient.MySqlDbType.String, Comment);
                    DBInterface.AddParameter("@color", MySql.Data.MySqlClient.MySqlDbType.VarBinary, GetColor());

                    if (ParentID > -1)
                    {
                        DBInterface.AddParameter("@idParent", MySql.Data.MySqlClient.MySqlDbType.Int32, ParentID);
                    }
                    else
                    {
                        DBInterface.AddParameter("@idParent", MySql.Data.MySqlClient.MySqlDbType.Int32, null);
                    }

                    DBInterface.AddParameter("@id", MySql.Data.MySqlClient.MySqlDbType.Int32, ID);

                    DBInterface.ExecuteTransaction();

                    if (Updated != null)
                    {
                        Updated(this, new DBEventArgs()
                        {
                            ForceUpdate = false
                        });
                    }
                }
                else
                {
                    InsertRow insertRow = new InsertRow("label");
                    insertRow.Add("name", MySql.Data.MySqlClient.MySqlDbType.String, Name);
                    insertRow.Add("comment", MySql.Data.MySqlClient.MySqlDbType.String, Comment);
                    insertRow.Add("color", MySql.Data.MySqlClient.MySqlDbType.VarBinary, GetColor());

                    if (ParentID > -1)
                    {
                        insertRow.Add("idParent", MySql.Data.MySqlClient.MySqlDbType.Int32, ParentID);
                    }

                    insertRow.Execute();

                    if (Updated != null)
                    {
                        Updated(this, new DBEventArgs()
                        {
                            ForceUpdate = true
                        });
                    }
                }
                Changed = false;
            }
        }
Exemplo n.º 8
0
        public void RepeatedValue()
        {
            var row = new InsertRow {
                { "numbers", new[] { 1, 2 } }
            };
            var rowData = row.ToRowsData();

            Assert.Equal(new object[] { 1, 2 }, rowData.Json["numbers"]);
        }
Exemplo n.º 9
0
        public void DateTimeFormatting()
        {
            var row = new InsertRow
            {
                { "field", new DateTime(2000, 1, 1, 5, 0, 0, DateTimeKind.Utc) },
            };
            var rowData = row.ToRowsData();

            Assert.Equal("2000-01-01 05:00:00Z", rowData.Json["field"]);
        }
Exemplo n.º 10
0
        private void AssertInvalid(string name, object value)
        {
            var row = new InsertRow();

            Assert.Throws <ArgumentException>(() => row.Add(name, value));
            Assert.Throws <ArgumentException>(() => row[name] = value);
            Assert.Throws <ArgumentException>(() => row.Add(new Dictionary <string, object> {
                { name, value }
            }));
        }
Exemplo n.º 11
0
        public void SupportedValueTypes_Passthrough(Type type)
        {
            object value = Activator.CreateInstance(type);
            var    row   = new InsertRow {
                { "field", value }
            };
            var rowData = row.ToRowsData();

            Assert.Equal(value, rowData.Json["field"]);
        }
Exemplo n.º 12
0
        public void AddDictionary()
        {
            var dictionary = new Dictionary <string, object> {
                { "field1", "value1" }
            };
            var row = new InsertRow {
                dictionary
            };

            Assert.Equal("value1", row["field1"]);
        }
Exemplo n.º 13
0
        public void Insert_BadData()
        {
            var client  = BigqueryClient.Create(_fixture.ProjectId);
            var dataset = client.GetDataset(_fixture.DatasetId);
            var table   = dataset.GetTable(_fixture.HighScoreTableId);
            var row     = new InsertRow {
                { "noSuchField", 10 }
            };

            Assert.Throws <GoogleApiException>(() => table.Insert(row));
        }
Exemplo n.º 14
0
        public void DateTimeOffsetFormatting()
        {
            var row = new InsertRow
            {
                // 3am UTC
                { "field", new DateTimeOffset(2000, 1, 1, 5, 0, 0, TimeSpan.FromHours(2)) },
            };
            var rowData = row.ToRowsData();

            Assert.Equal("2000-01-01 03:00:00Z", rowData.Json["field"]);
        }
Exemplo n.º 15
0
        public void Insert_BadData_IgnoreBadData()
        {
            var client  = BigqueryClient.Create(_fixture.ProjectId);
            var dataset = client.GetDataset(_fixture.DatasetId);
            var table   = dataset.GetTable(_fixture.HighScoreTableId);
            var row     = new InsertRow {
                { "noSuchField", 10 }
            };

            table.Insert(row, new InsertOptions {
                AllowUnknownFields = true
            });
        }
Exemplo n.º 16
0
        public void NestedRecordFormatting()
        {
            var nested = new InsertRow {
                { "inner", "value" }
            };
            var outer = new InsertRow {
                { "outer", nested }
            };
            var rowData = outer.ToRowsData();
            var obj     = (IDictionary <string, object>)rowData.Json["outer"];

            Assert.Equal("value", obj["inner"]);
        }
Exemplo n.º 17
0
 public void AttachToPerson()
 {
     if (!LoadAttachedData(false))
     {
         InsertRow insertRow = new InsertRow("personlabel");
         insertRow.Add("note", MySql.Data.MySqlClient.MySqlDbType.String, Note);
         insertRow.Add("idPerson", MySql.Data.MySqlClient.MySqlDbType.Int32, person.ID);
         insertRow.Add("idLabel", MySql.Data.MySqlClient.MySqlDbType.Int32, ID);
         insertRow.Execute();
     }
     else
     {
         throw new DuplicateNameException("Its impossible to add the same label to person twice");
     }
 }
Exemplo n.º 18
0
        public void SimpleSuccess()
        {
            var row = new InsertRow
            {
                { "field1", "value1" },
                { "field2", null }
            };

            Assert.Equal("value1", row["field1"]);
            row["field3"] = 2;
            var rowData = row.ToRowsData();

            Assert.Equal("value1", rowData.Json["field1"]);
            Assert.Null(rowData.Json["field2"]);
            Assert.Equal(2, rowData.Json["field3"]);
        }
Exemplo n.º 19
0
        public void ComplexTypes()
        {
            var client    = BigqueryClient.Create(_fixture.ProjectId);
            var dataset   = client.GetDataset(_fixture.DatasetId);
            var table     = dataset.GetTable(_fixture.ComplexTypesTableId);
            var guid      = Guid.NewGuid().ToString();
            var insertRow = new InsertRow
            {
                ["guid"]     = guid,
                ["tags"]     = new[] { "a", "b" },
                ["position"] = new InsertRow {
                    ["x"] = 10L, ["y"] = 20L
                },
                ["names"] = new[] {
                    new InsertRow {
                        ["first"] = "a", ["last"] = "b"
                    },
                    new InsertRow {
                        ["first"] = "x", ["last"] = "y"
                    }
                }
            };

            table.Insert(insertRow);
            var result = table.ListRows();
            var row    = result.Single(r => (string)r["guid"] == guid);
            var tags   = (string[])row["tags"];

            Assert.Equal(new[] { "a", "b" }, tags);

            var position = (Dictionary <string, object>)row["position"];

            Assert.Equal(new Dictionary <string, object> {
                ["x"] = 10L, ["y"] = 20L
            }, position);

            var names = (Dictionary <string, object>[])row["names"];

            Assert.Equal(new[] {
                new Dictionary <string, object> {
                    ["first"] = "a", ["last"] = "b"
                },
                new Dictionary <string, object> {
                    ["first"] = "x", ["last"] = "y"
                }
            }, names);
        }
Exemplo n.º 20
0
        public void Save()
        {
            if (Changed)
            {
                if (ID >= 0)
                {
                    DBInterface.CommandText = "UPDATE `sellcontroller`.`country` SET `nameCountry` = @name, " +
                                              "`codeISO2` = @iso2, `codeISO3` = @iso3, `codeCitizen` = @nat  WHERE `idCountry` = @id;";

                    DBInterface.AddParameter("@name", MySql.Data.MySqlClient.MySqlDbType.String, Name);
                    DBInterface.AddParameter("@iso2", MySql.Data.MySqlClient.MySqlDbType.String, ISO);
                    DBInterface.AddParameter("@iso3", MySql.Data.MySqlClient.MySqlDbType.String, ISO3);
                    DBInterface.AddParameter("@nat", MySql.Data.MySqlClient.MySqlDbType.String, Nationality);
                    DBInterface.AddParameter("@id", MySql.Data.MySqlClient.MySqlDbType.Int32, ID);

                    DBInterface.ExecuteTransaction();

                    if (Updated != null)
                    {
                        Updated(this, new DBEventArgs()
                        {
                            ForceUpdate = false
                        });
                    }
                }
                else
                {
                    InsertRow insertRow = new InsertRow("country");
                    insertRow.Add("nameCountry", MySql.Data.MySqlClient.MySqlDbType.String, Name);
                    insertRow.Add("codeISO2", MySql.Data.MySqlClient.MySqlDbType.String, ISO);
                    insertRow.Add("codeISO3", MySql.Data.MySqlClient.MySqlDbType.String, ISO3);
                    insertRow.Add("codeCitizen", MySql.Data.MySqlClient.MySqlDbType.String, Nationality);
                    insertRow.Execute();

                    if (Updated != null)
                    {
                        Updated(this, new DBEventArgs()
                        {
                            ForceUpdate = true
                        });
                    }
                }

                Changed = false;
            }
        }
Exemplo n.º 21
0
        public void InsertEquivalents_SingleRow()
        {
            var datasetId = "dataset";
            var tableId   = "table";
            var reference = new TableReference {
                ProjectId = ProjectId, DatasetId = datasetId, TableId = tableId
            };
            var schema  = new TableSchemaBuilder().Build();
            var options = new InsertOptions();
            var stream  = new MemoryStream();
            var row     = new InsertRow();

            VerifyEquivalent(
                client => client.Insert(MatchesWhenSerialized(reference), new[] { row }, options),
                client => client.Insert(datasetId, tableId, row, options),
                client => client.Insert(ProjectId, datasetId, tableId, row, options),
                client => new BigqueryTable(client, GetTable(reference)).Insert(row, options));
        }
Exemplo n.º 22
0
    public bool CreacionCliente(string nombre, string Rut, double Margen, string Direccion, string CodRegion, string CodComuna, bool PrecioxM2, string tratoDiasEntrega)
    {
        int       dias = Convert.ToInt32(tratoDiasEntrega);
        Hashtable Ht   = new Hashtable()
        {
            { "MARGEN", Margen },
            { "RUT", Rut },
            { "TIPOXLSDVH", 1 },
            { "ECOMRPROPIO", 0 },
            { "ESPRECIOXM2", PrecioxM2 },
            { "DIRECCION", Direccion },
            { "COD_COMUNA", CodComuna },
            { "COD_REGION", CodRegion },
            { "TRATODIASENTREGA", dias },
            { "ESTADO", true }
        };
        InsertRow insert = new InsertRow("PLABAL", "ECOM_MAEMP", Ht);

        return(insert.Insertado);
    }
Exemplo n.º 23
0
        public void Save()
        {
            if (Changed)
            {
                if (ID >= 0)
                {
                    DBInterface.CommandText = "UPDATE sellcontroller.contact SET value = @content, description = @desc WHERE idContact = @id;";
                    DBInterface.AddParameter("@content", MySql.Data.MySqlClient.MySqlDbType.String, Content);
                    DBInterface.AddParameter("@desc", MySql.Data.MySqlClient.MySqlDbType.String, Description);
                    DBInterface.AddParameter("@id", MySql.Data.MySqlClient.MySqlDbType.Int32, ID);
                    DBInterface.ExecuteTransaction();

                    if (Updated != null)
                    {
                        Updated(this, new DBEventArgs()
                        {
                            ForceUpdate = false
                        });
                    }
                }
                else
                {
                    InsertRow insertRow = new InsertRow("contact");
                    insertRow.Add("idTypeContact", MySql.Data.MySqlClient.MySqlDbType.Int32, ContactTypeID());
                    insertRow.Add("idPerson", MySql.Data.MySqlClient.MySqlDbType.String, person.ID);
                    insertRow.Add("value", MySql.Data.MySqlClient.MySqlDbType.String, Content);
                    insertRow.Add("description", MySql.Data.MySqlClient.MySqlDbType.String, Description);
                    insertRow.Execute();

                    if (Updated != null)
                    {
                        Updated(this, new DBEventArgs()
                        {
                            ForceUpdate = true
                        });
                    }
                }

                Changed = false;
            }
        }
Exemplo n.º 24
0
        public void AddNewUser(string FullName, string Name, bool IsAdmin)
        {
            if ((role.RoleString == "admin") && (FullName != null) && (FullName != string.Empty) && (Name != null) && (Name != string.Empty))
            {
                string pass = "******";

                int IsAdminInt = 0;
                if (IsAdmin)
                {
                    IsAdminInt = 1;
                }

                InsertRow insertRow = new InsertRow("user");
                insertRow.Add("login", MySql.Data.MySqlClient.MySqlDbType.String, Name);
                insertRow.Add("Name", MySql.Data.MySqlClient.MySqlDbType.String, FullName);
                insertRow.Add("isAdminRole", MySql.Data.MySqlClient.MySqlDbType.Int32, IsAdminInt);
                insertRow.Add("hashcode", MySql.Data.MySqlClient.MySqlDbType.String, PassHash(pass));

                insertRow.Execute();
            }
        }
Exemplo n.º 25
0
        public void Save()
        {
            if (Changed)
            {
                if (ID >= 0)
                {
                    DBInterface.CommandText = "UPDATE `sellcontroller`.`contact` SET `value` = @content WHERE `idContact` = @id;";
                    DBInterface.AddParameter("@content", MySql.Data.MySqlClient.MySqlDbType.String, Content);
                    DBInterface.AddParameter("@id", MySql.Data.MySqlClient.MySqlDbType.Int32, ID);
                    DBInterface.ExecuteTransaction();

                    if (Updated != null)
                    {
                        Updated(this, new DBEventArgs()
                        {
                            ForceUpdate = false
                        });
                    }
                }
                else
                {
                    InsertRow insertRow = new InsertRow("contact", "idContact");
                    insertRow.Add("value", MySql.Data.MySqlClient.MySqlDbType.String, Content);
                    insertRow.Execute();

                    if (Updated != null)
                    {
                        Updated(this, new DBEventArgs()
                        {
                            ForceUpdate = true
                        });
                    }
                }

                Changed = false;
            }
        }
Exemplo n.º 26
0
        public TypeContextMenu(VisualizerTable table, TypeChanged typeChanged, AVGPRStateChanged avgprChanged, Action processCopy, InsertRow insertRow)
        {
            _table = table;

            var typeItems = ((VariableType[])Enum.GetValues(typeof(VariableType)))
                            .Select(type => new MenuItem(type.ToString(), (s, e) => typeChanged(_currentRow, type)));

            var fgColor = new MenuItem("Font Color", new[]
            {
                new MenuItem("Green", (s, e) => _table.ApplyRowHighlight(_currentRow, changeFg: DataHighlightColor.Green)),
                new MenuItem("Red", (s, e) => _table.ApplyRowHighlight(_currentRow, changeFg: DataHighlightColor.Red)),
                new MenuItem("Blue", (s, e) => _table.ApplyRowHighlight(_currentRow, changeFg: DataHighlightColor.Blue)),
                new MenuItem("None", (s, e) => _table.ApplyRowHighlight(_currentRow, changeFg: DataHighlightColor.None))
            });
            var bgColor = new MenuItem("Background Color", new[]
            {
                new MenuItem("Green", (s, e) => _table.ApplyRowHighlight(_currentRow, changeBg: DataHighlightColor.Green)),
                new MenuItem("Red", (s, e) => _table.ApplyRowHighlight(_currentRow, changeBg: DataHighlightColor.Red)),
                new MenuItem("Blue", (s, e) => _table.ApplyRowHighlight(_currentRow, changeBg: DataHighlightColor.Blue)),
                new MenuItem("None", (s, e) => _table.ApplyRowHighlight(_currentRow, changeBg: DataHighlightColor.None))
            });

            var insertRowBefore = new MenuItem("Insert Row Before", (s, e) => insertRow(_currentRow, false));
            var insertRowAfter  = new MenuItem("Insert Row After", (s, e) => insertRow(_currentRow, true));

            _avgprButton = new MenuItem("AVGPR", (s, e) =>
            {
                _avgprButton.Checked = !_avgprButton.Checked;
                avgprChanged(_currentRow, _avgprButton.Checked);
            });

            var copy = new MenuItem("Copy", (s, e) => processCopy());

            var menuItems = typeItems.Concat(new[]
            {
                new MenuItem("-"),
                fgColor,
                bgColor,
                new MenuItem("-"),
                copy,
                new MenuItem("-"),
                insertRowBefore,
                insertRowAfter
                //_avgprButton
            });

            _menu = new ContextMenu(menuItems.ToArray());
        }
Exemplo n.º 27
0
        public void InsertId()
        {
            var row = new InsertRow("id");

            Assert.Equal("id", row.InsertId);
        }
Exemplo n.º 28
0
        public void Save()
        {
            if (Changed)
            {
                if (ID >= 0)
                {
                    DBInterface.CommandText = "update passport set " +
                                              "ownerName = @name, " +
                                              "ownerSurname = @surname, " +
                                              "number = @number, " +
                                              "expireDate = @date, " +
                                              "note = @note, " +
                                              "idCitizen = @idCitizen, " +
                                              "idCountry = @idCountry " +
                                              "where idPassport = @id;";

                    DBInterface.AddParameter("@id", MySql.Data.MySqlClient.MySqlDbType.Int32, ID);
                    DBInterface.AddParameter("@name", MySql.Data.MySqlClient.MySqlDbType.String, PersonName);
                    DBInterface.AddParameter("@surname", MySql.Data.MySqlClient.MySqlDbType.String, PersonSurname);
                    DBInterface.AddParameter("@number", MySql.Data.MySqlClient.MySqlDbType.String, SerialNumber);
                    DBInterface.AddParameter("@date", MySql.Data.MySqlClient.MySqlDbType.DateTime, ValidTill);
                    DBInterface.AddParameter("@note", MySql.Data.MySqlClient.MySqlDbType.String, Description);

                    if (Citizen != null)
                    {
                        DBInterface.AddParameter("@idCitizen", MySql.Data.MySqlClient.MySqlDbType.Int32, Citizen.ID);
                    }

                    if (CountryOfEmmitation != null)
                    {
                        DBInterface.AddParameter("@idCountry", MySql.Data.MySqlClient.MySqlDbType.Int32, CountryOfEmmitation.ID);
                    }

                    DBInterface.ExecuteTransaction();

                    if (Updated != null)
                    {
                        Updated(this, new DBEventArgs()
                        {
                            ForceUpdate = false
                        });
                    }
                }
                else
                {
                    InsertRow insertRow = new InsertRow("passport");

                    insertRow.Add("ownerName", MySql.Data.MySqlClient.MySqlDbType.String, PersonName);
                    insertRow.Add("ownerSurname", MySql.Data.MySqlClient.MySqlDbType.String, PersonSurname);
                    insertRow.Add("number", MySql.Data.MySqlClient.MySqlDbType.String, SerialNumber);
                    insertRow.Add("expireDate", MySql.Data.MySqlClient.MySqlDbType.DateTime, ValidTill);
                    insertRow.Add("note", MySql.Data.MySqlClient.MySqlDbType.String, Description);

                    if (Citizen != null)
                    {
                        insertRow.Add("idCitizen", MySql.Data.MySqlClient.MySqlDbType.Int32, Citizen.ID);
                    }

                    if (CountryOfEmmitation != null)
                    {
                        insertRow.Add("idCountry", MySql.Data.MySqlClient.MySqlDbType.Int32, CountryOfEmmitation.ID);
                    }

                    insertRow.Add("isActive", MySql.Data.MySqlClient.MySqlDbType.Int32, 1);
                    insertRow.Add("idPeople", MySql.Data.MySqlClient.MySqlDbType.Int32, person.PersonID);

                    insertRow.Execute();

                    if (Updated != null)
                    {
                        Updated(this, new DBEventArgs()
                        {
                            ForceUpdate = true
                        });
                    }
                }

                Changed = false;
            }
        }