private void AddRecordInDatabase() { Params.spI_tblOrderItem Param = new Params.spI_tblOrderItem(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_Oit_GuidOrderID.SelectedIndex != -1) { Param.Param_Oit_GuidOrderID = (System.Guid)Control_Oit_GuidOrderID.SelectedValue; } if (Control_Oit_GuidProductID.SelectedIndex != -1) { Param.Param_Oit_GuidProductID = (System.Guid)Control_Oit_GuidProductID.SelectedValue; } if (Control_Oit_LngAmount.Text.Trim() != String.Empty) { Param.Param_Oit_LngAmount = (System.Data.SqlTypes.SqlInt32)Control_Oit_LngAmount.GetSqlTypesValue; } SPs.spI_tblOrderItem SP = new SPs.spI_tblOrderItem(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_tblOrderItem", "AddRecordInDatabase"); } } }
public void Execute(WSGuid Oit_GuidID, WSGuid Oit_GuidOrderID, WSGuid Oit_GuidProductID, WSInt32 Oit_LngAmount) { Params.spI_tblOrderItem param = new Params.spI_tblOrderItem(true); param.SetUpConnection(string.Empty); if (Oit_GuidID == null || Oit_GuidID.UseNull) { param.Param_Oit_GuidID = SqlGuid.Null; } else if (!Oit_GuidID.UseDefault) { param.Param_Oit_GuidID = Oit_GuidID.Value; } if (Oit_GuidOrderID == null || Oit_GuidOrderID.UseNull) { param.Param_Oit_GuidOrderID = SqlGuid.Null; } else if (!Oit_GuidOrderID.UseDefault) { param.Param_Oit_GuidOrderID = Oit_GuidOrderID.Value; } if (Oit_GuidProductID == null || Oit_GuidProductID.UseNull) { param.Param_Oit_GuidProductID = SqlGuid.Null; } else if (!Oit_GuidProductID.UseDefault) { param.Param_Oit_GuidProductID = Oit_GuidProductID.Value; } if (Oit_LngAmount == null || Oit_LngAmount.UseNull) { param.Param_Oit_LngAmount = SqlInt32.Null; } else if (!Oit_LngAmount.UseDefault) { param.Param_Oit_LngAmount = Oit_LngAmount.Value; } using (SPs.spI_tblOrderItem sp = new SPs.spI_tblOrderItem(true)) { sp.Execute(ref param); param.Dispose(); } }
public Guid Add_tblOrderItem_Record(Tables.tblOrderItem_Record record) { Params.spI_tblOrderItem param = new Params.spI_tblOrderItem(true); param.SetUpConnection(string.Empty); if (record.Col_Oit_GuidOrderID == null || record.Col_Oit_GuidOrderID.UseNull) { param.Param_Oit_GuidOrderID = SqlGuid.Null; } else if (!record.Col_Oit_GuidOrderID.UseDefault) { param.Param_Oit_GuidOrderID = record.Col_Oit_GuidOrderID.Value; } if (record.Col_Oit_GuidProductID == null || record.Col_Oit_GuidProductID.UseNull) { param.Param_Oit_GuidProductID = SqlGuid.Null; } else if (!record.Col_Oit_GuidProductID.UseDefault) { param.Param_Oit_GuidProductID = record.Col_Oit_GuidProductID.Value; } if (record.Col_Oit_LngAmount == null || record.Col_Oit_LngAmount.UseNull) { param.Param_Oit_LngAmount = SqlInt32.Null; } else if (!record.Col_Oit_LngAmount.UseDefault) { param.Param_Oit_LngAmount = record.Col_Oit_LngAmount.Value; } using (SPs.spI_tblOrderItem sp = new SPs.spI_tblOrderItem(true)) { sp.Execute(ref param); Guid id = param.Param_Oit_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) { tblOrderItem_Record recordToAdd = record as tblOrderItem_Record; if (recordToAdd == null) { throw new ArgumentException("Invalid record type. Must be 'OlymarsDemo.BusinessComponents.tblOrderItem_Record'.", "record"); } switch (this.parentType) { case tblOrderItem_CollectionParentType.Col_Oit_GuidOrderID: recordToAdd.Col_Oit_GuidOrderID = ((tblOrder_Record)this.parent).Col_Ord_GuidID; break; case tblOrderItem_CollectionParentType.Col_Oit_GuidProductID: recordToAdd.Col_Oit_GuidProductID = ((Product)this.parent).Col_Pro_GuidID; break; } bool alreadyOpened = false; Params.spI_tblOrderItem Param = new Params.spI_tblOrderItem(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_Oit_GuidID = recordToAdd.Col_Oit_GuidID; Param.Param_Oit_GuidOrderID = recordToAdd.Col_Oit_GuidOrderID; Param.Param_Oit_GuidProductID = recordToAdd.Col_Oit_GuidProductID; Param.Param_Oit_LngAmount = recordToAdd.Col_Oit_LngAmount; SPs.spI_tblOrderItem Sp = new SPs.spI_tblOrderItem(false); if (Sp.Execute(ref Param)) { tblOrderItem_Record newRecord = null; switch (this.lastKnownConnectionType) { case OlymarsDemo.DataClasses.ConnectionType.ConnectionString: newRecord = new tblOrderItem_Record(this.connectionString, Param.Param_Oit_GuidID); break; case OlymarsDemo.DataClasses.ConnectionType.SqlConnection: newRecord = new tblOrderItem_Record(this.sqlConnection, Param.Param_Oit_GuidID); break; case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction: newRecord = new tblOrderItem_Record(this.sqlTransaction, Param.Param_Oit_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.tblOrderItem_Collection", "Add"); } }
private void cmdUpdate_Click(object sender, System.EventArgs e) { if (!CheckValues()) { return; } if (Action == ActionEnum.Edit) { Params.spU_tblOrderItem Param = null; SPs.spU_tblOrderItem SP = null; Param = new Params.spU_tblOrderItem(); Param.SetUpConnection(ConnectionString); Param.Param_Oit_GuidID = CurrentID; Param.Param_Oit_GuidOrderID = new Guid(com_Oit_GuidOrderID.SelectedItem.Value); Param.Param_Oit_GuidProductID = new Guid(com_Oit_GuidProductID.SelectedItem.Value); if (txt_Oit_LngAmount.Text.Trim() != String.Empty) { Param.Param_Oit_LngAmount = new System.Data.SqlTypes.SqlInt32(System.Convert.ToInt32(txt_Oit_LngAmount.Text)); } SP = new SPs.spU_tblOrderItem(); if (SP.Execute(ref Param)) { if (ReturnURL.Visible) { Response.Redirect(String.Format("WebForm_tblOrderItem.aspx?Action=Edit&ID={0}&ReturnToUrl={1}&ReturnToDisplay={2}", CurrentID.ToString(), ReturnURL.NavigateUrl, ReturnURL.Text)); } else { Response.Redirect(String.Format("WebForm_tblOrderItem.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_tblOrderItem Param = null; SPs.spI_tblOrderItem SP = null; Param = new Params.spI_tblOrderItem(); Param.SetUpConnection(ConnectionString); Param.Param_Oit_GuidOrderID = new Guid(com_Oit_GuidOrderID.SelectedItem.Value); Param.Param_Oit_GuidProductID = new Guid(com_Oit_GuidProductID.SelectedItem.Value); if (txt_Oit_LngAmount.Text.Trim() != String.Empty) { Param.Param_Oit_LngAmount = new System.Data.SqlTypes.SqlInt32(System.Convert.ToInt32(txt_Oit_LngAmount.Text)); } SP = new SPs.spI_tblOrderItem(); if (SP.Execute(ref Param)) { if (ReturnURL.Visible) { Response.Redirect(String.Format("WebForm_tblOrderItem.aspx?Action=Edit&ID={0}&ReturnToUrl={1}&ReturnToDisplay={2}", Param.Param_Oit_GuidID.ToString(), ReturnURL.NavigateUrl, ReturnURL.Text)); } else { Response.Redirect(String.Format("WebForm_tblOrderItem.aspx?Action=Edit&ID={0}", Param.Param_Oit_GuidID.ToString())); } return; } else { if (Param.SqlException != null) { throw Param.SqlException; } if (Param.OtherException != null) { throw Param.OtherException; } } } }