示例#1
0
        protected override void Edit()
        {
            HPS.BLL.ClassBLL.BLLClass_TFactory ClassFactory = new HPS.BLL.ClassBLL.BLLClass_TFactory();
            try
            {
                HPS.BLL.ClassBLL.BLLClass_T ClassEntity = new HPS.BLL.ClassBLL.BLLClass_T();
                ClassEntity.ClassName_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(ClassName_nvcTextBox.Text, TypeCode.String).ToString();

                if (Hepsa.Core.Common.MessageBox.ConfirmMessage(HPS.Exceptions.ExceptionCs.EditMessage) == true)
                {
                    ClassFactory.BeginProc();
                    ClassFactory.Update(ClassEntity, (HPS.BLL.ClassBLL.BLLClass_TKeys)Key);
                    ClassFactory.CommitProc();
                    if (DataTable != null)
                    {
                        DataRow[] dr = DataTable.Select(HPS.BLL.ClassBLL.BLLClass_T.Class_TField.ClassID_int.ToString() + "='" + ((HPS.BLL.ClassBLL.BLLClass_TKeys)Key).ClassID_int.ToString() + "'");
                        if (dr.Length > 0)
                        {
                            dr[0][HPS.BLL.ClassBLL.BLLClass_T.Class_TField.ClassName_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ClassEntity.ClassName_nvc, TypeCode.String);
                        }
                        DataTable.AcceptChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                ClassFactory.RollBackProc();
                throw ex;
            }
        }
示例#2
0
        protected override void Insert()
        {
            HPS.BLL.ClassBLL.BLLClass_TFactory ClassFactory = new HPS.BLL.ClassBLL.BLLClass_TFactory();
            try
            {
                HPS.BLL.ClassBLL.BLLClass_T ClassEntity = new HPS.BLL.ClassBLL.BLLClass_T();
                ClassEntity.ClassName_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(ClassName_nvcTextBox.Text, TypeCode.String).ToString();

                ClassFactory.BeginProc();
                ClassFactory.Insert(ClassEntity);
                ClassFactory.CommitProc();
                if (DataTable != null)
                {
                    DataRow dr = this.DataTable.NewRow();
                    dr[HPS.BLL.ClassBLL.BLLClass_T.Class_TField.ClassID_int.ToString()]   = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ClassEntity.ClassID_int, TypeCode.Int32);
                    dr[HPS.BLL.ClassBLL.BLLClass_T.Class_TField.ClassName_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ClassEntity.ClassName_nvc, TypeCode.String);

                    DataTable.Rows.Add(dr);
                    DataTable.AcceptChanges();
                }
                this.ClearForm(this);
            }
            catch (Exception ex)
            {
                ClassFactory.RollBackProc();
                throw ex;
            }
        }
示例#3
0
        public HPS.BLL.ClassBLL.BLLClass_T SelectByPrimaryKey(HPS.BLL.ClassBLL.BLLClass_TKeys businessObjectKey)
        {
            bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open);

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

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

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



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

                IDataReader dataReader = this.Command.ExecuteReader();
                HPS.BLL.ClassBLL.BLLClass_T businessObject = new HPS.BLL.ClassBLL.BLLClass_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;
            }
        }
示例#4
0
 protected override void ShowForm()
 {
     this.FillCombo();
     HPS.BLL.ClassBLL.BLLClass_TFactory ClassFactory = new HPS.BLL.ClassBLL.BLLClass_TFactory();
     HPS.BLL.ClassBLL.BLLClass_T        ClassEntity  = ClassFactory.GetBy((HPS.BLL.ClassBLL.BLLClass_TKeys)Key);
     if (ClassEntity == null)
     {
         throw new HPS.Exceptions.ClassNotFound();
     }
     ClassName_nvcTextBox.Text = Convert.ToString(Hepsa.Core.Common.PersentationController.GetEntityValue(ClassEntity.ClassName_nvc, TypeCode.String));
 }
示例#5
0
        public List <HPS.BLL.ClassBLL.BLLClass_T> PopulateObjectsFromReader(IDataReader dataReader)
        {
            List <HPS.BLL.ClassBLL.BLLClass_T> list = new List <HPS.BLL.ClassBLL.BLLClass_T>();

            while (dataReader.Read())
            {
                HPS.BLL.ClassBLL.BLLClass_T businessObject = new HPS.BLL.ClassBLL.BLLClass_T();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }
            return(list);
        }
示例#6
0
        public void Insert(HPS.BLL.ClassBLL.BLLClass_T businessObject)
        {
            try{
                if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueClassID_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);
            }
        }
示例#7
0
        public void Insert(HPS.BLL.ClassBLL.BLLClass_T businessObject)
        {
            bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open);

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

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

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

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



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

                this.Command.ExecuteNonQuery();

                businessObject.ClassID_int = (Int32)(this.Command.Parameters["@ClassID_int"].Value);

                if (ControlConnection)
                {
                    this.Commit();
                }
            }
            catch (System.Exception ex) {
                if (ControlConnection)
                {
                    this.RollBack();
                }
                throw ex;
            }
        }
示例#8
0
 public void PopulateBusinessObjectFromReader(HPS.BLL.ClassBLL.BLLClass_T businessObject, IDataReader dataReader)
 {
     businessObject.ClassID_int   = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.ClassBLL.BLLClass_T.Class_TField.ClassID_int.ToString()));
     businessObject.ClassName_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.ClassBLL.BLLClass_T.Class_TField.ClassName_nvc.ToString()));
 }