private void DeleteButton_Click(object sender, EventArgs e) { HPS.BLL.TrafficTypeBLL.BLLTrafficType_TFactory TrafficTypeFactory = new HPS.BLL.TrafficTypeBLL.BLLTrafficType_TFactory(); try { if (Hepsa.Core.Common.MessageBox.ConfirmDeleteMessage() == false) { return; } HPS.BLL.TrafficTypeBLL.BLLTrafficType_TFactory TrafficType_TFactory = new HPS.BLL.TrafficTypeBLL.BLLTrafficType_TFactory(); HPS.BLL.TrafficTypeBLL.BLLTrafficType_TKeys TrafficTypeKey = new HPS.BLL.TrafficTypeBLL.BLLTrafficType_TKeys(); TrafficTypeKey.TrafficTypeID_int = (Int32?)TrafficTypeGridView.CurrentRow.Cells["colTrafficTypeID_int"].Value; TrafficTypeFactory.Delete(TrafficTypeKey); DataRow[] dr = ((DataTable)this.TrafficTypeGridView.DataSource).Select(HPS.BLL.TrafficTypeBLL.BLLTrafficType_T.TrafficType_TField.TrafficTypeID_int.ToString() + "='" + TrafficTypeKey.TrafficTypeID_int.ToString() + "'"); if (dr.Length > 0) { dr[0].Delete(); } ((DataTable)this.TrafficTypeGridView.DataSource).AcceptChanges(); } catch (Exception ex) { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); } }
public HPS.BLL.TrafficTypeBLL.BLLTrafficType_T SelectByPrimaryKey(HPS.BLL.TrafficTypeBLL.BLLTrafficType_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_TrafficType_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter TrafficTypeID_int = new SqlParameter(); TrafficTypeID_int.ParameterName = "@TrafficTypeID_int"; TrafficTypeID_int.SqlDbType = SqlDbType.Int; TrafficTypeID_int.Direction = ParameterDirection.Input; TrafficTypeID_int.IsNullable = false; TrafficTypeID_int.Value = businessObjectKey.TrafficTypeID_int; this.Command.Parameters.Add(TrafficTypeID_int); if (ControlConnection) { this.BeginTransaction(); } IDataReader dataReader = this.Command.ExecuteReader(); HPS.BLL.TrafficTypeBLL.BLLTrafficType_T businessObject = new HPS.BLL.TrafficTypeBLL.BLLTrafficType_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 void GetBy(HPS.BLL.TrafficTypeBLL.BLLTrafficType_TKeys keys, ref System.Data.DataSet dataSet) { try { _dataObject.SelectByPrimaryKey(keys, ref dataSet); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
public HPS.BLL.TrafficTypeBLL.BLLTrafficType_T GetBy(HPS.BLL.TrafficTypeBLL.BLLTrafficType_TKeys keys) { try { return(_dataObject.SelectByPrimaryKey(keys)); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
public void Delete(HPS.BLL.TrafficTypeBLL.BLLTrafficType_TKeys keys) { try { _dataObject.Delete(keys); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
public void Update(HPS.BLL.TrafficTypeBLL.BLLTrafficType_T businessObject, HPS.BLL.TrafficTypeBLL.BLLTrafficType_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_TrafficType_T_Update]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter TrafficType_nvc = new SqlParameter(); TrafficType_nvc.ParameterName = "@TrafficType_nvc"; TrafficType_nvc.SqlDbType = SqlDbType.NVarChar; TrafficType_nvc.Direction = ParameterDirection.Input; TrafficType_nvc.IsNullable = false; TrafficType_nvc.Value = businessObject.TrafficType_nvc; this.Command.Parameters.Add(TrafficType_nvc); SqlParameter pk_TrafficTypeID_int = new SqlParameter(); pk_TrafficTypeID_int.ParameterName = "@pk_TrafficTypeID_int"; pk_TrafficTypeID_int.SqlDbType = SqlDbType.Int; pk_TrafficTypeID_int.Direction = ParameterDirection.Input; pk_TrafficTypeID_int.IsNullable = false; pk_TrafficTypeID_int.Value = businessObjectKey.TrafficTypeID_int; this.Command.Parameters.Add(pk_TrafficTypeID_int); if (ControlConnection) { this.BeginTransaction(); } this.Command.ExecuteNonQuery(); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }
public void SelectByPrimaryKey(HPS.BLL.TrafficTypeBLL.BLLTrafficType_TKeys businessObjectKey, ref System.Data.DataTable dataTable) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); SqlDataAdapter sqlDataAdapter = new System.Data.SqlClient.SqlDataAdapter(this.Command); this.Command.CommandText = "[sp_TrafficType_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter TrafficTypeID_int = new SqlParameter(); TrafficTypeID_int.ParameterName = "@TrafficTypeID_int"; TrafficTypeID_int.SqlDbType = SqlDbType.Int; TrafficTypeID_int.Direction = ParameterDirection.Input; TrafficTypeID_int.IsNullable = false; TrafficTypeID_int.Value = businessObjectKey.TrafficTypeID_int; this.Command.Parameters.Add(TrafficTypeID_int); if (ControlConnection) { this.BeginTransaction(); } sqlDataAdapter.Fill(dataTable); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }
private void EditButton_Click(object sender, EventArgs e) { HPS.BLL.TrafficTypeBLL.BLLTrafficType_TFactory TrafficTypeFactory = new HPS.BLL.TrafficTypeBLL.BLLTrafficType_TFactory(); string condition = "[TrafficType_T].[TrafficType_nvc]='" + TrafficTypeGridView.CurrentRow.Cells[colTrafficType_nvc.Name].Value + "'"; List <HPS.BLL.TrafficTypeBLL.BLLTrafficType_T> lst = TrafficTypeFactory.GetAllByCondition(condition); int flag = 0; foreach (HPS.BLL.TrafficTypeBLL.BLLTrafficType_T item in lst) { if (item.TrafficTypeID_int == 1 || item.TrafficTypeID_int == 2) { flag = 1; } } if (flag != 1) { HPS.BLL.TrafficTypeBLL.BLLTrafficType_TKeys TrafficTypeKey = new HPS.BLL.TrafficTypeBLL.BLLTrafficType_TKeys(); TrafficTypeKey.TrafficTypeID_int = (Int32?)this.TrafficTypeGridView.CurrentRow.Cells["colTrafficTypeID_int"].Value; TrafficTypeEntityForm TrafficType = new TrafficTypeEntityForm(BaseEntityForm1.enmState.Edit, (DataTable)this.TrafficTypeGridView.DataSource, TrafficTypeKey); TrafficType.ShowDialog(); } }
public void Update(HPS.BLL.TrafficTypeBLL.BLLTrafficType_T businessObject, HPS.BLL.TrafficTypeBLL.BLLTrafficType_TKeys businessObjectKey) { try { HPS.BLL.TrafficTypeBLL.BLLTrafficType_T tmpTrafficType = this.GetBy(businessObjectKey); List <string> Except = new List <string>(); if (businessObject.TrafficTypeID_int == businessObjectKey.TrafficTypeID_int) { Except.Add("UniqueTrafficTypeID_int"); } if (businessObject.TrafficType_nvc == tmpTrafficType.TrafficType_nvc) { Except.Add("UniqueTrafficType_nvc"); } if (Except.Count > 0) { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, Except.ToArray()) == 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 TrafficTypeEntityForm(Hepsa.Core.PL.BaseEntityParentForm.enmState State, DataTable DataTable, HPS.BLL.TrafficTypeBLL.BLLTrafficType_TKeys Key) : base(State, DataTable, Key) { InitializeComponent(); }