public HPS.BLL.BLLCompanyMobile_T SelectByPrimaryKey(HPS.BLL.BLLCompanyMobile_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_CompanyMobile_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter CompanyMobileID_int = new SqlParameter(); CompanyMobileID_int.ParameterName = "@CompanyMobileID_int"; CompanyMobileID_int.SqlDbType = SqlDbType.Int; CompanyMobileID_int.Direction = ParameterDirection.Input; CompanyMobileID_int.IsNullable = false; CompanyMobileID_int.Value = businessObjectKey.CompanyMobileID_int; this.Command.Parameters.Add(CompanyMobileID_int); if (ControlConnection) { this.BeginTransaction(); } IDataReader dataReader = this.Command.ExecuteReader(); HPS.BLL.BLLCompanyMobile_T businessObject = new HPS.BLL.BLLCompanyMobile_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.BLLCompanyMobile_T> PopulateObjectsFromReader(IDataReader dataReader) { List <HPS.BLL.BLLCompanyMobile_T> list = new List <HPS.BLL.BLLCompanyMobile_T>(); while (dataReader.Read()) { HPS.BLL.BLLCompanyMobile_T businessObject = new HPS.BLL.BLLCompanyMobile_T(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
protected override void ShowForm() { HPS.BLL.BLLCompanyMobile_TFactory CompanyMobileFactory = new HPS.BLL.BLLCompanyMobile_TFactory(); HPS.BLL.BLLCompanyMobile_T CompanyMobileEntity = CompanyMobileFactory.GetBy((HPS.BLL.BLLCompanyMobile_TKeys)Key); if (CompanyMobileEntity == null) { throw new HPS.Exceptions.CompanyMobileNotFound(); } MobileNumber_nvcTextBox.Text = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(CompanyMobileEntity.MobileNumber_nvc, TypeCode.String)); FirstName_nvcTextBox.Text = (string)Hepsa.Core.Common.PersentationController.GetEntityValue(CompanyMobileEntity.FirstName_nvc, TypeCode.String); LastName_nvcTextBox.Text = (string)Hepsa.Core.Common.PersentationController.GetEntityValue(CompanyMobileEntity.LastName_nvc, TypeCode.String); Active_bitCheckBox.Checked = (bool)Hepsa.Core.Common.PersentationController.GetEntityValue(CompanyMobileEntity.Active_bit, TypeCode.Boolean); }
public void Insert(HPS.BLL.BLLCompanyMobile_T businessObject) { try { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueCompanyMobileID_int") == false) { throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString()); } _dataObject.Insert(businessObject); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
public void Update(HPS.BLL.BLLCompanyMobile_T businessObject, HPS.BLL.BLLCompanyMobile_TKeys businessObjectKey) { try { List <string> ExceptList = new List <string>(); if (businessObject.CompanyMobileID_int == businessObjectKey.CompanyMobileID_int) { ExceptList.Add("UniqueCompanyMobileID_int"); } if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, ExceptList.ToArray()) == 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.BLLCompanyMobile_TFactory CompanyMobileFactory = new HPS.BLL.BLLCompanyMobile_TFactory(); try { HPS.BLL.BLLCompanyMobile_T CompanyMobileEntity = CompanyMobileFactory.GetBy((HPS.BLL.BLLCompanyMobile_TKeys)Key); if (CompanyMobileEntity == null) { throw new HPS.Exceptions.CompanyMobileNotFound(); } CompanyMobileEntity.MobileNumber_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(MobileNumber_nvcTextBox.Text, TypeCode.String).ToString(); CompanyMobileEntity.FirstName_nvc = (string)Hepsa.Core.Common.PersentationController.GetEntityValue(FirstName_nvcTextBox.Text, TypeCode.String); CompanyMobileEntity.LastName_nvc = (string)Hepsa.Core.Common.PersentationController.GetEntityValue(LastName_nvcTextBox.Text, TypeCode.String); CompanyMobileEntity.Active_bit = (bool)Hepsa.Core.Common.PersentationController.GetEntityValue(Active_bitCheckBox.Checked, TypeCode.Boolean); CompanyMobileFactory.BeginProc(); CompanyMobileFactory.Update(CompanyMobileEntity, (HPS.BLL.BLLCompanyMobile_TKeys)Key); CompanyMobileFactory.CommitProc(); if (DataTable != null) { DataRow[] dr = DataTable.Select(HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.CompanyMobileID_int.ToString() + "='" + ((HPS.BLL.BLLCompanyMobile_TKeys)Key).CompanyMobileID_int.ToString() + "'"); if (dr.Length > 0) { dr[0][HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.MobileNumber_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CompanyMobileEntity.MobileNumber_nvc, TypeCode.String); dr[0][HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.FirstName_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CompanyMobileEntity.FirstName_nvc, TypeCode.String); dr[0][HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.LastName_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CompanyMobileEntity.LastName_nvc, TypeCode.String); dr[0][HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.Active_bit.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CompanyMobileEntity.Active_bit, TypeCode.Boolean); } DataTable.AcceptChanges(); } } catch (System.Exception ex) { CompanyMobileFactory.RollBackProc(); throw ex; } }
protected override void Insert() { HPS.BLL.BLLCompanyMobile_TFactory CompanyMobileFactory = new HPS.BLL.BLLCompanyMobile_TFactory(); try { HPS.BLL.BLLCompanyMobile_T CompanyMobileEntity = new HPS.BLL.BLLCompanyMobile_T(); CompanyMobileEntity.MobileNumber_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(MobileNumber_nvcTextBox.Text, TypeCode.String).ToString(); CompanyMobileEntity.FirstName_nvc = (string)Hepsa.Core.Common.PersentationController.GetEntityValue(FirstName_nvcTextBox.Text, TypeCode.String); CompanyMobileEntity.LastName_nvc = (string)Hepsa.Core.Common.PersentationController.GetEntityValue(LastName_nvcTextBox.Text, TypeCode.String); CompanyMobileEntity.Active_bit = (bool)Hepsa.Core.Common.PersentationController.GetEntityValue(Active_bitCheckBox.Checked, TypeCode.Boolean); CompanyMobileEntity.CompanyID_int = this._CompanyID_int; CompanyMobileFactory.BeginProc(); CompanyMobileFactory.Insert(CompanyMobileEntity); CompanyMobileFactory.CommitProc(); if (DataTable != null) { DataRow dr = this.DataTable.NewRow(); dr[HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.CompanyMobileID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CompanyMobileEntity.CompanyMobileID_int, TypeCode.Int32); dr[HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.MobileNumber_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CompanyMobileEntity.MobileNumber_nvc, TypeCode.String); dr[HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.FirstName_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CompanyMobileEntity.FirstName_nvc, TypeCode.String); dr[HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.LastName_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CompanyMobileEntity.LastName_nvc, TypeCode.String); dr[HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.Active_bit.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CompanyMobileEntity.Active_bit, TypeCode.Boolean); DataTable.Rows.Add(dr); DataTable.AcceptChanges(); } this.ClearForm(this); } catch (System.Exception ex) { CompanyMobileFactory.RollBackProc(); throw ex; } }
public void PopulateBusinessObjectFromReader(HPS.BLL.BLLCompanyMobile_T businessObject, IDataReader dataReader) { businessObject.CompanyMobileID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.CompanyMobileID_int.ToString())); businessObject.CompanyID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.CompanyID_int.ToString())); businessObject.MobileNumber_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.MobileNumber_nvc.ToString())); businessObject.Active_bit = dataReader.GetBoolean(dataReader.GetOrdinal(HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.Active_bit.ToString())); if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.FirstName_nvc.ToString())) == false) { businessObject.FirstName_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.FirstName_nvc.ToString())); } else { businessObject.FirstName_nvc = String.Empty; } if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.LastName_nvc.ToString())) == false) { businessObject.LastName_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.BLLCompanyMobile_T.CompanyMobile_TField.LastName_nvc.ToString())); } else { businessObject.LastName_nvc = String.Empty; } }
public void Insert(HPS.BLL.BLLCompanyMobile_T businessObject) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_CompanyMobile_T_Add]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter CompanyMobileID_int = new SqlParameter(); CompanyMobileID_int.ParameterName = "@CompanyMobileID_int"; CompanyMobileID_int.SqlDbType = SqlDbType.Int; CompanyMobileID_int.Direction = ParameterDirection.Output; CompanyMobileID_int.IsNullable = false; CompanyMobileID_int.Value = businessObject.CompanyMobileID_int; this.Command.Parameters.Add(CompanyMobileID_int); SqlParameter CompanyID_int = new SqlParameter(); CompanyID_int.ParameterName = "@CompanyID_int"; CompanyID_int.SqlDbType = SqlDbType.Int; CompanyID_int.Direction = ParameterDirection.Input; CompanyID_int.IsNullable = false; CompanyID_int.Value = businessObject.CompanyID_int; this.Command.Parameters.Add(CompanyID_int); SqlParameter MobileNumber_nvc = new SqlParameter(); MobileNumber_nvc.ParameterName = "@MobileNumber_nvc"; MobileNumber_nvc.SqlDbType = SqlDbType.NVarChar; MobileNumber_nvc.Direction = ParameterDirection.Input; MobileNumber_nvc.IsNullable = false; MobileNumber_nvc.Value = businessObject.MobileNumber_nvc; this.Command.Parameters.Add(MobileNumber_nvc); SqlParameter FirstName_nvcParam = new SqlParameter(); FirstName_nvcParam.ParameterName = "@FirstName_nvc"; FirstName_nvcParam.SqlDbType = SqlDbType.NVarChar; FirstName_nvcParam.Direction = ParameterDirection.Input; FirstName_nvcParam.IsNullable = true; if (string.IsNullOrEmpty(businessObject.FirstName_nvc)) { FirstName_nvcParam.Value = DBNull.Value; } else { FirstName_nvcParam.Value = businessObject.FirstName_nvc; } this.Command.Parameters.Add(FirstName_nvcParam); SqlParameter LastName_nvcParam = new SqlParameter(); LastName_nvcParam.ParameterName = "@LastName_nvc"; LastName_nvcParam.SqlDbType = SqlDbType.NVarChar; LastName_nvcParam.Direction = ParameterDirection.Input; LastName_nvcParam.IsNullable = true; if (string.IsNullOrEmpty(businessObject.LastName_nvc)) { LastName_nvcParam.Value = DBNull.Value; } else { LastName_nvcParam.Value = businessObject.LastName_nvc; } this.Command.Parameters.Add(LastName_nvcParam); SqlParameter Active_bitParam = new SqlParameter(); Active_bitParam.ParameterName = "@Active_bit"; Active_bitParam.SqlDbType = SqlDbType.Bit; Active_bitParam.Direction = ParameterDirection.Input; Active_bitParam.IsNullable = false; Active_bitParam.Value = businessObject.Active_bit; this.Command.Parameters.Add(Active_bitParam); if (ControlConnection) { this.BeginTransaction(); } this.Command.ExecuteNonQuery(); businessObject.CompanyMobileID_int = (Int32)(this.Command.Parameters["@CompanyMobileID_int"].Value); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }