Example #1
0
        protected override void ShowForm()
        {
            this.FillCombo();
            HPS.BLL.ComputerBLL.BLLComputer_TFactory ComputerFactory = new HPS.BLL.ComputerBLL.BLLComputer_TFactory();
            HPS.BLL.ComputerBLL.BLLComputer_T        ComputerEntity  = ComputerFactory.GetBy((HPS.BLL.ComputerBLL.BLLComputer_TKeys)Key);
            if (ComputerEntity == null)
            {
                throw new HPS.Exceptions.ComputerNotFound();
            }
            MessageLED_nvcTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(ComputerEntity.MessageLED_nvc, TypeCode.String).ToString();
            IPTextBox.Text             = Hepsa.Core.Common.PersentationController.GetEntityValue(ComputerEntity.IPAddress_nvc, TypeCode.String).ToString();
            MacTextBox.Text            = Hepsa.Core.Common.PersentationController.GetEntityValue(ComputerEntity.MacAddress_nvc, TypeCode.String).ToString();
            Active_bitCheckBox.Checked = (Boolean)Hepsa.Core.Common.PersentationController.GetEntityValue(ComputerEntity.Active_bit, TypeCode.Boolean);

            List <HPS.BLL.ComputerBLL.BLLComputer_T> ComputerList = new List <HPS.BLL.ComputerBLL.BLLComputer_T>();

            ComputerList = ComputerFactory.GetAllByCondition(string.Format(" Computer_T.MacAddress_nvc='{0}' AND Deleted_bit=0", _MacAddress_nvc));

            if (ComputerList.Count > 0)
            {
                foreach (var item in ComputerList)
                {
                    foreach (var gridRow in UserNameGridView.GetRows())
                    {
                        if (item.Computer_nvc == gridRow.Cells["username_nvc"].Value.ToString())
                        {
                            gridRow.IsChecked = true;
                        }
                    }
                }
            }
        }
Example #2
0
        public HPS.BLL.ComputerBLL.BLLComputer_T SelectByPrimaryKey(HPS.BLL.ComputerBLL.BLLComputer_TKeys businessObjectKey)
        {
            bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open);

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

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

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



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

                IDataReader dataReader = this.Command.ExecuteReader();
                HPS.BLL.ComputerBLL.BLLComputer_T businessObject = new HPS.BLL.ComputerBLL.BLLComputer_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;
            }
        }
Example #3
0
        public List <HPS.BLL.ComputerBLL.BLLComputer_T> PopulateObjectsFromReader(IDataReader dataReader)
        {
            List <HPS.BLL.ComputerBLL.BLLComputer_T> list = new List <HPS.BLL.ComputerBLL.BLLComputer_T>();

            while (dataReader.Read())
            {
                HPS.BLL.ComputerBLL.BLLComputer_T businessObject = new HPS.BLL.ComputerBLL.BLLComputer_T();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }
            return(list);
        }
Example #4
0
        protected override void Insert()
        {
            HPS.BLL.ComputerBLL.BLLComputer_TFactory ComputerFactory = new HPS.BLL.ComputerBLL.BLLComputer_TFactory();
            try
            {
                HPS.BLL.ComputerBLL.BLLComputer_T    ComputerEntity = new HPS.BLL.ComputerBLL.BLLComputer_T();
                List <BLL.ComputerBLL.BLLComputer_T> ComputerList   = new List <BLL.ComputerBLL.BLLComputer_T>();
                ComputerList = ComputerFactory.GetAllByCondition("MacAddress_nvc=N'" + MacTextBox.Text + "'");
                BLL.ComputerBLL.BLLComputer_TKeys ComputerKey = new BLL.ComputerBLL.BLLComputer_TKeys();
                foreach (Janus.Windows.GridEX.GridEXRow item in UserNameGridView.GetCheckedRows())
                {
                    if (ComputerList.Find(a => a.Computer_nvc == item.Cells["username_nvc"].Value.ToString() && a.Deleted_bit == false && a.MacAddress_nvc == MacTextBox.Text) == null)
                    {
                        ComputerEntity.ComputerID_int  = null;
                        ComputerEntity.Computer_nvc    = item.Cells["username_nvc"].Value.ToString();
                        ComputerEntity.IPAddress_nvc   = Hepsa.Core.Common.PersentationController.GetEntityValue(IPTextBox.Text, TypeCode.String).ToString();
                        ComputerEntity.MacAddress_nvc  = Hepsa.Core.Common.PersentationController.GetEntityValue(MacTextBox.Text, TypeCode.String).ToString();
                        ComputerEntity.MessageLED_nvc  = Hepsa.Core.Common.PersentationController.GetEntityValue(MessageLED_nvcTextBox.Text, TypeCode.String).ToString();
                        ComputerEntity.Active_bit      = Active_bitCheckBox.Checked;
                        ComputerEntity.UserGroupID_int = (Int32)item.Cells["UserGroupID_int"].Value;
                        ComputerFactory.BeginProc();
                        ComputerFactory.Insert(ComputerEntity);
                        ComputerFactory.CommitProc();
                    }
                }
                //if (DataTable != null)
                //{
                //    DataRow dr = this.DataTable.NewRow();
                //    dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.ComputerID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.ComputerID_int, TypeCode.Int32);
                //    dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.Computer_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.Computer_nvc, TypeCode.String);
                //    dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.IPAddress_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValue(IPTextBox.Text, TypeCode.String).ToString();
                //    dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.MacAddress_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValue(MacTextBox.Text, TypeCode.String).ToString();
                //    dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.MessageLED_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.MessageLED_nvc, TypeCode.String);
                //    dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.Active_bit.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.Active_bit, TypeCode.Boolean);
                //    dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.UserGroupID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.UserGroupID_int, TypeCode.Int32);
                //    dr["UserGroupID_intUserGroup_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(UserGroupID_intComboBox);

                //    DataTable.Rows.Add(dr);
                //    DataTable.AcceptChanges();
                //}
                //this.ClearForm(this);
            }

            catch (Exception ex)
            {
                ComputerFactory.RollBackProc();
                throw ex;
            }
            this.DialogResult = DialogResult.OK;
        }
Example #5
0
        public void Insert(HPS.BLL.ComputerBLL.BLLComputer_T businessObject)
        {
            try
            {
                if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "ComputerID_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);
            }
        }
Example #6
0
 protected override void ShowForm()
 {
     this.FillCombo();
     HPS.BLL.ComputerBLL.BLLComputer_TFactory ComputerFactory = new HPS.BLL.ComputerBLL.BLLComputer_TFactory();
     HPS.BLL.ComputerBLL.BLLComputer_T        ComputerEntity  = ComputerFactory.GetBy((HPS.BLL.ComputerBLL.BLLComputer_TKeys)Key);
     if (ComputerEntity == null)
     {
         throw new HPS.Exceptions.ComputerNotFound();
     }
     Computer_nvcComboBox.Text  = Hepsa.Core.Common.PersentationController.GetEntityValue(ComputerEntity.Computer_nvc, TypeCode.String).ToString();
     MessageLED_nvcTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(ComputerEntity.MessageLED_nvc, TypeCode.String).ToString();
     IPTextBox.Text             = Hepsa.Core.Common.PersentationController.GetEntityValue(ComputerEntity.IPAddress_nvc, TypeCode.String).ToString();
     MacTextBox.Text            = Hepsa.Core.Common.PersentationController.GetEntityValue(ComputerEntity.MacAddress_nvc, TypeCode.String).ToString();
     Active_bitCheckBox.Checked = (Boolean)Hepsa.Core.Common.PersentationController.GetEntityValue(ComputerEntity.Active_bit, TypeCode.Boolean);
     Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref UserGroupID_intComboBox, ComputerEntity.UserGroupID_int, TypeCode.Int32);
 }
Example #7
0
        protected override void Insert()
        {
            HPS.BLL.ComputerBLL.BLLComputer_TFactory ComputerFactory = new HPS.BLL.ComputerBLL.BLLComputer_TFactory();
            try
            {
                HPS.BLL.ComputerBLL.BLLComputer_T    ComputerEntity = new HPS.BLL.ComputerBLL.BLLComputer_T();
                List <BLL.ComputerBLL.BLLComputer_T> ComputerList   = new List <BLL.ComputerBLL.BLLComputer_T>();
                ComputerList = ComputerFactory.GetAllByCondition("MacAddress_nvc=N'" + MacTextBox.Text + "'");
                BLL.ComputerBLL.BLLComputer_TKeys ComputerKey = new BLL.ComputerBLL.BLLComputer_TKeys();
                if (ComputerList.Find(a => a.Computer_nvc.Trim() == Hepsa.Core.Common.PersentationController.GetEntityValue(Computer_nvcComboBox.Text.Trim(), TypeCode.String).ToString() && a.Deleted_bit == false && a.MacAddress_nvc == MacTextBox.Text) == null)
                {
                    ComputerEntity.Computer_nvc    = Hepsa.Core.Common.PersentationController.GetEntityValue(Computer_nvcComboBox.Text, TypeCode.String).ToString();
                    ComputerEntity.IPAddress_nvc   = Hepsa.Core.Common.PersentationController.GetEntityValue(IPTextBox.Text, TypeCode.String).ToString();
                    ComputerEntity.MacAddress_nvc  = Hepsa.Core.Common.PersentationController.GetEntityValue(MacTextBox.Text, TypeCode.String).ToString();
                    ComputerEntity.MessageLED_nvc  = Hepsa.Core.Common.PersentationController.GetEntityValue(MessageLED_nvcTextBox.Text, TypeCode.String).ToString();
                    ComputerEntity.Active_bit      = Active_bitCheckBox.Checked;
                    ComputerEntity.UserGroupID_int = (Int32?)Hepsa.Core.Common.PersentationController.GetEntityValue(UserGroupID_intComboBox.SelectedValue, TypeCode.Int32);
                    ComputerFactory.BeginProc();
                    ComputerFactory.Insert(ComputerEntity);
                    ComputerFactory.CommitProc();
                }
                if (DataTable != null)
                {
                    DataRow dr = this.DataTable.NewRow();
                    dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.ComputerID_int.ToString()]  = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.ComputerID_int, TypeCode.Int32);
                    dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.Computer_nvc.ToString()]    = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.Computer_nvc, TypeCode.String);
                    dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.IPAddress_nvc.ToString()]   = Hepsa.Core.Common.PersentationController.GetEntityValue(IPTextBox.Text, TypeCode.String).ToString();
                    dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.MacAddress_nvc.ToString()]  = Hepsa.Core.Common.PersentationController.GetEntityValue(MacTextBox.Text, TypeCode.String).ToString();
                    dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.MessageLED_nvc.ToString()]  = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.MessageLED_nvc, TypeCode.String);
                    dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.Active_bit.ToString()]      = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.Active_bit, TypeCode.Boolean);
                    dr[HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.UserGroupID_int.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.UserGroupID_int, TypeCode.Int32);
                    dr["UserGroupID_intUserGroup_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(UserGroupID_intComboBox);

                    DataTable.Rows.Add(dr);
                    DataTable.AcceptChanges();
                }
                this.ClearForm(this);
            }
            catch (Exception ex)
            {
                ComputerFactory.RollBackProc();
                throw ex;
            }
        }
Example #8
0
        public void PopulateBusinessObjectFromReader(HPS.BLL.ComputerBLL.BLLComputer_T businessObject, IDataReader dataReader)
        {
            businessObject.ComputerID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.ComputerID_int.ToString()));
            businessObject.Computer_nvc   = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.Computer_nvc.ToString()));
            businessObject.IPAddress_nvc  = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.IPAddress_nvc.ToString()));
            businessObject.MacAddress_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.MacAddress_nvc.ToString()));
            if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.MessageLED_nvc.ToString())) == false)
            {
                businessObject.MessageLED_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.MessageLED_nvc.ToString()));
            }
            else
            {
                businessObject.MessageLED_nvc = String.Empty;
            }

            businessObject.Active_bit  = dataReader.GetBoolean(dataReader.GetOrdinal(HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.Active_bit.ToString()));
            businessObject.Deleted_bit = dataReader.GetBoolean(dataReader.GetOrdinal(HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.Deleted_bit.ToString()));

            businessObject.UserGroupID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.UserGroupID_int.ToString()));
        }
Example #9
0
        protected override void Edit()
        {
            HPS.BLL.ComputerBLL.BLLComputer_TFactory ComputerFactory = new HPS.BLL.ComputerBLL.BLLComputer_TFactory();
            try
            {
                HPS.BLL.ComputerBLL.BLLComputer_T ComputerEntity = new HPS.BLL.ComputerBLL.BLLComputer_T();
                ComputerEntity.Computer_nvc    = Hepsa.Core.Common.PersentationController.GetEntityValue(Computer_nvcComboBox.Text, TypeCode.String).ToString();
                ComputerEntity.IPAddress_nvc   = Hepsa.Core.Common.PersentationController.GetEntityValue(IPTextBox.Text, TypeCode.String).ToString();
                ComputerEntity.MacAddress_nvc  = Hepsa.Core.Common.PersentationController.GetEntityValue(MacTextBox.Text, TypeCode.String).ToString();
                ComputerEntity.MessageLED_nvc  = Hepsa.Core.Common.PersentationController.GetEntityValue(MessageLED_nvcTextBox.Text, TypeCode.String).ToString();
                ComputerEntity.Active_bit      = Active_bitCheckBox.Checked;
                ComputerEntity.UserGroupID_int = (Int32?)Hepsa.Core.Common.PersentationController.GetEntityValue(UserGroupID_intComboBox.SelectedValue, TypeCode.Int32);

                if (Hepsa.Core.Common.MessageBox.ConfirmMessage(HPS.Exceptions.ExceptionCs.EditMessage) == true)
                {
                    ComputerFactory.BeginProc();
                    ComputerFactory.Update(ComputerEntity, (HPS.BLL.ComputerBLL.BLLComputer_TKeys)Key);
                    ComputerFactory.CommitProc();
                    if (DataTable != null)
                    {
                        DataRow[] dr = DataTable.Select(HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.ComputerID_int.ToString() + "='" + ((HPS.BLL.ComputerBLL.BLLComputer_TKeys)Key).ComputerID_int.ToString() + "'");
                        if (dr.Length > 0)
                        {
                            dr[0][HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.Computer_nvc.ToString()]   = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.Computer_nvc, TypeCode.String);
                            dr[0][HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.IPAddress_nvc.ToString()]  = Hepsa.Core.Common.ApplicationInfo.IpAddress;
                            dr[0][HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.MacAddress_nvc.ToString()] = Hepsa.Core.Common.ApplicationInfo.MacAddress;
                            dr[0][HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.MessageLED_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.MessageLED_nvc, TypeCode.String);
                            dr[0][HPS.BLL.ComputerBLL.BLLComputer_T.Computer_TField.Active_bit.ToString()]     = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(ComputerEntity.Active_bit, TypeCode.Boolean);
                            dr[0]["UserGroupID_intUserGroup_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(UserGroupID_intComboBox);
                        }
                        DataTable.AcceptChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                ComputerFactory.RollBackProc();
                throw ex;
            }
        }
Example #10
0
        public void Update(HPS.BLL.ComputerBLL.BLLComputer_T businessObject, HPS.BLL.ComputerBLL.BLLComputer_TKeys businessObjectKey)
        {
            try
            {
                HPS.BLL.ComputerBLL.BLLComputer_T tmpComputer = this.GetBy(businessObjectKey);
                List <string> Except = new List <string>();
                if (businessObject.ComputerID_int == businessObjectKey.ComputerID_int)
                {
                    Except.Add("UniqueComputerID_int");
                }
                if (businessObject.MacAddress_nvc == tmpComputer.MacAddress_nvc)
                {
                    Except.Add("UniqueMacAddress_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);
            }
        }
Example #11
0
        protected override void Edit()
        {
            HPS.BLL.ComputerBLL.BLLComputer_TFactory ComputerFactory = new HPS.BLL.ComputerBLL.BLLComputer_TFactory();
            List <BLL.ComputerBLL.BLLComputer_T>     ComputerList    = new List <BLL.ComputerBLL.BLLComputer_T>();

            ComputerList = ComputerFactory.GetAllByCondition("MacAddress_nvc=N'" + MacTextBox.Text + "'");
            BLL.ComputerBLL.BLLComputer_TKeys ComputerKey = new BLL.ComputerBLL.BLLComputer_TKeys();
            foreach (BLL.ComputerBLL.BLLComputer_T item in ComputerList)
            {
                item.Deleted_bit           = true;
                ComputerKey.ComputerID_int = item.ComputerID_int;
                ComputerFactory.Update(item, ComputerKey);
            }
            try
            {
                HPS.BLL.ComputerBLL.BLLComputer_T ComputerEntity = new HPS.BLL.ComputerBLL.BLLComputer_T();
                foreach (Janus.Windows.GridEX.GridEXRow item in UserNameGridView.GetCheckedRows())
                {
                    ComputerEntity.ComputerID_int  = null;
                    ComputerEntity.Computer_nvc    = item.Cells["username_nvc"].Value.ToString();
                    ComputerEntity.IPAddress_nvc   = Hepsa.Core.Common.PersentationController.GetEntityValue(IPTextBox.Text, TypeCode.String).ToString();
                    ComputerEntity.MacAddress_nvc  = Hepsa.Core.Common.PersentationController.GetEntityValue(MacTextBox.Text, TypeCode.String).ToString();
                    ComputerEntity.MessageLED_nvc  = Hepsa.Core.Common.PersentationController.GetEntityValue(MessageLED_nvcTextBox.Text, TypeCode.String).ToString();
                    ComputerEntity.Active_bit      = Active_bitCheckBox.Checked;
                    ComputerEntity.UserGroupID_int = (Int32)item.Cells["UserGroupID_int"].Value;
                    ComputerFactory.BeginProc();
                    ComputerFactory.Insert(ComputerEntity);
                    ComputerFactory.CommitProc();
                }
            }
            catch (Exception ex)
            {
                ComputerFactory.RollBackProc();
                throw ex;
            }
        }
Example #12
0
        public void Insert(HPS.BLL.ComputerBLL.BLLComputer_T businessObject)
        {
            bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open);

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

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

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

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

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

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

                SqlParameter MessageLED_nvc = new SqlParameter();
                MessageLED_nvc.ParameterName = "@MessageLED_nvc";
                MessageLED_nvc.SqlDbType     = SqlDbType.NVarChar;
                MessageLED_nvc.Direction     = ParameterDirection.Input;
                MessageLED_nvc.IsNullable    = true;
                if (String.IsNullOrEmpty(businessObject.MessageLED_nvc))
                {
                    MessageLED_nvc.Value = DBNull.Value;
                }
                else
                {
                    MessageLED_nvc.Value = businessObject.MessageLED_nvc;
                }
                this.Command.Parameters.Add(MessageLED_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 UserGroupID_int = new SqlParameter();
                UserGroupID_int.ParameterName = "@UserGroupID_int";
                UserGroupID_int.SqlDbType     = SqlDbType.Int;
                UserGroupID_int.Direction     = ParameterDirection.Input;
                UserGroupID_int.IsNullable    = false;
                UserGroupID_int.Value         = businessObject.UserGroupID_int;
                this.Command.Parameters.Add(UserGroupID_int);

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

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

                this.Command.ExecuteNonQuery();

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

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