public void Save() { if (Changed) { int countryID; int unionID; GetTargetCountryOrUnion(out countryID, out unionID); if (ID >= 0) { DBInterface.StoredProcedure("visa_update"); DBInterface.AddParameter("@inVisa", MySql.Data.MySqlClient.MySqlDbType.Int32, ID); DBInterface.AddParameter("@inIdPassport", MySql.Data.MySqlClient.MySqlDbType.Int32, PassportID); DBInterface.AddParameter("@inName", MySql.Data.MySqlClient.MySqlDbType.String, OwnerName); DBInterface.AddParameter("@inVisaNumber", MySql.Data.MySqlClient.MySqlDbType.String, Number); DBInterface.AddParameter("@inDateOn", MySql.Data.MySqlClient.MySqlDbType.DateTime, DateApproved); DBInterface.AddParameter("@indateFrom", MySql.Data.MySqlClient.MySqlDbType.DateTime, ValidFrom); DBInterface.AddParameter("@inDateUntil", MySql.Data.MySqlClient.MySqlDbType.DateTime, ValidTill); DBInterface.AddIdParameter("@inIdCountry", countryID); DBInterface.AddIdParameter("@inIdCountryUnion", unionID); DBInterface.AddIdParameter("@inIdCountryEsquire", CountryOfEmmitationID); DBInterface.AddParameter("@inTypeVisa", MySql.Data.MySqlClient.MySqlDbType.String, VizaType); DBInterface.AddParameter("@inEntriesNumber", MySql.Data.MySqlClient.MySqlDbType.Int32, EntriesNumber); DBInterface.AddParameter("@inDaysCount", MySql.Data.MySqlClient.MySqlDbType.Int32, DaysCount); DBInterface.AddParameter("@inUsedDays", MySql.Data.MySqlClient.MySqlDbType.Int32, DaysUsed); DBInterface.AddParameter("@inIssuedIn", MySql.Data.MySqlClient.MySqlDbType.String, Issued); DBInterface.AddParameter("@inNote", MySql.Data.MySqlClient.MySqlDbType.String, Description); DBInterface.AddParameter("@inIdDocument", MySql.Data.MySqlClient.MySqlDbType.Int32, DBNull.Value); DBInterface.ExecuteTransaction(); if (Updated != null) { Updated(this, new DBEventArgs() { ForceUpdate = false }); } } else { DBInterface.StoredProcedure("visa_insert"); DBInterface.AddOutParameter("@outIdVisa", MySql.Data.MySqlClient.MySqlDbType.Int32); DBInterface.AddParameter("@inIdPassport", MySql.Data.MySqlClient.MySqlDbType.Int32, PassportID); DBInterface.AddParameter("@inName", MySql.Data.MySqlClient.MySqlDbType.String, OwnerName); DBInterface.AddParameter("@inVisaNumber", MySql.Data.MySqlClient.MySqlDbType.String, Number); DBInterface.AddParameter("@inDateOn", MySql.Data.MySqlClient.MySqlDbType.DateTime, DateApproved); DBInterface.AddParameter("@indateFrom", MySql.Data.MySqlClient.MySqlDbType.DateTime, ValidFrom); DBInterface.AddParameter("@inDateUntil", MySql.Data.MySqlClient.MySqlDbType.DateTime, ValidTill); DBInterface.AddIdParameter("@inIdCountry", countryID); DBInterface.AddIdParameter("@inIdCountryUnion", unionID); DBInterface.AddIdParameter("@inIdCountryEsquire", CountryOfEmmitationID); DBInterface.AddParameter("@inTypeVisa", MySql.Data.MySqlClient.MySqlDbType.String, VizaType); DBInterface.AddParameter("@inEntriesNumber", MySql.Data.MySqlClient.MySqlDbType.Int32, EntriesNumber); DBInterface.AddParameter("@inDaysCount", MySql.Data.MySqlClient.MySqlDbType.Int32, DaysCount); DBInterface.AddParameter("@inUsedDays", MySql.Data.MySqlClient.MySqlDbType.Int32, DaysUsed); DBInterface.AddParameter("@inIssuedIn", MySql.Data.MySqlClient.MySqlDbType.String, Issued); DBInterface.AddParameter("@inNote", MySql.Data.MySqlClient.MySqlDbType.String, Description); DBInterface.AddParameter("@inIdDocument", MySql.Data.MySqlClient.MySqlDbType.Int32, DBNull.Value); DBInterface.ExecuteTransaction(); ID = DBInterface.GetOutParameterInt("@outIdVisa"); if (Updated != null) { Updated(this, new DBEventArgs() { ForceUpdate = true }); } } Changed = false; } }