/// <summary> /// [To be supplied.] /// </summary> public void Update() { if (!this.recordWasLoadedFromDB) { throw new ArgumentException("No record was loaded from the database. No update is possible."); } bool ChangesHaveBeenMade = false; ChangesHaveBeenMade = (ChangesHaveBeenMade || col_TitleWasUpdated); if (!ChangesHaveBeenMade) { return; } bool alreadyOpened = false; Params.spU_Title Param = new Params.spU_Title(true); Param.CommandTimeOut = this.updateCommandTimeOut; switch (this.lastKnownConnectionType) { case Bob.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case Bob.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open); break; case Bob.DataClasses.ConnectionType.SqlTransaction: Param.SetUpConnection(this.sqlTransaction); break; } Param.Param_TitleId = this.col_TitleId; if (this.col_TitleWasUpdated) { Param.Param_Title = this.col_Title; Param.Param_ConsiderNull_Title = true; } else { Param.Param_Title = SqlString.Null; Param.Param_ConsiderNull_Title = false; } SPs.spU_Title Sp = new SPs.spU_Title(false); if (Sp.Execute(ref Param)) { this.col_TitleWasUpdated = false; } else { throw new Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.Title", "Update"); } CloseConnection(Sp.Connection, alreadyOpened); }
private void UpdateRecordInDatabase() { Params.spU_Title Param = new Params.spU_Title(false); switch (this.lastKnownConnectionType) { case Bob.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case Bob.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); break; } Param.Param_TitleId = this.currentID; if (Control_Title.Text.Trim() != String.Empty) { Param.Param_Title = (System.Data.SqlTypes.SqlString)Control_Title.GetSqlTypesValue; } SPs.spU_Title SP = new SPs.spU_Title(false); if (SP.Execute(ref Param)) { this.parameter = Param; this.errorHasOccured = false; } else { this.errorHasOccured = true; if (Param.SqlException != null && Param.SqlException.Number == 2627) { MessageBox.Show(this, "Unable to update this record:\r\n\r\n" + Param.SqlException.Message, "Error"); } else { throw new Bob.DataClasses.CustomException(Param, "Bob.Windows.Forms.WinForm_Title", "UpdateRecordInDatabase"); } } }