示例#1
0
        public void Update(PollDetails obj)
        {
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = UPDATEPollDetails;

            #region [Parameters]
            SqlParameter pollID = new SqlParameter(PN_ID, SqlDbType.Int);
            pollID.Value = obj.ID;
            pollID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(pollID);
            SqlParameter parameterPollID = new SqlParameter(PN_POLLID, SqlDbType.Int);
            parameterPollID.Value = obj.PollID;
            parameterPollID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterPollID);
            SqlParameter parameterName = new SqlParameter(PN_NAME, SqlDbType.NVarChar);
            parameterName.Value = obj.Name;
            parameterName.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterName);
            SqlParameter parameterCount = new SqlParameter(PN_COUNT, SqlDbType.Int);
            parameterCount.Value = obj.Count;
            parameterCount.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterCount);
            #endregion;

            _connection.Open();
            _command.ExecuteNonQuery();
            _connection.Close();
        }
示例#2
0
        public void PopulatePollDetails(SqlDataReader _dtr, PollDetails obj)
        {
            int columnIndex = 0;
            columnIndex = _dtr.GetOrdinal(PollDetailsDataMapper.CN_ID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.ID = _dtr.GetInt32((columnIndex));
            }

            columnIndex = _dtr.GetOrdinal(PollDetailsDataMapper.CN_POLLID);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.PollID = _dtr.GetInt32((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(PollDetailsDataMapper.CN_NAME);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Name = _dtr.GetString((columnIndex));
            }
            columnIndex = _dtr.GetOrdinal(PollDetailsDataMapper.CN_COUNT);
            if (!_dtr.IsDBNull(columnIndex))
            {
                obj.Count = _dtr.GetInt32((columnIndex));
            }
        }
示例#3
0
        private void EditModeDet()
        {
            if (ObjectID > 0)
            {
                TG.ExpressCMS.DataLayer.Entities.PollDetails _PollDetails = new TG.ExpressCMS.DataLayer.Entities.PollDetails();
                _PollDetails = PollDetailsManager.GetByID(DetObjectID);
                if (null == _PollDetails)
                    return;
                txtPollDetailsName.Text = _PollDetails.Name;

                plcControlsDetails.Visible = true;
            }
        }
示例#4
0
        void btnSaveUpdateDet_Click(object sender, EventArgs e)
        {

            PollDetails _PollDetails = new TG.ExpressCMS.DataLayer.Entities.PollDetails();
            if (DetObjectID <= 0)
            {
                try
                {
                    _PollDetails.PollID = ObjectID;
                    _PollDetails.Name = txtPollDetailsName.Text;
                    _PollDetails.Count = 1;
                    PollDetailsManager.Add(_PollDetails);
                    AddModeDet();
                    dvPolldet.InnerText = "Saved Successfully";
                    Session["_poll"] = null;
                }
                catch (Exception ex)
                {
                    dvPolldet.InnerText = ex.ToString();
                }

            }
            else
            {
                try
                {

                    _PollDetails = PollDetailsManager.GetByID(ObjectID);
                    _PollDetails.PollID = ObjectID;

                    _PollDetails.Name = txtPollDetailsName.Text;
                    if (null == _PollDetails)
                    {
                        dvProblems.InnerText = Resources.ExpressCMS.ResourceManager.GetString(ConstantsManager.UnknowErronOccures);
                        return;
                    }
                    PollDetailsManager.Update(_PollDetails);
                    EditModeDet();
                    dvPolldet.InnerText = "Saved Successfully";
                    Session["_poll"] = null;
                }
                catch (Exception ex)
                {
                    dvPolldet.InnerText = ex.ToString();
                }
            }
            BindGridDet();
        }
示例#5
0
        public IList<PollDetails> GetByPollID(int pollID)
        {

            PollDetails obj = null;

            IList<PollDetails> colobj = new List<PollDetails>();
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = "[usp_SelectPollDetailByPollID]";

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

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

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

            return colobj;
        }
示例#6
0
 public PollDetails GetPollDetails(SqlDataReader _dtr, IList<PollDetails> colobj)
 {
     PollDetails obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_ID].ToString())).SingleOrDefault();
     if (null == obj)
     {
         obj = new PollDetails();
         colobj.Add(obj);
     }
     return obj;
 }
示例#7
0
        public IList<PollDetails> GetAll()
        {

            PollDetails obj = null;

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

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

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

            return colobj;
        }
示例#8
0
 private void GetEntityFromReader(SqlDataReader _dtr, PollDetails obj)
 {
     PopulatePollDetails(_dtr, obj);
 }
示例#9
0
        public PollDetails GetByID(int ID)
        {

            PollDetails obj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTPollDetails;

            #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 PollDetails();
                        if (_dtreader.Read())
                            GetEntityFromReader(_dtreader, obj);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

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

            return obj;
        }
示例#10
0
        public static void Update(PollDetails obj)
        {
            PollDetailsDataMapper objCaller = new PollDetailsDataMapper();

            objCaller.Update(obj);
        }
示例#11
0
        public static int Add(PollDetails obj)
        {
            PollDetailsDataMapper objCaller = new PollDetailsDataMapper();

            return objCaller.Add(obj);
        }