public void Execute(WSGuid Sup_GuidID, WSString Sup_StrName) { Params.spI_tblSupplier param = new Params.spI_tblSupplier(true); param.SetUpConnection(string.Empty); if (Sup_GuidID == null || Sup_GuidID.UseNull) { param.Param_Sup_GuidID = SqlGuid.Null; } else if (!Sup_GuidID.UseDefault) { param.Param_Sup_GuidID = Sup_GuidID.Value; } if (Sup_StrName == null || Sup_StrName.UseNull) { param.Param_Sup_StrName = SqlString.Null; } else if (!Sup_StrName.UseDefault) { param.Param_Sup_StrName = Sup_StrName.Value; } using (SPs.spI_tblSupplier sp = new SPs.spI_tblSupplier(true)) { sp.Execute(ref param); param.Dispose(); } }
private void AddRecordInDatabase() { Params.spI_tblSupplier Param = new Params.spI_tblSupplier(false); switch (this.lastKnownConnectionType) { case OlymarsDemo.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case OlymarsDemo.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); break; } if (Control_Sup_StrName.Text.Trim() != String.Empty) { Param.Param_Sup_StrName = (System.Data.SqlTypes.SqlString)Control_Sup_StrName.GetSqlTypesValue; } SPs.spI_tblSupplier SP = new SPs.spI_tblSupplier(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 add this record:\r\n\r\n" + Param.SqlException.Message, "Error"); } else { throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.Windows.Forms.WinForm_tblSupplier", "AddRecordInDatabase"); } } }
public Guid Add_Supplier(Tables.Supplier record) { Params.spI_tblSupplier param = new Params.spI_tblSupplier(true); param.SetUpConnection(string.Empty); if (record.Col_Sup_StrName == null || record.Col_Sup_StrName.UseNull) { param.Param_Sup_StrName = SqlString.Null; } else if (!record.Col_Sup_StrName.UseDefault) { param.Param_Sup_StrName = record.Col_Sup_StrName.Value; } using (SPs.spI_tblSupplier sp = new SPs.spI_tblSupplier(true)) { sp.Execute(ref param); Guid id = param.Param_Sup_GuidID.Value; param.Dispose(); return(id); } }
/// <summary> /// [To be supplied.] /// </summary> /// <param name="record">[To be supplied.]</param> /// <returns>[To be supplied.]</returns> public IBusinessComponentRecord Add(IBusinessComponentRecord record) { Supplier recordToAdd = record as Supplier; if (recordToAdd == null) { throw new ArgumentException("Invalid record type. Must be 'OlymarsDemo.BusinessComponents.Supplier'.", "record"); } bool alreadyOpened = false; Params.spI_tblSupplier Param = new Params.spI_tblSupplier(true); Param.CommandTimeOut = this.insertCommandTimeOut; switch (this.lastKnownConnectionType) { case OlymarsDemo.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case OlymarsDemo.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open); break; case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction: Param.SetUpConnection(this.sqlTransaction); break; } Param.Param_Sup_GuidID = recordToAdd.Col_Sup_GuidID; Param.Param_Sup_StrName = recordToAdd.Col_Sup_StrName; SPs.spI_tblSupplier Sp = new SPs.spI_tblSupplier(false); if (Sp.Execute(ref Param)) { Supplier newRecord = null; switch (this.lastKnownConnectionType) { case OlymarsDemo.DataClasses.ConnectionType.ConnectionString: newRecord = new Supplier(this.connectionString, Param.Param_Sup_GuidID); break; case OlymarsDemo.DataClasses.ConnectionType.SqlConnection: newRecord = new Supplier(this.sqlConnection, Param.Param_Sup_GuidID); break; case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction: newRecord = new Supplier(this.sqlTransaction, Param.Param_Sup_GuidID); break; } CloseConnection(Sp.Connection, alreadyOpened); if (internalRecords != null) { internalRecords.Add(newRecord); } if (this.addedRecords == null) { this.addedRecords = new System.Collections.ArrayList(); } this.addedRecords.Add(newRecord); return(newRecord); } else { throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.Suppliers", "Add"); } }
private void cmdUpdate_Click(object sender, System.EventArgs e) { if (!CheckValues()) { return; } if (Action == ActionEnum.Edit) { Params.spU_tblSupplier Param = null; SPs.spU_tblSupplier SP = null; Param = new Params.spU_tblSupplier(); Param.SetUpConnection(ConnectionString); Param.Param_Sup_GuidID = CurrentID; if (txt_Sup_StrName.Text.Trim() != String.Empty) { Param.Param_Sup_StrName = new System.Data.SqlTypes.SqlString(txt_Sup_StrName.Text); } SP = new SPs.spU_tblSupplier(); if (SP.Execute(ref Param)) { if (ReturnURL.Visible) { Response.Redirect(String.Format("WebForm_tblSupplier.aspx?Action=Edit&ID={0}&ReturnToUrl={1}&ReturnToDisplay={2}", CurrentID.ToString(), ReturnURL.NavigateUrl, ReturnURL.Text)); } else { Response.Redirect(String.Format("WebForm_tblSupplier.aspx?Action=Edit&ID={0}", CurrentID.ToString())); } return; } else { if (Param.SqlException != null) { throw Param.SqlException; } if (Param.OtherException != null) { throw Param.OtherException; } } } else { Params.spI_tblSupplier Param = null; SPs.spI_tblSupplier SP = null; Param = new Params.spI_tblSupplier(); Param.SetUpConnection(ConnectionString); if (txt_Sup_StrName.Text.Trim() != String.Empty) { Param.Param_Sup_StrName = new System.Data.SqlTypes.SqlString(txt_Sup_StrName.Text); } SP = new SPs.spI_tblSupplier(); if (SP.Execute(ref Param)) { if (ReturnURL.Visible) { Response.Redirect(String.Format("WebForm_tblSupplier.aspx?Action=Edit&ID={0}&ReturnToUrl={1}&ReturnToDisplay={2}", Param.Param_Sup_GuidID.ToString(), ReturnURL.NavigateUrl, ReturnURL.Text)); } else { Response.Redirect(String.Format("WebForm_tblSupplier.aspx?Action=Edit&ID={0}", Param.Param_Sup_GuidID.ToString())); } return; } else { if (Param.SqlException != null) { throw Param.SqlException; } if (Param.OtherException != null) { throw Param.OtherException; } } } }