예제 #1
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            HPS.BLL.ClassBLL.BLLClass_TFactory ClassFactory = new HPS.BLL.ClassBLL.BLLClass_TFactory();

            try
            {
                if (Hepsa.Core.Common.MessageBox.ConfirmDeleteMessage() == false)
                {
                    return;
                }


                HPS.BLL.ClassBLL.BLLClass_TFactory Class_TFactory = new HPS.BLL.ClassBLL.BLLClass_TFactory();
                HPS.BLL.ClassBLL.BLLClass_TKeys    ClassKey       = new HPS.BLL.ClassBLL.BLLClass_TKeys();

                ClassKey.ClassID_int = (Int32)ClassGridView.CurrentRow.Cells["colClassID_int"].Value;
                ClassFactory.Delete(ClassKey);

                DataRow[] dr = ((DataTable)this.ClassGridView.DataSource).Select(HPS.BLL.ClassBLL.BLLClass_T.Class_TField.ClassID_int.ToString() + "='" + ClassKey.ClassID_int.ToString() + "'");
                if (dr.Length > 0)
                {
                    dr[0].Delete();
                }
                ((DataTable)this.ClassGridView.DataSource).AcceptChanges();
            }

            catch (Exception ex)
            {
                Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message);
            }
        }
예제 #2
0
 public void GetBy(HPS.BLL.ClassBLL.BLLClass_TKeys keys, ref System.Data.DataTable dataTable)
 {
     try{
         _dataObject.SelectByPrimaryKey(keys, ref dataTable);
     }catch (System.Exception ex) {
         throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this);
     }
 }
예제 #3
0
 public HPS.BLL.ClassBLL.BLLClass_T GetBy(HPS.BLL.ClassBLL.BLLClass_TKeys keys)
 {
     try{
         return(_dataObject.SelectByPrimaryKey(keys));
     }catch (System.Exception ex) {
         throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this);
     }
 }
예제 #4
0
 public void Delete(HPS.BLL.ClassBLL.BLLClass_TKeys keys)
 {
     try{
         _dataObject.Delete(keys);
     }catch (System.Exception ex) {
         throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this);
     }
 }
예제 #5
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            HPS.BLL.ClassBLL.BLLClass_TKeys ClassKey = new HPS.BLL.ClassBLL.BLLClass_TKeys();
            ClassKey.ClassID_int = (Int32)this.ClassGridView.CurrentRow.Cells["colClassID_int"].Value;
            ClassEntityForm Class = new ClassEntityForm(BaseEntityForm1.enmState.Edit, (DataTable)this.ClassGridView.DataSource, ClassKey);

            Class.ShowDialog();
        }
예제 #6
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;
            }
        }
예제 #7
0
        public void Update(HPS.BLL.ClassBLL.BLLClass_T businessObject, HPS.BLL.ClassBLL.BLLClass_TKeys businessObjectKey)
        {
            bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open);

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

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

                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);


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



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

                this.Command.ExecuteNonQuery();

                if (ControlConnection)
                {
                    this.Commit();
                }
            }
            catch (System.Exception ex) {
                if (ControlConnection)
                {
                    this.RollBack();
                }
                throw ex;
            }
        }
예제 #8
0
        public void SelectByPrimaryKey(HPS.BLL.ClassBLL.BLLClass_TKeys businessObjectKey, ref System.Data.DataTable dataTable)
        {
            bool           ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open);
            SqlDataAdapter sqlDataAdapter    = new System.Data.SqlClient.SqlDataAdapter(this.Command);

            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();
                }

                sqlDataAdapter.Fill(dataTable);

                if (ControlConnection)
                {
                    this.Commit();
                }
            }
            catch (System.Exception ex) {
                if (ControlConnection)
                {
                    this.RollBack();
                }
                throw ex;
            }
        }
예제 #9
0
        public void Update(HPS.BLL.ClassBLL.BLLClass_T businessObject, HPS.BLL.ClassBLL.BLLClass_TKeys businessObjectKey)
        {
            try{
                if (businessObject.ClassID_int == businessObjectKey.ClassID_int)
                {
                    if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueClassID_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);
            }
        }
예제 #10
0
 public ClassEntityForm(Hepsa.Core.PL.BaseEntityParentForm.enmState State, DataTable DataTable, HPS.BLL.ClassBLL.BLLClass_TKeys Key)
     : base(State, DataTable, Key)
 {
     InitializeComponent();
 }