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); } }
public void PopulateBusinessObjectFromReader(HPS.BLL.NewsBLL.BLLNews_T businessObject, IDataReader dataReader) { businessObject.NewsID_bint = dataReader.GetInt64(dataReader.GetOrdinal(HPS.BLL.NewsBLL.BLLNews_T.News_TField.NewsID_bint.ToString())); businessObject.Title_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.NewsBLL.BLLNews_T.News_TField.Title_nvc.ToString())); businessObject.News_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.NewsBLL.BLLNews_T.News_TField.News_nvc.ToString())); if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.NewsBLL.BLLNews_T.News_TField.StartDate_nvc.ToString())) == false) { businessObject.StartDate_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.NewsBLL.BLLNews_T.News_TField.StartDate_nvc.ToString())); } else { businessObject.StartDate_nvc = String.Empty; } if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.NewsBLL.BLLNews_T.News_TField.EndDate_nvc.ToString())) == false) { businessObject.EndDate_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.NewsBLL.BLLNews_T.News_TField.EndDate_nvc.ToString())); } else { businessObject.EndDate_nvc = String.Empty; } businessObject.Date_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.NewsBLL.BLLNews_T.News_TField.Date_nvc.ToString())); businessObject.Time_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.NewsBLL.BLLNews_T.News_TField.Time_nvc.ToString())); businessObject.UserName_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.NewsBLL.BLLNews_T.News_TField.UserName_nvc.ToString())); }
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 List <HPS.BLL.NewsBLL.BLLNews_T> PopulateObjectsFromReader(IDataReader dataReader) { List <HPS.BLL.NewsBLL.BLLNews_T> list = new List <HPS.BLL.NewsBLL.BLLNews_T>(); while (dataReader.Read()) { HPS.BLL.NewsBLL.BLLNews_T businessObject = new HPS.BLL.NewsBLL.BLLNews_T(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
protected override void ShowForm() { this.FillCombo(); HPS.BLL.NewsBLL.BLLNews_TFactory NewsFactory = new HPS.BLL.NewsBLL.BLLNews_TFactory(); HPS.BLL.NewsBLL.BLLNews_T NewsEntity = NewsFactory.GetBy((HPS.BLL.NewsBLL.BLLNews_TKeys)Key); if (NewsEntity == null) { throw new HPS.Exceptions.NewsNotFound(); } Title_nvcTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(NewsEntity.Title_nvc, TypeCode.String).ToString(); News_nvcTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(NewsEntity.News_nvc, TypeCode.String).ToString(); StartDate_nvcTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(NewsEntity.StartDate_nvc, TypeCode.String).ToString(); EndDate_nvcTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(NewsEntity.EndDate_nvc, TypeCode.String).ToString(); }
public void Insert(HPS.BLL.NewsBLL.BLLNews_T businessObject) { try { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "NewsID_bint") == 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); } }
protected override void Insert() { HPS.BLL.NewsBLL.BLLNews_TFactory NewsFactory = new HPS.BLL.NewsBLL.BLLNews_TFactory(); try { HPS.BLL.NewsBLL.BLLNews_T NewsEntity = new HPS.BLL.NewsBLL.BLLNews_T(); NewsEntity.Title_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(Title_nvcTextBox.Text, TypeCode.String).ToString(); NewsEntity.News_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(News_nvcTextBox.Text, TypeCode.String).ToString(); NewsEntity.StartDate_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(StartDate_nvcTextBox.Text, TypeCode.String).ToString(); NewsEntity.EndDate_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(EndDate_nvcTextBox.Text, TypeCode.String).ToString(); NewsEntity.Date_nvc = NewsFactory.ServerJalaliDate; NewsEntity.Time_nvc = NewsFactory.ServerTime; NewsEntity.UserName_nvc = HPS.Common.CurrentUser.user.UserName_nvc; if (NewsFactory.ServerJalaliDate.CompareTo(StartDate_nvcTextBox.Text) > 0) { throw new ApplicationException("از تاریخ نباید کوچکتر از <" + NewsFactory.ServerJalaliDate + "> باشد"); } if (EndDate_nvcTextBox.Text.CompareTo(StartDate_nvcTextBox.Text) < 0) { throw new ApplicationException(HPS.Exceptions.ExceptionCs.EndDateMoreThanStartDate); } NewsFactory.BeginProc(); NewsFactory.Insert(NewsEntity); NewsFactory.CommitProc(); if (DataTable != null) { DataRow dr = this.DataTable.NewRow(); dr[HPS.BLL.NewsBLL.BLLNews_T.News_TField.NewsID_bint.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(NewsEntity.NewsID_bint, TypeCode.Int64); dr[HPS.BLL.NewsBLL.BLLNews_T.News_TField.Title_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(NewsEntity.Title_nvc, TypeCode.String); dr[HPS.BLL.NewsBLL.BLLNews_T.News_TField.News_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(NewsEntity.News_nvc, TypeCode.String); dr[HPS.BLL.NewsBLL.BLLNews_T.News_TField.StartDate_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(NewsEntity.StartDate_nvc, TypeCode.String); dr[HPS.BLL.NewsBLL.BLLNews_T.News_TField.EndDate_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(NewsEntity.EndDate_nvc, TypeCode.String); dr[HPS.BLL.NewsBLL.BLLNews_T.News_TField.Date_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(NewsEntity.Date_nvc, TypeCode.String); dr[HPS.BLL.NewsBLL.BLLNews_T.News_TField.Time_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(NewsEntity.Time_nvc, TypeCode.String); dr[HPS.BLL.NewsBLL.BLLNews_T.News_TField.UserName_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(NewsEntity.UserName_nvc, TypeCode.String); DataTable.Rows.Add(dr); DataTable.AcceptChanges(); } this.ClearForm(this); } catch (Exception ex) { NewsFactory.RollBackProc(); throw ex; } }
protected override void Edit() { HPS.BLL.NewsBLL.BLLNews_TFactory NewsFactory = new HPS.BLL.NewsBLL.BLLNews_TFactory(); try { HPS.BLL.NewsBLL.BLLNews_T NewsEntity = new HPS.BLL.NewsBLL.BLLNews_T(); NewsEntity.Title_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(Title_nvcTextBox.Text, TypeCode.String).ToString(); NewsEntity.News_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(News_nvcTextBox.Text, TypeCode.String).ToString(); NewsEntity.StartDate_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(StartDate_nvcTextBox.Text, TypeCode.String).ToString(); NewsEntity.EndDate_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(EndDate_nvcTextBox.Text, TypeCode.String).ToString(); NewsEntity.Date_nvc = NewsFactory.ServerJalaliDate; NewsEntity.Time_nvc = NewsFactory.ServerTime; NewsEntity.UserName_nvc = HPS.Common.CurrentUser.user.UserName_nvc; if (Hepsa.Core.Common.MessageBox.ConfirmMessage(HPS.Exceptions.ExceptionCs.EditMessage) == true) { NewsFactory.BeginProc(); NewsFactory.Update(NewsEntity, (HPS.BLL.NewsBLL.BLLNews_TKeys)Key); NewsFactory.CommitProc(); if (DataTable != null) { DataRow[] dr = DataTable.Select(HPS.BLL.NewsBLL.BLLNews_T.News_TField.NewsID_bint.ToString() + "='" + ((HPS.BLL.NewsBLL.BLLNews_TKeys)Key).NewsID_bint.ToString() + "'"); if (dr.Length > 0) { dr[0][HPS.BLL.NewsBLL.BLLNews_T.News_TField.Title_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(NewsEntity.Title_nvc, TypeCode.String); dr[0][HPS.BLL.NewsBLL.BLLNews_T.News_TField.News_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(NewsEntity.News_nvc, TypeCode.String); dr[0][HPS.BLL.NewsBLL.BLLNews_T.News_TField.StartDate_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(NewsEntity.StartDate_nvc, TypeCode.String); dr[0][HPS.BLL.NewsBLL.BLLNews_T.News_TField.EndDate_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(NewsEntity.EndDate_nvc, TypeCode.String); dr[0][HPS.BLL.NewsBLL.BLLNews_T.News_TField.Date_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(NewsEntity.Date_nvc, TypeCode.String); dr[0][HPS.BLL.NewsBLL.BLLNews_T.News_TField.Time_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(NewsEntity.Time_nvc, TypeCode.String); } DataTable.AcceptChanges(); } } } catch (Exception ex) { NewsFactory.RollBackProc(); throw ex; } }
public void Insert(HPS.BLL.NewsBLL.BLLNews_T businessObject) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_News_T_Add]"; 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.Output; NewsID_bint.IsNullable = false; NewsID_bint.Value = businessObject.NewsID_bint; this.Command.Parameters.Add(NewsID_bint); 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 = true; 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 = false; 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); if (ControlConnection) { this.BeginTransaction(); } this.Command.ExecuteNonQuery(); businessObject.NewsID_bint = (Int64?)(this.Command.Parameters["@NewsID_bint"].Value); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }