コード例 #1
0
        public HPS.BLL.InfractionTypeBLL.BLLInfractionType_T SelectByPrimaryKey(HPS.BLL.InfractionTypeBLL.BLLInfractionType_TKeys businessObjectKey)
        {
            bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open);

            this.Command.CommandText = "[sp_InfractionType_T_SelectByPrimaryKey]";
            this.Command.CommandType = CommandType.StoredProcedure;

            try{
                this.Command.Parameters.Clear();

                SqlParameter InfractionTypeID_int = new SqlParameter();
                InfractionTypeID_int.ParameterName = "@InfractionTypeID_int";
                InfractionTypeID_int.SqlDbType     = SqlDbType.Int;
                InfractionTypeID_int.Direction     = ParameterDirection.Input;
                InfractionTypeID_int.IsNullable    = false;
                InfractionTypeID_int.Value         = businessObjectKey.InfractionTypeID_int;
                this.Command.Parameters.Add(InfractionTypeID_int);



                if (ControlConnection)
                {
                    this.BeginTransaction();
                }

                IDataReader dataReader = this.Command.ExecuteReader();
                HPS.BLL.InfractionTypeBLL.BLLInfractionType_T businessObject = new HPS.BLL.InfractionTypeBLL.BLLInfractionType_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;
            }
        }
コード例 #2
0
        public List <HPS.BLL.InfractionTypeBLL.BLLInfractionType_T> PopulateObjectsFromReader(IDataReader dataReader)
        {
            List <HPS.BLL.InfractionTypeBLL.BLLInfractionType_T> list = new List <HPS.BLL.InfractionTypeBLL.BLLInfractionType_T>();

            while (dataReader.Read())
            {
                HPS.BLL.InfractionTypeBLL.BLLInfractionType_T businessObject = new HPS.BLL.InfractionTypeBLL.BLLInfractionType_T();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }
            return(list);
        }
コード例 #3
0
        protected override void Insert()
        {
            HPS.BLL.InfractionTypeBLL.BLLInfractionType_TFactory InfractionTypeFactory = new HPS.BLL.InfractionTypeBLL.BLLInfractionType_TFactory();
            try
            {
                HPS.BLL.InfractionTypeBLL.BLLInfractionType_T InfractionTypeEntity = new HPS.BLL.InfractionTypeBLL.BLLInfractionType_T();
                InfractionTypeEntity.InfractionType_nvc          = Hepsa.Core.Common.PersentationController.GetEntityValue(InfractionType_nvcTextBox.Text, TypeCode.String).ToString();
                InfractionTypeEntity.InfractionGroupID_int       = (Int32?)Hepsa.Core.Common.PersentationController.GetEntityValue(InfractionGroupID_intComboBox.SelectedValue, TypeCode.Int32);
                InfractionTypeEntity.InfractionSurveyGroupID_int = (Int32?)Hepsa.Core.Common.PersentationController.GetEntityValue(InfractionSurveyGroupID_intComboBox.SelectedValue, TypeCode.Int32);
                InfractionTypeEntity.PenaltyFee_dec = (Nullable <Decimal>)Hepsa.Core.Common.PersentationController.GetEntityValue(PenaltyFee_decNumericTextBox.NumericText, TypeCode.Decimal);
                InfractionTypeEntity.Date_nvc       = InfractionTypeFactory.ServerJalaliDate;
                InfractionTypeEntity.Time_nvc       = InfractionTypeFactory.ServerTime;
                InfractionTypeEntity.UserName_nvc   = HPS.Common.CurrentUser.user.UserName_nvc;
                InfractionTypeEntity.Active_bit     = Active_bitCheckBox.Checked;


                string condition = "InfractionType_T.InfractionType_nvc=N'" + InfractionTypeEntity.InfractionType_nvc + "' AND InfractionType_T.InfractionGroupID_int='" + InfractionTypeEntity.InfractionGroupID_int + "'";
                List <HPS.BLL.InfractionTypeBLL.BLLInfractionType_T> InfractionTypeList = InfractionTypeFactory.GetAllByCondition(condition);
                if (InfractionTypeList != null && InfractionTypeList.Count > 0)
                {
                    throw new ApplicationException("این نوع تخلف قبلاً ثبت شده است");
                }

                InfractionTypeFactory.BeginProc();
                InfractionTypeFactory.Insert(InfractionTypeEntity);
                InfractionTypeFactory.CommitProc();
                if (DataTable != null)
                {
                    DataRow dr = this.DataTable.NewRow();
                    dr[HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.InfractionTypeID_int.ToString()]  = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(InfractionTypeEntity.InfractionTypeID_int, TypeCode.Int32);
                    dr[HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.InfractionType_nvc.ToString()]    = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(InfractionTypeEntity.InfractionType_nvc, TypeCode.String);
                    dr[HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.InfractionGroupID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(InfractionTypeEntity.InfractionGroupID_int, TypeCode.Int32);
                    dr["InfractionGroupID_intInfractionGroup_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(InfractionGroupID_intComboBox);
                    dr[HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.InfractionSurveyGroupID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(InfractionTypeEntity.InfractionSurveyGroupID_int, TypeCode.Int32);
                    dr["InfractionSurveyGroupID_intInfractionSurveyGroup_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(InfractionSurveyGroupID_intComboBox);
                    dr[HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.PenaltyFee_dec.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(InfractionTypeEntity.PenaltyFee_dec, TypeCode.Decimal);
                    dr[HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.Date_nvc.ToString()]       = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(InfractionTypeEntity.Date_nvc, TypeCode.String);
                    dr[HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.Time_nvc.ToString()]       = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(InfractionTypeEntity.Time_nvc, TypeCode.String);
                    dr[HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.Active_bit.ToString()]     = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(InfractionTypeEntity.Active_bit, TypeCode.Boolean);
                    dr[HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.UserName_nvc.ToString()]   = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(InfractionTypeEntity.UserName_nvc, TypeCode.String);

                    DataTable.Rows.Add(dr);
                    DataTable.AcceptChanges();
                }
                this.ClearForm(this);
            }
            catch (Exception ex)
            {
                InfractionTypeFactory.RollBackProc();
                throw ex;
            }
        }
コード例 #4
0
 protected override void ShowForm()
 {
     this.FillCombo();
     HPS.BLL.InfractionTypeBLL.BLLInfractionType_TFactory InfractionTypeFactory = new HPS.BLL.InfractionTypeBLL.BLLInfractionType_TFactory();
     HPS.BLL.InfractionTypeBLL.BLLInfractionType_T        InfractionTypeEntity  = InfractionTypeFactory.GetBy((HPS.BLL.InfractionTypeBLL.BLLInfractionType_TKeys)Key);
     if (InfractionTypeEntity == null)
     {
         throw new HPS.Exceptions.InfractionTypeNotFound();
     }
     InfractionType_nvcTextBox.Text = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(InfractionTypeEntity.InfractionType_nvc, TypeCode.String));
     Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref InfractionGroupID_intComboBox, InfractionTypeEntity.InfractionGroupID_int, TypeCode.Int32);
     Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref InfractionSurveyGroupID_intComboBox, InfractionTypeEntity.InfractionSurveyGroupID_int, TypeCode.Int32);
     PenaltyFee_decNumericTextBox.Text = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(InfractionTypeEntity.PenaltyFee_dec, TypeCode.Decimal));
     Active_bitCheckBox.Checked        = (Boolean)Hepsa.Core.Common.PersentationController.GetEntityValue(InfractionTypeEntity.Active_bit, TypeCode.Boolean);
 }
コード例 #5
0
        public void Insert(HPS.BLL.InfractionTypeBLL.BLLInfractionType_T businessObject)
        {
            try
            {
                if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueInfractionTypeID_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);
            }
        }
コード例 #6
0
        public void PopulateBusinessObjectFromReader(HPS.BLL.InfractionTypeBLL.BLLInfractionType_T businessObject, IDataReader dataReader)
        {
            businessObject.InfractionTypeID_int        = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.InfractionTypeID_int.ToString()));
            businessObject.InfractionType_nvc          = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.InfractionType_nvc.ToString()));
            businessObject.InfractionGroupID_int       = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.InfractionGroupID_int.ToString()));
            businessObject.InfractionSurveyGroupID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.InfractionSurveyGroupID_int.ToString()));
            if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.PenaltyFee_dec.ToString())) == false)
            {
                businessObject.PenaltyFee_dec = dataReader.GetDecimal(dataReader.GetOrdinal(HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.PenaltyFee_dec.ToString()));
            }
            else
            {
                businessObject.PenaltyFee_dec = null;
            }

            businessObject.Date_nvc     = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.Date_nvc.ToString()));
            businessObject.Time_nvc     = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.Time_nvc.ToString()));
            businessObject.Active_bit   = dataReader.GetBoolean(dataReader.GetOrdinal(HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.Active_bit.ToString()));
            businessObject.UserName_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.InfractionTypeBLL.BLLInfractionType_T.InfractionType_TField.UserName_nvc.ToString()));
        }
コード例 #7
0
        public void Update(HPS.BLL.InfractionTypeBLL.BLLInfractionType_T businessObject, HPS.BLL.InfractionTypeBLL.BLLInfractionType_TKeys businessObjectKey)
        {
            try
            {
                HPS.BLL.InfractionTypeBLL.BLLInfractionType_T tmpInfractionType = this.GetBy(businessObjectKey);
                List <string> Except = new List <string>();
                if (businessObject.InfractionTypeID_int == businessObjectKey.InfractionTypeID_int)
                {
                    Except.Add("UniqueInfractionTypeID_int");
                }
                if (businessObject.InfractionGroupID_int == tmpInfractionType.InfractionGroupID_int)
                {
                    Except.Add("UniqueInfractionGroupID_int");
                }
                //if (businessObject.InfractionType_nvc == tmpInfractionType.InfractionType_nvc)
                //    Except.Add("UniqueInfractionType_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);
            }
        }
コード例 #8
0
        public void Insert(HPS.BLL.InfractionTypeBLL.BLLInfractionType_T businessObject)
        {
            bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open);

            this.Command.CommandText = "[sp_InfractionType_T_Add]";
            this.Command.CommandType = CommandType.StoredProcedure;

            try{
                this.Command.Parameters.Clear();

                SqlParameter InfractionTypeID_int = new SqlParameter();
                InfractionTypeID_int.ParameterName = "@InfractionTypeID_int";
                InfractionTypeID_int.SqlDbType     = SqlDbType.Int;
                InfractionTypeID_int.Direction     = ParameterDirection.Output;
                InfractionTypeID_int.IsNullable    = false;
                InfractionTypeID_int.Value         = businessObject.InfractionTypeID_int;
                this.Command.Parameters.Add(InfractionTypeID_int);

                SqlParameter InfractionType_nvc = new SqlParameter();
                InfractionType_nvc.ParameterName = "@InfractionType_nvc";
                InfractionType_nvc.SqlDbType     = SqlDbType.NVarChar;
                InfractionType_nvc.Direction     = ParameterDirection.Input;
                InfractionType_nvc.IsNullable    = false;
                InfractionType_nvc.Value         = businessObject.InfractionType_nvc;
                this.Command.Parameters.Add(InfractionType_nvc);

                SqlParameter InfractionGroupID_int = new SqlParameter();
                InfractionGroupID_int.ParameterName = "@InfractionGroupID_int";
                InfractionGroupID_int.SqlDbType     = SqlDbType.Int;
                InfractionGroupID_int.Direction     = ParameterDirection.Input;
                InfractionGroupID_int.IsNullable    = false;
                InfractionGroupID_int.Value         = businessObject.InfractionGroupID_int;
                this.Command.Parameters.Add(InfractionGroupID_int);

                SqlParameter InfractionSurveyGroupID_int = new SqlParameter();
                InfractionSurveyGroupID_int.ParameterName = "@InfractionSurveyGroupID_int";
                InfractionSurveyGroupID_int.SqlDbType     = SqlDbType.Int;
                InfractionSurveyGroupID_int.Direction     = ParameterDirection.Input;
                InfractionSurveyGroupID_int.IsNullable    = false;
                InfractionSurveyGroupID_int.Value         = businessObject.InfractionSurveyGroupID_int;
                this.Command.Parameters.Add(InfractionSurveyGroupID_int);

                SqlParameter PenaltyFee_dec = new SqlParameter();
                PenaltyFee_dec.ParameterName = "@PenaltyFee_dec";
                PenaltyFee_dec.SqlDbType     = SqlDbType.Decimal;
                PenaltyFee_dec.Direction     = ParameterDirection.Input;
                PenaltyFee_dec.IsNullable    = true;
                if (businessObject.PenaltyFee_dec.HasValue == false)
                {
                    PenaltyFee_dec.Value = DBNull.Value;
                }
                else
                {
                    PenaltyFee_dec.Value = businessObject.PenaltyFee_dec;
                }
                this.Command.Parameters.Add(PenaltyFee_dec);

                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 Active_bit = new SqlParameter();
                Active_bit.ParameterName = "@Active_bit";
                Active_bit.SqlDbType     = SqlDbType.Bit;
                Active_bit.Direction     = ParameterDirection.Input;
                Active_bit.IsNullable    = false;
                Active_bit.Value         = businessObject.Active_bit;
                this.Command.Parameters.Add(Active_bit);

                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.InfractionTypeID_int = (Int32?)(this.Command.Parameters["@InfractionTypeID_int"].Value);

                if (ControlConnection)
                {
                    this.Commit();
                }
            }
            catch (System.Exception ex) {
                if (ControlConnection)
                {
                    this.RollBack();
                }
                throw ex;
            }
        }