protected override void Edit() { HPS.BLL.ColorBLL.BLLColor_TFactory ColorFactory = new HPS.BLL.ColorBLL.BLLColor_TFactory(); try { HPS.BLL.ColorBLL.BLLColor_T ColorEntity = new HPS.BLL.ColorBLL.BLLColor_T(); ColorEntity.Color_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(Color_nvcTextBox.Text, TypeCode.String).ToString(); ColorEntity.ColorCode_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(ColorCode_nvcTextBox.Text, TypeCode.String).ToString(); if (Hepsa.Core.Common.MessageBox.ConfirmMessage(HPS.Exceptions.ExceptionCs.EditMessage) == true) { ColorFactory.BeginProc(); ColorFactory.Update(ColorEntity, (HPS.BLL.ColorBLL.BLLColor_TKeys)Key); ColorFactory.CommitProc(); if (DataTable != null) { DataRow[] dr = DataTable.Select(HPS.BLL.ColorBLL.BLLColor_T.Color_TField.ColorID_int.ToString() + "='" + ((HPS.BLL.ColorBLL.BLLColor_TKeys)Key).ColorID_int.ToString() + "'"); if (dr.Length > 0) { dr[0][HPS.BLL.ColorBLL.BLLColor_T.Color_TField.Color_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ColorEntity.Color_nvc, TypeCode.String); dr[0][HPS.BLL.ColorBLL.BLLColor_T.Color_TField.ColorCode_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ColorEntity.ColorCode_nvc, TypeCode.String); } DataTable.AcceptChanges(); } } } catch (Exception ex) { ColorFactory.RollBackProc(); throw ex; } }
protected override void Insert() { HPS.BLL.ColorBLL.BLLColor_TFactory ColorFactory = new HPS.BLL.ColorBLL.BLLColor_TFactory(); try { HPS.BLL.ColorBLL.BLLColor_T ColorEntity = new HPS.BLL.ColorBLL.BLLColor_T(); ColorEntity.Color_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(Color_nvcTextBox.Text, TypeCode.String).ToString(); ColorEntity.ColorCode_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(ColorCode_nvcTextBox.Text, TypeCode.String).ToString(); ColorFactory.BeginProc(); ColorFactory.Insert(ColorEntity); ColorFactory.CommitProc(); if (DataTable != null) { DataRow dr = this.DataTable.NewRow(); dr[HPS.BLL.ColorBLL.BLLColor_T.Color_TField.ColorID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ColorEntity.ColorID_int, TypeCode.Int32); dr[HPS.BLL.ColorBLL.BLLColor_T.Color_TField.Color_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ColorEntity.Color_nvc, TypeCode.String); dr[HPS.BLL.ColorBLL.BLLColor_T.Color_TField.ColorCode_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ColorEntity.ColorCode_nvc, TypeCode.String); DataTable.Rows.Add(dr); DataTable.AcceptChanges(); } this.ClearForm(this); } catch (Exception ex) { ColorFactory.RollBackProc(); throw ex; } }
public HPS.BLL.ColorBLL.BLLColor_T SelectByPrimaryKey(HPS.BLL.ColorBLL.BLLColor_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_Color_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try{ this.Command.Parameters.Clear(); SqlParameter ColorID_int = new SqlParameter(); ColorID_int.ParameterName = "@ColorID_int"; ColorID_int.SqlDbType = SqlDbType.Int; ColorID_int.Direction = ParameterDirection.Input; ColorID_int.IsNullable = false; ColorID_int.Value = businessObjectKey.ColorID_int; this.Command.Parameters.Add(ColorID_int); if (ControlConnection) { this.BeginTransaction(); } IDataReader dataReader = this.Command.ExecuteReader(); HPS.BLL.ColorBLL.BLLColor_T businessObject = new HPS.BLL.ColorBLL.BLLColor_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.ColorBLL.BLLColor_T> PopulateObjectsFromReader(IDataReader dataReader) { List <HPS.BLL.ColorBLL.BLLColor_T> list = new List <HPS.BLL.ColorBLL.BLLColor_T>(); while (dataReader.Read()) { HPS.BLL.ColorBLL.BLLColor_T businessObject = new HPS.BLL.ColorBLL.BLLColor_T(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
protected override void ShowForm() { this.FillCombo(); HPS.BLL.ColorBLL.BLLColor_TFactory ColorFactory = new HPS.BLL.ColorBLL.BLLColor_TFactory(); HPS.BLL.ColorBLL.BLLColor_T ColorEntity = ColorFactory.GetBy((HPS.BLL.ColorBLL.BLLColor_TKeys)Key); if (ColorEntity == null) { throw new HPS.Exceptions.ColorNotFound(); } Color_nvcTextBox.Text = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(ColorEntity.Color_nvc, TypeCode.String)); ColorCode_nvcTextBox.Text = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(ColorEntity.ColorCode_nvc, TypeCode.String)); }
public void PopulateBusinessObjectFromReader(HPS.BLL.ColorBLL.BLLColor_T businessObject, IDataReader dataReader) { businessObject.ColorID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.ColorBLL.BLLColor_T.Color_TField.ColorID_int.ToString())); businessObject.Color_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.ColorBLL.BLLColor_T.Color_TField.Color_nvc.ToString())); if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.ColorBLL.BLLColor_T.Color_TField.ColorCode_nvc.ToString())) == false) { businessObject.ColorCode_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.ColorBLL.BLLColor_T.Color_TField.ColorCode_nvc.ToString())); } else { businessObject.ColorCode_nvc = String.Empty; } }
public void Insert(HPS.BLL.ColorBLL.BLLColor_T businessObject) { try{ if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "ColorID_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.ColorBLL.BLLColor_T businessObject, HPS.BLL.ColorBLL.BLLColor_TKeys businessObjectKey) { try{ if (businessObject.ColorID_int == businessObjectKey.ColorID_int) { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueColorID_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 void Update(HPS.BLL.ColorBLL.BLLColor_T businessObject, HPS.BLL.ColorBLL.BLLColor_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_Color_T_Update]"; this.Command.CommandType = CommandType.StoredProcedure; try{ this.Command.Parameters.Clear(); SqlParameter Color_nvc = new SqlParameter(); Color_nvc.ParameterName = "@Color_nvc"; Color_nvc.SqlDbType = SqlDbType.NVarChar; Color_nvc.Direction = ParameterDirection.Input; Color_nvc.IsNullable = false; Color_nvc.Value = businessObject.Color_nvc; this.Command.Parameters.Add(Color_nvc); SqlParameter ColorCode_nvc = new SqlParameter(); ColorCode_nvc.ParameterName = "@ColorCode_nvc"; ColorCode_nvc.SqlDbType = SqlDbType.NVarChar; ColorCode_nvc.Direction = ParameterDirection.Input; ColorCode_nvc.IsNullable = false; if (String.IsNullOrEmpty(businessObject.ColorCode_nvc)) { ColorCode_nvc.Value = DBNull.Value; } else { ColorCode_nvc.Value = businessObject.ColorCode_nvc; } this.Command.Parameters.Add(ColorCode_nvc); SqlParameter pk_ColorID_int = new SqlParameter(); pk_ColorID_int.ParameterName = "@pk_ColorID_int"; pk_ColorID_int.SqlDbType = SqlDbType.Int; pk_ColorID_int.Direction = ParameterDirection.Input; pk_ColorID_int.IsNullable = false; pk_ColorID_int.Value = businessObjectKey.ColorID_int; this.Command.Parameters.Add(pk_ColorID_int); if (ControlConnection) { this.BeginTransaction(); } this.Command.ExecuteNonQuery(); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }