public void Update(HPS.BLL.BillBLL.BLLBill_T businessObject, HPS.BLL.BillBLL.BLLBill_TKeys businessObjectKey) { try { if (businessObject.BillID_int == businessObjectKey.BillID_int) { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueBillID_int") == false) { throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString()); } } else { if (businessObject.IsValid() == false) { throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString()); } } _dataObject.Update(businessObject, businessObjectKey); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
protected override void Edit() { HPS.BLL.BillBLL.BLLBill_TFactory BillFactory = new HPS.BLL.BillBLL.BLLBill_TFactory(); try { HPS.BLL.BillBLL.BLLBill_T BillEntity = new HPS.BLL.BillBLL.BLLBill_T(); BillEntity.BillType_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(BillType_nvcTextBox.Text, TypeCode.String).ToString(); BillEntity.TrafficTypeID_int = (Nullable <Int32>)Hepsa.Core.Common.PersentationController.GetEntityValue(TrafficTypeID_intComboBox.SelectedValue, TypeCode.Int32); if (Hepsa.Core.Common.MessageBox.ConfirmMessage(HPS.Exceptions.ExceptionCs.EditMessage) == true) { BillFactory.BeginProc(); BillFactory.Update(BillEntity, (HPS.BLL.BillBLL.BLLBill_TKeys)Key); BillFactory.CommitProc(); if (DataTable != null) { DataRow[] dr = DataTable.Select(HPS.BLL.BillBLL.BLLBill_T.Bill_TField.BillID_int.ToString() + "='" + ((HPS.BLL.BillBLL.BLLBill_TKeys)Key).BillID_int.ToString() + "'"); if (dr.Length > 0) { dr[0][HPS.BLL.BillBLL.BLLBill_T.Bill_TField.BillType_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(BillEntity.BillType_nvc, TypeCode.String); dr[0]["TrafficTypeID_intTrafficType_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(TrafficTypeID_intComboBox); } DataTable.AcceptChanges(); } } } catch (Exception ex) { BillFactory.RollBackProc(); throw ex; } }
protected override void Insert() { HPS.BLL.BillBLL.BLLBill_TFactory BillFactory = new HPS.BLL.BillBLL.BLLBill_TFactory(); try { HPS.BLL.BillBLL.BLLBill_T BillEntity = new HPS.BLL.BillBLL.BLLBill_T(); BillEntity.BillType_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(BillType_nvcTextBox.Text, TypeCode.String).ToString(); BillEntity.TrafficTypeID_int = (Nullable <Int32>)Hepsa.Core.Common.PersentationController.GetEntityValue(TrafficTypeID_intComboBox.SelectedValue, TypeCode.Int32); BillFactory.BeginProc(); BillFactory.Insert(BillEntity); BillFactory.CommitProc(); if (DataTable != null) { DataRow dr = this.DataTable.NewRow(); dr[HPS.BLL.BillBLL.BLLBill_T.Bill_TField.BillID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(BillEntity.BillID_int, TypeCode.Int32); dr[HPS.BLL.BillBLL.BLLBill_T.Bill_TField.BillType_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(BillEntity.BillType_nvc, TypeCode.String); dr[HPS.BLL.BillBLL.BLLBill_T.Bill_TField.TrafficTypeID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(BillEntity.TrafficTypeID_int, TypeCode.Int32); dr["TrafficTypeID_intTrafficType_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(TrafficTypeID_intComboBox); DataTable.Rows.Add(dr); DataTable.AcceptChanges(); } this.ClearForm(this); } catch (Exception ex) { BillFactory.RollBackProc(); throw ex; } }
public HPS.BLL.BillBLL.BLLBill_T SelectByPrimaryKey(HPS.BLL.BillBLL.BLLBill_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_Bill_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try{ this.Command.Parameters.Clear(); SqlParameter BillID_int = new SqlParameter(); BillID_int.ParameterName = "@BillID_int"; BillID_int.SqlDbType = SqlDbType.Int; BillID_int.Direction = ParameterDirection.Input; BillID_int.IsNullable = false; BillID_int.Value = businessObjectKey.BillID_int; this.Command.Parameters.Add(BillID_int); if (ControlConnection) { this.BeginTransaction(); } IDataReader dataReader = this.Command.ExecuteReader(); HPS.BLL.BillBLL.BLLBill_T businessObject = new HPS.BLL.BillBLL.BLLBill_T(); if (dataReader.Read()) { PopulateBusinessObjectFromReader(businessObject, dataReader); } else { businessObject = null; } if (dataReader.IsClosed == false) { dataReader.Close(); } if (ControlConnection) { this.Commit(); } return(businessObject); } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }
public List <HPS.BLL.BillBLL.BLLBill_T> PopulateObjectsFromReader(IDataReader dataReader) { List <HPS.BLL.BillBLL.BLLBill_T> list = new List <HPS.BLL.BillBLL.BLLBill_T>(); while (dataReader.Read()) { HPS.BLL.BillBLL.BLLBill_T businessObject = new HPS.BLL.BillBLL.BLLBill_T(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
protected override void ShowForm() { this.FillCombo(); HPS.BLL.BillBLL.BLLBill_TFactory BillFactory = new HPS.BLL.BillBLL.BLLBill_TFactory(); HPS.BLL.BillBLL.BLLBill_T BillEntity = BillFactory.GetBy((HPS.BLL.BillBLL.BLLBill_TKeys)Key); if (BillEntity == null) { throw new HPS.Exceptions.BillNotFound(); } BillType_nvcTextBox.Text = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(BillEntity.BillType_nvc, TypeCode.String)); Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref TrafficTypeID_intComboBox, BillEntity.TrafficTypeID_int, TypeCode.Int32); }
public void PopulateBusinessObjectFromReader(HPS.BLL.BillBLL.BLLBill_T businessObject, IDataReader dataReader) { businessObject.BillID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.BillBLL.BLLBill_T.Bill_TField.BillID_int.ToString())); businessObject.BillType_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.BillBLL.BLLBill_T.Bill_TField.BillType_nvc.ToString())); if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.BillBLL.BLLBill_T.Bill_TField.TrafficTypeID_int.ToString())) == false) { businessObject.TrafficTypeID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.BillBLL.BLLBill_T.Bill_TField.TrafficTypeID_int.ToString())); } else { businessObject.TrafficTypeID_int = null; } }
public void Update(HPS.BLL.BillBLL.BLLBill_T businessObject, HPS.BLL.BillBLL.BLLBill_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_Bill_T_Update]"; this.Command.CommandType = CommandType.StoredProcedure; try{ this.Command.Parameters.Clear(); SqlParameter BillType_nvc = new SqlParameter(); BillType_nvc.ParameterName = "@BillType_nvc"; BillType_nvc.SqlDbType = SqlDbType.NVarChar; BillType_nvc.Direction = ParameterDirection.Input; BillType_nvc.IsNullable = false; BillType_nvc.Value = businessObject.BillType_nvc; this.Command.Parameters.Add(BillType_nvc); SqlParameter TrafficTypeID_int = new SqlParameter(); TrafficTypeID_int.ParameterName = "@TrafficTypeID_int"; TrafficTypeID_int.SqlDbType = SqlDbType.Int; TrafficTypeID_int.Direction = ParameterDirection.Input; TrafficTypeID_int.IsNullable = false; if (businessObject.TrafficTypeID_int.HasValue == false) { TrafficTypeID_int.Value = DBNull.Value; } else { TrafficTypeID_int.Value = businessObject.TrafficTypeID_int; } this.Command.Parameters.Add(TrafficTypeID_int); SqlParameter pk_BillID_int = new SqlParameter(); pk_BillID_int.ParameterName = "@pk_BillID_int"; pk_BillID_int.SqlDbType = SqlDbType.Int; pk_BillID_int.Direction = ParameterDirection.Input; pk_BillID_int.IsNullable = false; pk_BillID_int.Value = businessObjectKey.BillID_int; this.Command.Parameters.Add(pk_BillID_int); if (ControlConnection) { this.BeginTransaction(); } this.Command.ExecuteNonQuery(); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }