Example #1
0
        public int Add(Poll obj)
        {
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = INSERTPoll;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_ID, SqlDbType.Int);
            parameterID.Value = obj.ID;
            parameterID.Direction = ParameterDirection.Output;
            _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 parameterDate = new SqlParameter(PN_DATE, SqlDbType.NVarChar);
            parameterDate.Value = obj.Date;
            parameterDate.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterDate);
            SqlParameter parameterCreatedBy = new SqlParameter(PN_CREATEDBY, SqlDbType.Int);
            parameterCreatedBy.Value = obj.CreatedBy;
            parameterCreatedBy.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterCreatedBy);
            SqlParameter parameterIsClosed = new SqlParameter(PN_ISCLOSED, SqlDbType.Int);
            parameterIsClosed.Value = obj.IsClosed;
            parameterIsClosed.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterIsClosed);
            SqlParameter parameterIsDeleted = new SqlParameter(PN_ISDELETED, SqlDbType.Int);
            parameterIsDeleted.Value = obj.IsDeleted;
            parameterIsDeleted.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterIsDeleted);
            #endregion;

            _connection.Open();
            _command.ExecuteNonQuery();
            _connection.Close();
            obj.ID = Convert.ToInt32(parameterID.Value);
            return obj.ID;
        }
Example #2
0
        public static void Update(Poll obj)
        {
            PollDataMapper objCaller = new PollDataMapper();

            objCaller.Update(obj);
        }
Example #3
0
        public static int Add(Poll obj)
        {
            PollDataMapper objCaller = new PollDataMapper();

            return objCaller.Add(obj);
        }
Example #4
0
 public void PopulatePoll(SqlDataReader _dtr, Poll obj)
 {
     int columnIndex = 0;
     columnIndex = _dtr.GetOrdinal(PollDataMapper.CN_ID);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.ID = _dtr.GetInt32((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(PollDataMapper.CN_NAME);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Name = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(PollDataMapper.CN_DATE);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Date = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(PollDataMapper.CN_CREATEDBY);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.CreatedBy = _dtr.GetInt32((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(PollDataMapper.CN_ISCLOSED);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.IsClosed = _dtr.GetBoolean((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(PollDataMapper.CN_ISDELETED);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.IsDeleted = _dtr.GetBoolean((columnIndex));
     }
 }
Example #5
0
        private void EditMode()
        {
            if (ObjectID > 0)
            {
                TG.ExpressCMS.DataLayer.Entities.Poll _Poll = new TG.ExpressCMS.DataLayer.Entities.Poll();
                _Poll = PollManager.GetByID(ObjectID);
                if (null == _Poll)
                    return;
                txtDate.Text = _Poll.Date;

                txtName.Text = _Poll.Name;
                chkClosed.Checked = _Poll.IsClosed;
                plcControls.Visible = true;
                BindGridDet();
                upnlPollDetails.Update();
            }
        }
Example #6
0
        void btnSaveUpdate_Click(object sender, EventArgs e)
        {

            Poll _Poll = new TG.ExpressCMS.DataLayer.Entities.Poll();
            if (ObjectID <= 0)
            {
                try
                {
                    _Poll.Date = DateTime.Now.ToString("dd/MM/yyyy");
                    _Poll.CreatedBy = SecurityContext.LoggedInUser.ID;
                    _Poll.IsClosed = chkClosed.Checked;
                    _Poll.IsDeleted = false;
                    _Poll.Name = txtName.Text;
                    PollManager.Add(_Poll);
                    AddMode();
                    dvProblems.InnerText = "Saved Successfully";
                }
                catch (Exception ex)
                {
                    dvProblems.InnerText = ex.ToString();
                }

            }
            else
            {
                try
                {

                    _Poll = PollManager.GetByID(ObjectID);

                    _Poll.Date = DateTime.Now.ToString("dd/MM/yyyy");
                    _Poll.CreatedBy = SecurityContext.LoggedInUser.ID;
                    _Poll.IsClosed = chkClosed.Checked;
                    _Poll.IsDeleted = false;
                    _Poll.Name = txtName.Text;
                    if (null == _Poll)
                    {
                        dvProblems.InnerText = Resources.ExpressCMS.ResourceManager.GetString(ConstantsManager.UnknowErronOccures);
                        return;
                    }
                    PollManager.Update(_Poll);
                    EditMode();
                    dvProblems.InnerText = "Saved Successfully";
                }
                catch (Exception ex)
                {
                    dvProblems.InnerText = ex.ToString();
                }
            }
            BindGrid();
            BindGridDet();
        }
Example #7
0
 public Poll GetPoll(SqlDataReader _dtr, IList<Poll> colobj)
 {
     Poll obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_ID].ToString())).SingleOrDefault();
     if (null == obj)
     {
         obj = new Poll();
         colobj.Add(obj);
     }
     return obj;
 }
Example #8
0
        public IList<Poll> GetAll()
        {

            Poll obj = null;

            IList<Poll> colobj = new List<Poll>();
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTALLPoll;

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

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

            return colobj;
        }
Example #9
0
 private void GetEntityFromReader(SqlDataReader _dtr, Poll obj)
 {
     PopulatePoll(_dtr, obj);
 }
Example #10
0
        public Poll GetByID(int ID)
        {

            Poll obj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTPoll;

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

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

            return obj;
        }