protected override void Insert() { HPS.BLL.CityBLL.BLLCity_TFactory CityFactory = new HPS.BLL.CityBLL.BLLCity_TFactory(); try { HPS.BLL.CityBLL.BLLCity_T CityEntity = new HPS.BLL.CityBLL.BLLCity_T(); CityEntity.CityCode_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(CityCode_nvcTextBox.Text, TypeCode.String).ToString(); CityEntity.City_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(City_nvcTextBox.Text, TypeCode.String).ToString(); CityEntity.TravelTime_int = (Nullable <Int32>)Hepsa.Core.Common.PersentationController.GetEntityValue(TravelTime_intNumericTextBox.NumericText, TypeCode.Int32); CityEntity.Active_bit = Active_bitCheckBox.Checked; CityFactory.BeginProc(); CityFactory.Insert(CityEntity); CityFactory.CommitProc(); if (DataTable != null) { DataRow dr = this.DataTable.NewRow(); dr[HPS.BLL.CityBLL.BLLCity_T.City_TField.CityID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CityEntity.CityID_int, TypeCode.Int32); dr[HPS.BLL.CityBLL.BLLCity_T.City_TField.CityCode_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CityEntity.CityCode_nvc, TypeCode.String); dr[HPS.BLL.CityBLL.BLLCity_T.City_TField.City_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CityEntity.City_nvc, TypeCode.String); dr[HPS.BLL.CityBLL.BLLCity_T.City_TField.TravelTime_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CityEntity.TravelTime_int, TypeCode.Int32); dr[HPS.BLL.CityBLL.BLLCity_T.City_TField.Active_bit.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CityEntity.Active_bit, TypeCode.Boolean); DataTable.Rows.Add(dr); DataTable.AcceptChanges(); } this.ClearForm(this); } catch (Exception ex) { CityFactory.RollBackProc(); throw ex; } }
public void Update(HPS.BLL.CityBLL.BLLCity_T businessObject, HPS.BLL.CityBLL.BLLCity_TKeys businessObjectKey) { try { if (businessObject.CityID_int == businessObjectKey.CityID_int) { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueCityID_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); } }
public HPS.BLL.CityBLL.BLLCity_T SelectByPrimaryKey(HPS.BLL.CityBLL.BLLCity_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_City_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter CityID_int = new SqlParameter(); CityID_int.ParameterName = "@CityID_int"; CityID_int.SqlDbType = SqlDbType.Int; CityID_int.Direction = ParameterDirection.Input; CityID_int.IsNullable = false; CityID_int.Value = businessObjectKey.CityID_int; this.Command.Parameters.Add(CityID_int); if (ControlConnection) { this.BeginTransaction(); } IDataReader dataReader = this.Command.ExecuteReader(); HPS.BLL.CityBLL.BLLCity_T businessObject = new HPS.BLL.CityBLL.BLLCity_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; } }
private void CityID_intComboBox_SelectionChangeCommitted(object sender, EventArgs e) { HPS.BLL.CityBLL.BLLCity_TFactory CityFactory = new HPS.BLL.CityBLL.BLLCity_TFactory(); HPS.BLL.CityBLL.BLLCity_TKeys CityKey = new HPS.BLL.CityBLL.BLLCity_TKeys(); CityKey.CityID_int = (Int32?)CityID_intComboBox.SelectedValue; HPS.BLL.CityBLL.BLLCity_T CityEntity = CityFactory.GetBy(CityKey); if (CityEntity != null && CityEntity.CityID_int != 0) { CityCode_nvcTextBox.Text = CityEntity.CityCode_nvc; } }
private void CityID_intNewButton_Click(object sender, EventArgs e) { HPS.Present.SearchForm.CitySearch frm = new HPS.Present.SearchForm.CitySearch(); frm.ShowDialog(); if (frm != null) { CityEntity = frm.SelectedCity; CityID_intComboBox.Text = CityEntity.City_nvc; } }
public List <HPS.BLL.CityBLL.BLLCity_T> PopulateObjectsFromReader(IDataReader dataReader) { List <HPS.BLL.CityBLL.BLLCity_T> list = new List <HPS.BLL.CityBLL.BLLCity_T>(); while (dataReader.Read()) { HPS.BLL.CityBLL.BLLCity_T businessObject = new HPS.BLL.CityBLL.BLLCity_T(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
protected override void ShowForm() { this.FillCombo(); HPS.BLL.CityBLL.BLLCity_TFactory CityFactory = new HPS.BLL.CityBLL.BLLCity_TFactory(); HPS.BLL.CityBLL.BLLCity_T CityEntity = CityFactory.GetBy((HPS.BLL.CityBLL.BLLCity_TKeys)Key); if (CityEntity == null) { throw new HPS.Exceptions.CityNotFound(); } CityCode_nvcTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(CityEntity.CityCode_nvc, TypeCode.String).ToString(); City_nvcTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(CityEntity.City_nvc, TypeCode.String).ToString(); TravelTime_intNumericTextBox.Text = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(CityEntity.TravelTime_int, TypeCode.Int32)); Active_bitCheckBox.Checked = (Boolean)Hepsa.Core.Common.PersentationController.GetEntityValue(CityEntity.Active_bit, TypeCode.Boolean); }
public void Insert(HPS.BLL.CityBLL.BLLCity_T businessObject) { try { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "CityID_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 PopulateBusinessObjectFromReader(HPS.BLL.CityBLL.BLLCity_T businessObject, IDataReader dataReader) { businessObject.CityID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.CityBLL.BLLCity_T.City_TField.CityID_int.ToString())); businessObject.CityCode_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.CityBLL.BLLCity_T.City_TField.CityCode_nvc.ToString())); businessObject.City_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.CityBLL.BLLCity_T.City_TField.City_nvc.ToString())); if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.CityBLL.BLLCity_T.City_TField.TravelTime_int.ToString())) == false) { businessObject.TravelTime_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.CityBLL.BLLCity_T.City_TField.TravelTime_int.ToString())); } else { businessObject.TravelTime_int = null; } businessObject.Active_bit = dataReader.GetBoolean(dataReader.GetOrdinal(HPS.BLL.CityBLL.BLLCity_T.City_TField.Active_bit.ToString())); }
private void SearchButton_Click(object sender, EventArgs e) { if (CityGridView.CurrentRow != null) { HPS.BLL.CityBLL.BLLCity_TFactory CityFactory = new HPS.BLL.CityBLL.BLLCity_TFactory(); HPS.BLL.CityBLL.BLLCity_TKeys CityKey = new HPS.BLL.CityBLL.BLLCity_TKeys(); CityKey.CityID_int = (Int32)CityGridView.CurrentRow.Cells[colCityID_int.Name].Value; CityEntity = CityFactory.GetBy(CityKey); if (string.IsNullOrEmpty(Hepsa.Core.Common.PersentationController.GetEntityValue(CityGridView.CurrentRow.Cells[colCityID_int.Name].Value, TypeCode.String).ToString()) == false) { CityEntity.City_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(CityGridView.CurrentRow.Cells[colCity_nvc.Name].Value, TypeCode.String).ToString(); CityEntity.CityCode_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(CityGridView.CurrentRow.Cells[colCityCode_nvc.Name].Value, TypeCode.String).ToString(); } } this.Close(); }
protected override void Edit() { HPS.BLL.CityBLL.BLLCity_TFactory CityFactory = new HPS.BLL.CityBLL.BLLCity_TFactory(); try { HPS.BLL.CityBLL.BLLCity_T CityEntity = new HPS.BLL.CityBLL.BLLCity_T(); CityEntity.CityCode_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(CityCode_nvcTextBox.Text, TypeCode.String).ToString(); CityEntity.City_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(City_nvcTextBox.Text, TypeCode.String).ToString(); CityEntity.TravelTime_int = (Nullable <Int32>)Hepsa.Core.Common.PersentationController.GetEntityValue(TravelTime_intNumericTextBox.NumericText, TypeCode.Int32); CityEntity.Active_bit = Active_bitCheckBox.Checked; if (Hepsa.Core.Common.MessageBox.ConfirmMessage(HPS.Exceptions.ExceptionCs.EditMessage) == true) { CityFactory.BeginProc(); CityFactory.Update(CityEntity, (HPS.BLL.CityBLL.BLLCity_TKeys)Key); CityFactory.CommitProc(); if (DataTable != null) { DataRow[] dr = DataTable.Select(HPS.BLL.CityBLL.BLLCity_T.City_TField.CityID_int.ToString() + "='" + ((HPS.BLL.CityBLL.BLLCity_TKeys)Key).CityID_int.ToString() + "'"); if (dr.Length > 0) { dr[0][HPS.BLL.CityBLL.BLLCity_T.City_TField.CityCode_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CityEntity.CityCode_nvc, TypeCode.String); dr[0][HPS.BLL.CityBLL.BLLCity_T.City_TField.City_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CityEntity.City_nvc, TypeCode.String); dr[0][HPS.BLL.CityBLL.BLLCity_T.City_TField.TravelTime_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CityEntity.TravelTime_int, TypeCode.Int32); dr[0][HPS.BLL.CityBLL.BLLCity_T.City_TField.Active_bit.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(CityEntity.Active_bit, TypeCode.Boolean); } DataTable.AcceptChanges(); } } } catch (Exception ex) { CityFactory.RollBackProc(); throw ex; } }
public void Insert(HPS.BLL.CityBLL.BLLCity_T businessObject) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_City_T_Add]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter CityID_int = new SqlParameter(); CityID_int.ParameterName = "@CityID_int"; CityID_int.SqlDbType = SqlDbType.Int; CityID_int.Direction = ParameterDirection.Output; CityID_int.IsNullable = false; CityID_int.Value = businessObject.CityID_int; this.Command.Parameters.Add(CityID_int); SqlParameter CityCode_nvc = new SqlParameter(); CityCode_nvc.ParameterName = "@CityCode_nvc"; CityCode_nvc.SqlDbType = SqlDbType.NVarChar; CityCode_nvc.Direction = ParameterDirection.Input; CityCode_nvc.IsNullable = false; CityCode_nvc.Value = businessObject.CityCode_nvc; this.Command.Parameters.Add(CityCode_nvc); SqlParameter City_nvc = new SqlParameter(); City_nvc.ParameterName = "@City_nvc"; City_nvc.SqlDbType = SqlDbType.NVarChar; City_nvc.Direction = ParameterDirection.Input; City_nvc.IsNullable = false; City_nvc.Value = businessObject.City_nvc; this.Command.Parameters.Add(City_nvc); SqlParameter TravelTime_int = new SqlParameter(); TravelTime_int.ParameterName = "@TravelTime_int"; TravelTime_int.SqlDbType = SqlDbType.Int; TravelTime_int.Direction = ParameterDirection.Input; TravelTime_int.IsNullable = true; if (businessObject.TravelTime_int.HasValue == false) { TravelTime_int.Value = DBNull.Value; } else { TravelTime_int.Value = businessObject.TravelTime_int; } this.Command.Parameters.Add(TravelTime_int); SqlParameter Active_bit = new SqlParameter(); Active_bit.ParameterName = "@Active_bit"; Active_bit.SqlDbType = SqlDbType.Bit; Active_bit.Direction = ParameterDirection.Input; Active_bit.IsNullable = false; Active_bit.Value = businessObject.Active_bit; this.Command.Parameters.Add(Active_bit); if (ControlConnection) { this.BeginTransaction(); } this.Command.ExecuteNonQuery(); businessObject.CityID_int = (Int32?)(this.Command.Parameters["@CityID_int"].Value); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }