private void UpdateRecordInDatabase() { Params.spU_tblProduct Param = new Params.spU_tblProduct(false); switch (this.lastKnownConnectionType) { case OlymarsDemo.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case OlymarsDemo.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); break; } Param.Param_Pro_GuidID = this.currentID; if (Control_Pro_StrName.Text.Trim() != String.Empty) { Param.Param_Pro_StrName = (System.Data.SqlTypes.SqlString)Control_Pro_StrName.GetSqlTypesValue; } if (Control_Pro_CurPrice.Text.Trim() != String.Empty) { Param.Param_Pro_CurPrice = (System.Data.SqlTypes.SqlMoney)Control_Pro_CurPrice.GetSqlTypesValue; } if (Control_Pro_LngCategoryID.SelectedIndex != -1) { Param.Param_Pro_LngCategoryID = (System.Int32)Control_Pro_LngCategoryID.SelectedValue; } SPs.spU_tblProduct SP = new SPs.spU_tblProduct(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 OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.Windows.Forms.WinForm_tblProduct", "UpdateRecordInDatabase"); } } }
private void UpdateRecordInDatabase() { Params.spU_tblCustomer Param = new Params.spU_tblCustomer(false); switch (this.lastKnownConnectionType) { case OlymarsDemo.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case OlymarsDemo.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); break; } Param.Param_Cus_LngID = this.currentID; if (Control_Cus_StrLastName.Text.Trim() != String.Empty) { Param.Param_Cus_StrLastName = (System.Data.SqlTypes.SqlString)Control_Cus_StrLastName.GetSqlTypesValue; } if (Control_Cus_StrFirstName.Text.Trim() != String.Empty) { Param.Param_Cus_StrFirstName = (System.Data.SqlTypes.SqlString)Control_Cus_StrFirstName.GetSqlTypesValue; } if (Control_Cus_StrEmail.Text.Trim() != String.Empty) { Param.Param_Cus_StrEmail = (System.Data.SqlTypes.SqlString)Control_Cus_StrEmail.GetSqlTypesValue; } SPs.spU_tblCustomer SP = new SPs.spU_tblCustomer(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 OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.Windows.Forms.WinForm_tblCustomer", "UpdateRecordInDatabase"); } } }
private void AddRecordInDatabase() { Params.spI_tblOrder Param = new Params.spI_tblOrder(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_Ord_DatOrderedOn.Text.Trim() != String.Empty) { Param.Param_Ord_DatOrderedOn = (System.Data.SqlTypes.SqlDateTime)Control_Ord_DatOrderedOn.GetSqlTypesValue; } if (Control_Ord_LngCustomerID.SelectedIndex != -1) { Param.Param_Ord_LngCustomerID = (System.Int32)Control_Ord_LngCustomerID.SelectedValue; } if (Control_Ord_CurTotal.Text.Trim() != String.Empty) { Param.Param_Ord_CurTotal = (System.Data.SqlTypes.SqlMoney)Control_Ord_CurTotal.GetSqlTypesValue; } SPs.spI_tblOrder SP = new SPs.spI_tblOrder(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_tblOrder", "AddRecordInDatabase"); } } }