Esempio n. 1
0
        public void Update(Group obj)
        {
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = UPDATEGroup;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_ID, SqlDbType.Int);
            parameterID.Value = obj.ID;
            parameterID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterID);
            SqlParameter parameterName = new SqlParameter(PN_NAME, SqlDbType.NVarChar);
            parameterName.Value = obj.Name;
            parameterName.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterName);
            SqlParameter parameterDescription = new SqlParameter(PN_DESCRIPTION, SqlDbType.NVarChar);
            parameterDescription.Value = obj.Description;
            parameterDescription.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterDescription);
            #endregion;

            _connection.Open();
            _command.ExecuteNonQuery();
            _connection.Close();
        }
Esempio n. 2
0
 public void PopulateGroup(SqlDataReader _dtr, Group obj)
 {
     int columnIndex = 0;
     columnIndex = _dtr.GetOrdinal(GroupDataMapper.CN_ID);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.ID = _dtr.GetInt32((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(GroupDataMapper.CN_NAME);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Name = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(GroupDataMapper.CN_DESCRIPTION);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Description = _dtr.GetString((columnIndex));
     }
 }
Esempio n. 3
0
 private void EditMode()
 {
     if (ObjectID > 0)
     {
         Group cat = new Group();
         cat = GroupManager.GetByID(ObjectID);
         if (null == cat)
             return;
         txtName.Text = cat.Name;
         txtDesc.Text = cat.Description;
         plcControls.Visible = true;
     }
 }
Esempio n. 4
0
        void btnSaveUpdate_Click(object sender, EventArgs e)
        {

            Group Cat = new Group();
            if (ObjectID <= 0)
            {
                try
                {
                    Cat.Name = txtName.Text;
                    Cat.Description = txtDesc.Text;
                    GroupManager.Add(Cat);
                    AddMode();
                }
                catch (Exception ex)
                {
                    dvProblems.InnerText = ex.ToString();
                }

            }
            else
            {
                try
                {
                    Cat = GroupManager.GetByID(ObjectID);
                    if (null == Cat)
                    {
                        dvProblems.InnerText = Resources.ExpressCMS.ResourceManager.GetString(ConstantsManager.UnknowErronOccures);
                        return;
                    }
                    Cat.Name = txtName.Text;
                    Cat.Description = txtDesc.Text;
                    GroupManager.Update(Cat);
                    EditMode();
                }
                catch (Exception ex)
                {
                    dvProblems.InnerText = ex.ToString();
                }
            }
            BindGrid();
        }
Esempio n. 5
0
 public Group GetGroup(SqlDataReader _dtr, IList<Group> colobj)
 {
     Group obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_ID].ToString())).SingleOrDefault();
     if (null == obj)
     {
         obj = new Group();
         colobj.Add(obj);
     }
     return obj;
 }
Esempio n. 6
0
        public IList<Group> GetAll()
        {

            Group obj = null;

            IList<Group> colobj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTALLGroup;

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new Group();
                        colobj = new List<Group>();
                        while (_dtreader.Read())
                        {
                            obj = GetGroup(_dtreader, colobj);
                            GetEntityFromReader(_dtreader, obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                _dtreader.Close();
                _connection.Close();
            }

            return colobj;
        }
Esempio n. 7
0
 private void GetEntityFromReader(SqlDataReader _dtr, Group obj)
 {
     PopulateGroup(_dtr, obj);
 }
Esempio n. 8
0
        public Group GetByID(int ID)
        {

            Group obj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTGroup;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_ID, SqlDbType.Int);
            parameterID.Value = ID;
            parameterID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterID);
            #endregion;

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new Group();
                        if (_dtreader.Read())
                            GetEntityFromReader(_dtreader, obj);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                _dtreader.Close();
                _connection.Close();
            }

            return obj;
        }
Esempio n. 9
0
        public static void Update(Group obj)
        {
            GroupDataMapper objCaller = new GroupDataMapper();

            objCaller.Update(obj);
        }
Esempio n. 10
0
        public static int Add(Group obj)
        {
            GroupDataMapper objCaller = new GroupDataMapper();

            return objCaller.Add(obj);
        }