public void Update(HPS.BLL.BillMessageBLL.BLLBillMessage_T businessObject, HPS.BLL.BillMessageBLL.BLLBillMessage_TKeys businessObjectKey) { try { if (businessObject.BillMessageID_int == businessObjectKey.BillMessageID_int) { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueBillMessageID_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 PopulateBusinessObjectFromReader(HPS.BLL.BillMessageBLL.BLLBillMessage_T businessObject, IDataReader dataReader) { businessObject.BillMessageID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.BillMessageID_int.ToString())); businessObject.ShowInLadeAssignmentRepetation_bit = dataReader.GetBoolean(dataReader.GetOrdinal(HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.ShowInLadeAssignmentRepetation_bit.ToString())); businessObject.Message_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.Message_nvc.ToString())); businessObject.StartDate_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.StartDate_nvc.ToString())); businessObject.EndDate_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.EndDate_nvc.ToString())); businessObject.UserName_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.UserName_nvc.ToString())); if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.BillID_int.ToString())) == false) { businessObject.BillID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.BillID_int.ToString())); } else { businessObject.BillID_int = null; } if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.SaloonID_int.ToString())) == false) { businessObject.SaloonID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.SaloonID_int.ToString())); } else { businessObject.SaloonID_int = null; } }
public HPS.BLL.BillMessageBLL.BLLBillMessage_T SelectByPrimaryKey(HPS.BLL.BillMessageBLL.BLLBillMessage_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_BillMessage_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter BillMessageID_int = new SqlParameter(); BillMessageID_int.ParameterName = "@BillMessageID_int"; BillMessageID_int.SqlDbType = SqlDbType.Int; BillMessageID_int.Direction = ParameterDirection.Input; BillMessageID_int.IsNullable = false; BillMessageID_int.Value = businessObjectKey.BillMessageID_int; this.Command.Parameters.Add(BillMessageID_int); if (ControlConnection) { this.BeginTransaction(); } IDataReader dataReader = this.Command.ExecuteReader(); HPS.BLL.BillMessageBLL.BLLBillMessage_T businessObject = new HPS.BLL.BillMessageBLL.BLLBillMessage_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.BillMessageBLL.BLLBillMessage_T> PopulateObjectsFromReader(IDataReader dataReader) { List <HPS.BLL.BillMessageBLL.BLLBillMessage_T> list = new List <HPS.BLL.BillMessageBLL.BLLBillMessage_T>(); while (dataReader.Read()) { HPS.BLL.BillMessageBLL.BLLBillMessage_T businessObject = new HPS.BLL.BillMessageBLL.BLLBillMessage_T(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
public void Insert(HPS.BLL.BillMessageBLL.BLLBillMessage_T businessObject) { try { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "BillMessageID_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); } }
protected override void ShowForm() { this.FillCombo(); HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory BillMessageFactory = new HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory(); HPS.BLL.BillMessageBLL.BLLBillMessage_T BillMessageEntity = BillMessageFactory.GetBy((HPS.BLL.BillMessageBLL.BLLBillMessage_TKeys)Key); if (BillMessageEntity == null) { throw new HPS.Exceptions.BillMessageNotFound(); } Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref BillID_intComboBox, BillMessageEntity.BillID_int, TypeCode.Int32); Message_nvcTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(BillMessageEntity.Message_nvc, TypeCode.String).ToString(); StartDate_nvcTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(BillMessageEntity.StartDate_nvc, TypeCode.String).ToString(); EndDate_nvcTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(BillMessageEntity.EndDate_nvc, TypeCode.String).ToString(); ShowInSaloncheckBox.Checked = BillMessageEntity.ShowInLadeAssignmentRepetation_bit.Value; Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref SaloonID_intComboBox, BillMessageEntity.SaloonID_int, TypeCode.Int32); }
protected override void Insert() { HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory BillMessageFactory = new HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory(); try { HPS.BLL.BillMessageBLL.BLLBillMessage_T BillMessageEntity = new HPS.BLL.BillMessageBLL.BLLBillMessage_T(); BillMessageEntity.BillID_int = (Int32?)Hepsa.Core.Common.PersentationController.GetEntityValue(BillID_intComboBox.SelectedValue, TypeCode.Int32); BillMessageEntity.Message_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(Message_nvcTextBox.Text, TypeCode.String).ToString(); BillMessageEntity.StartDate_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(StartDate_nvcTextBox.Text, TypeCode.String).ToString(); BillMessageEntity.EndDate_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(EndDate_nvcTextBox.Text, TypeCode.String).ToString(); BillMessageEntity.UserName_nvc = HPS.Common.CurrentUser.user.UserName_nvc; BillMessageEntity.ShowInLadeAssignmentRepetation_bit = ShowInSaloncheckBox.Checked; BillMessageEntity.SaloonID_int = (Int32?)Hepsa.Core.Common.PersentationController.GetEntityValue(SaloonID_intComboBox.SelectedValue, TypeCode.Int32); if (ShowInSaloncheckBox.Checked) { BillMessageEntity.BillID_int = null; BillID_intComboBox.SelectedIndex = -1; } if (BillMessageEntity.EndDate_nvc.CompareTo(BillMessageEntity.StartDate_nvc) < 0) { throw new ApplicationException(HPS.Exceptions.ExceptionCs.EndDateMoreThanStartDate); } if (string.Compare(StartDate_nvcTextBox.Text, BillMessageFactory.ServerJalaliDate) < 0) { throw new ApplicationException("تاریخ شروع نمی تواند کوچکتر از تاریخ جاری باشد"); } if (EndDate_nvcTextBox.Text.CompareTo(BillMessageFactory.ServerJalaliDate) < 0) { throw new ApplicationException("تاریخ اتمام نمی تواند کوچکتر از تاریخ جاری باشد"); } if (BillID_intComboBox.SelectedIndex != -1) { string Condition = string.Format("BillMessage_T.Message_nvc=N'{0}' AND BillMessage_T.BillID_int='{1}'", BillMessageEntity.Message_nvc, BillMessageEntity.BillID_int); List <HPS.BLL.BillMessageBLL.BLLBillMessage_T> BillmessageList = BillMessageFactory.GetAllByCondition(Condition); if (BillmessageList != null && BillmessageList.Count > 0) { foreach (HPS.BLL.BillMessageBLL.BLLBillMessage_T item in BillmessageList) { if (!(StartDate_nvcTextBox.Text.CompareTo(item.EndDate_nvc) > 0 || EndDate_nvcTextBox.Text.CompareTo(item.StartDate_nvc) < 0)) { throw new ApplicationException("براي تاريخ وارد شده پیام تعريف شده است"); } } } } BillMessageFactory.BeginProc(); BillMessageFactory.Insert(BillMessageEntity); BillMessageFactory.CommitProc(); if (DataTable != null) { DataRow dr = this.DataTable.NewRow(); dr[HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.BillMessageID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(BillMessageEntity.BillMessageID_int, TypeCode.Int32); dr[HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.BillID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(BillMessageEntity.BillID_int, TypeCode.Int32); dr["BillID_intBillType_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(BillID_intComboBox); dr[HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.Message_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(BillMessageEntity.Message_nvc, TypeCode.String); dr[HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.StartDate_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(BillMessageEntity.StartDate_nvc, TypeCode.String); dr[HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.EndDate_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(BillMessageEntity.EndDate_nvc, TypeCode.String); dr[HPS.BLL.BillMessageBLL.BLLBillMessage_T.BillMessage_TField.UserName_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(BillMessageEntity.UserName_nvc, TypeCode.String); DataTable.Rows.Add(dr); DataTable.AcceptChanges(); } this.ClearForm(this); } catch (Exception ex) { BillMessageFactory.RollBackProc(); throw ex; } }
public void Insert(HPS.BLL.BillMessageBLL.BLLBillMessage_T businessObject) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_BillMessage_T_Add]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter BillMessageID_int = new SqlParameter(); BillMessageID_int.ParameterName = "@BillMessageID_int"; BillMessageID_int.SqlDbType = SqlDbType.Int; BillMessageID_int.Direction = ParameterDirection.Output; BillMessageID_int.IsNullable = false; BillMessageID_int.Value = businessObject.BillMessageID_int; this.Command.Parameters.Add(BillMessageID_int); SqlParameter BillID_int = new SqlParameter(); BillID_int.ParameterName = "@BillID_int"; BillID_int.SqlDbType = SqlDbType.Int; BillID_int.Direction = ParameterDirection.Input; BillID_int.IsNullable = true; if (businessObject.BillID_int.HasValue) { BillID_int.Value = businessObject.BillID_int; } else { BillID_int.Value = DBNull.Value; } this.Command.Parameters.Add(BillID_int); SqlParameter Message_nvc = new SqlParameter(); Message_nvc.ParameterName = "@Message_nvc"; Message_nvc.SqlDbType = SqlDbType.NVarChar; Message_nvc.Direction = ParameterDirection.Input; Message_nvc.IsNullable = false; Message_nvc.Value = businessObject.Message_nvc; this.Command.Parameters.Add(Message_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; 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 = false; EndDate_nvc.Value = businessObject.EndDate_nvc; this.Command.Parameters.Add(EndDate_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 SaloonID_intParam = new SqlParameter(); SaloonID_intParam.ParameterName = "@SaloonID_int"; SaloonID_intParam.SqlDbType = SqlDbType.Int; SaloonID_intParam.Direction = ParameterDirection.Input; SaloonID_intParam.IsNullable = true; if (businessObject.SaloonID_int.HasValue) { SaloonID_intParam.Value = businessObject.SaloonID_int; } else { SaloonID_intParam.Value = DBNull.Value; } this.Command.Parameters.Add(SaloonID_intParam); SqlParameter ShowInLadeAssignmentRepetation_bitParam = new SqlParameter(); ShowInLadeAssignmentRepetation_bitParam.ParameterName = "@ShowInLadeAssignmentRepetation_bit"; ShowInLadeAssignmentRepetation_bitParam.SqlDbType = SqlDbType.Bit; ShowInLadeAssignmentRepetation_bitParam.Direction = ParameterDirection.Input; ShowInLadeAssignmentRepetation_bitParam.IsNullable = false; ShowInLadeAssignmentRepetation_bitParam.Value = businessObject.ShowInLadeAssignmentRepetation_bit; this.Command.Parameters.Add(ShowInLadeAssignmentRepetation_bitParam); if (ControlConnection) { this.BeginTransaction(); } this.Command.ExecuteNonQuery(); businessObject.BillMessageID_int = (Int32?)(this.Command.Parameters["@BillMessageID_int"].Value); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }