private void DeleteButton_Click(object sender, EventArgs e) { HPS.BLL.NewsBLL.BLLNews_TFactory NewsFactory = new HPS.BLL.NewsBLL.BLLNews_TFactory(); try { if (Hepsa.Core.Common.MessageBox.ConfirmDeleteMessage() == false) { return; } HPS.BLL.NewsBLL.BLLNews_TFactory News_TFactory = new HPS.BLL.NewsBLL.BLLNews_TFactory(); HPS.BLL.NewsBLL.BLLNews_TKeys NewsKey = new HPS.BLL.NewsBLL.BLLNews_TKeys(); NewsKey.NewsID_bint = (Int64?)NewsGridView.CurrentRow.Cells["colNewsID_bint"].Value; NewsFactory.Delete(NewsKey); DataRow[] dr = ((DataTable)this.NewsGridView.DataSource).Select(HPS.BLL.NewsBLL.BLLNews_T.News_TField.NewsID_bint.ToString() + "='" + NewsKey.NewsID_bint.ToString() + "'"); if (dr.Length > 0) { dr[0].Delete(); } ((DataTable)this.NewsGridView.DataSource).AcceptChanges(); } catch (Exception ex) { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); } }
public void Update(HPS.BLL.NewsBLL.BLLNews_T businessObject, HPS.BLL.NewsBLL.BLLNews_TKeys businessObjectKey) { try { if (businessObject.NewsID_bint == businessObjectKey.NewsID_bint) { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueNewsID_bint") == 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); } }
private void EditButton_Click(object sender, EventArgs e) { HPS.BLL.NewsBLL.BLLNews_TKeys NewsKey = new HPS.BLL.NewsBLL.BLLNews_TKeys(); NewsKey.NewsID_bint = (Int64?)this.NewsGridView.CurrentRow.Cells["colNewsID_bint"].Value; NewsEntityForm News = new NewsEntityForm(BaseEntityForm1.enmState.Edit, (DataTable)this.NewsGridView.DataSource, NewsKey); News.ShowDialog(); }
public HPS.BLL.NewsBLL.BLLNews_T SelectByPrimaryKey(HPS.BLL.NewsBLL.BLLNews_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_News_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter NewsID_bint = new SqlParameter(); NewsID_bint.ParameterName = "@NewsID_bint"; NewsID_bint.SqlDbType = SqlDbType.BigInt; NewsID_bint.Direction = ParameterDirection.Input; NewsID_bint.IsNullable = false; NewsID_bint.Value = businessObjectKey.NewsID_bint; this.Command.Parameters.Add(NewsID_bint); if (ControlConnection) { this.BeginTransaction(); } IDataReader dataReader = this.Command.ExecuteReader(); HPS.BLL.NewsBLL.BLLNews_T businessObject = new HPS.BLL.NewsBLL.BLLNews_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.NewsBLL.BLLNews_TKeys keys, ref System.Data.DataTable dataTable) { try { _dataObject.SelectByPrimaryKey(keys, ref dataTable); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
public HPS.BLL.NewsBLL.BLLNews_T GetBy(HPS.BLL.NewsBLL.BLLNews_TKeys keys) { try { return(_dataObject.SelectByPrimaryKey(keys)); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
public void Delete(HPS.BLL.NewsBLL.BLLNews_TKeys keys) { try { _dataObject.Delete(keys); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
public void SelectByPrimaryKey(HPS.BLL.NewsBLL.BLLNews_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_News_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter NewsID_bint = new SqlParameter(); NewsID_bint.ParameterName = "@NewsID_bint"; NewsID_bint.SqlDbType = SqlDbType.BigInt; NewsID_bint.Direction = ParameterDirection.Input; NewsID_bint.IsNullable = false; NewsID_bint.Value = businessObjectKey.NewsID_bint; this.Command.Parameters.Add(NewsID_bint); if (ControlConnection) { this.BeginTransaction(); } sqlDataAdapter.Fill(dataTable); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }
public NewsEntityForm(Hepsa.Core.PL.BaseEntityParentForm.enmState State, DataTable DataTable, HPS.BLL.NewsBLL.BLLNews_TKeys Key) : base(State, DataTable, Key) { InitializeComponent(); }
public void Update(HPS.BLL.NewsBLL.BLLNews_T businessObject, HPS.BLL.NewsBLL.BLLNews_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_News_T_Update]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter Title_nvc = new SqlParameter(); Title_nvc.ParameterName = "@Title_nvc"; Title_nvc.SqlDbType = SqlDbType.NVarChar; Title_nvc.Direction = ParameterDirection.Input; Title_nvc.IsNullable = false; Title_nvc.Value = businessObject.Title_nvc; this.Command.Parameters.Add(Title_nvc); SqlParameter News_nvc = new SqlParameter(); News_nvc.ParameterName = "@News_nvc"; News_nvc.SqlDbType = SqlDbType.NVarChar; News_nvc.Direction = ParameterDirection.Input; News_nvc.IsNullable = false; News_nvc.Value = businessObject.News_nvc; this.Command.Parameters.Add(News_nvc); SqlParameter StartDate_nvc = new SqlParameter(); StartDate_nvc.ParameterName = "@StartDate_nvc"; StartDate_nvc.SqlDbType = SqlDbType.NVarChar; StartDate_nvc.Direction = ParameterDirection.Input; StartDate_nvc.IsNullable = false; if (String.IsNullOrEmpty(businessObject.StartDate_nvc)) { StartDate_nvc.Value = DBNull.Value; } else { StartDate_nvc.Value = businessObject.StartDate_nvc; } this.Command.Parameters.Add(StartDate_nvc); SqlParameter EndDate_nvc = new SqlParameter(); EndDate_nvc.ParameterName = "@EndDate_nvc"; EndDate_nvc.SqlDbType = SqlDbType.NVarChar; EndDate_nvc.Direction = ParameterDirection.Input; EndDate_nvc.IsNullable = true; if (String.IsNullOrEmpty(businessObject.EndDate_nvc)) { EndDate_nvc.Value = DBNull.Value; } else { EndDate_nvc.Value = businessObject.EndDate_nvc; } this.Command.Parameters.Add(EndDate_nvc); SqlParameter Date_nvc = new SqlParameter(); Date_nvc.ParameterName = "@Date_nvc"; Date_nvc.SqlDbType = SqlDbType.NVarChar; Date_nvc.Direction = ParameterDirection.Input; Date_nvc.IsNullable = true; Date_nvc.Value = businessObject.Date_nvc; this.Command.Parameters.Add(Date_nvc); SqlParameter Time_nvc = new SqlParameter(); Time_nvc.ParameterName = "@Time_nvc"; Time_nvc.SqlDbType = SqlDbType.NVarChar; Time_nvc.Direction = ParameterDirection.Input; Time_nvc.IsNullable = false; Time_nvc.Value = businessObject.Time_nvc; this.Command.Parameters.Add(Time_nvc); SqlParameter UserName_nvc = new SqlParameter(); UserName_nvc.ParameterName = "@UserName_nvc"; UserName_nvc.SqlDbType = SqlDbType.NVarChar; UserName_nvc.Direction = ParameterDirection.Input; UserName_nvc.IsNullable = false; UserName_nvc.Value = businessObject.UserName_nvc; this.Command.Parameters.Add(UserName_nvc); SqlParameter pk_NewsID_bint = new SqlParameter(); pk_NewsID_bint.ParameterName = "@pk_NewsID_bint"; pk_NewsID_bint.SqlDbType = SqlDbType.BigInt; pk_NewsID_bint.Direction = ParameterDirection.Input; pk_NewsID_bint.IsNullable = false; pk_NewsID_bint.Value = businessObjectKey.NewsID_bint; this.Command.Parameters.Add(pk_NewsID_bint); if (ControlConnection) { this.BeginTransaction(); } this.Command.ExecuteNonQuery(); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }