Ejemplo n.º 1
0
        void btnSaveUpdate_Click(object sender, EventArgs e)
        {
            string result = string.Empty;
            TG.ExpressCMS.DataLayer.Entities.Contact _contact = new TG.ExpressCMS.DataLayer.Entities.Contact();
            _contact = ContactManager.GetByEmail(txtEmail.Text);
            if (null != _contact)
            {
                dvMessage.InnerText = Resources.ExpressCMS.YouEmailAlreadyregistered;
                return;
            }
            _contact = new DataLayer.Entities.Contact();
            _contact.Country = HttpUtility.HtmlEncode(txtCountry.Text);
            _contact.Email = HttpUtility.HtmlEncode(txtEmail.Text);
            _contact.Notes = HttpUtility.HtmlEncode(txtDescription.Text);
            _contact.FirstName = HttpUtility.HtmlEncode(txtName.Text);
            _contact.SurName = HttpUtility.HtmlEncode(txtSurname.Text);
            _contact.Phone2 = "";
            _contact.ZipCode = "";
            _contact.Company = "";
            _contact.Guid = Guid.NewGuid().ToString();
            _contact.Mobile = HttpUtility.HtmlEncode(txtPhone.Text);
            _contact.IsDeleted = false;
            _contact.Status = TG.ExpressCMS.DataLayer.Enums.RootEnums.ContactStatus.InActive;

            ContactManager.Add(_contact);
            ScriptManager.RegisterStartupScript(upnall, upnall.GetType(), Guid.NewGuid().ToString().Substring(0, 4), "alert('" + Resources.ExpressCMS.YouHadbeenRegisteredSuccessfully + "');", true);
            ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString().Substring(0, 4), "alert('" + Resources.ExpressCMS.YouHadbeenRegisteredSuccessfully + "');", true);
            if (_contact.ID > 0)
            {
                ScriptManager.RegisterStartupScript(upnall, upnall.GetType(), "SSSd", "alert('" + Resources.ExpressCMS.ResourceManager.GetString("NewsLetterSuccessSubscribtion") + "');", true);
                EmailSender.EmailSenderSoapClient emailSender = new EmailSender.EmailSenderSoapClient();
                //    EmailSender emailSender = new EmailSender();
                emailSender.AddemailtoQueueNow(_contact.ID, _contact.Email, _contact.FullName, EmailContext.GetConfirmationText(_contact.FirstName, _contact.Email), "NoTImeFORLove");

                emailSender.ProcessAllPendingEmail("NoTImeFORLove");
                dvMessage.InnerText = Resources.ExpressCMS.YouHadbeenRegisteredSuccessfully;
                ScriptManager.RegisterStartupScript(upnall, upnall.GetType(), Guid.NewGuid().ToString().Substring(0, 4), "alert('" + Resources.ExpressCMS.YouHadbeenRegisteredSuccessfully + "');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(upnall, upnall.GetType(), "SSSd1", "alert('" + Resources.ExpressCMS.ResourceManager.GetString("NewsLetterFailedSubscribtion") + "');", true);
            }

            AddMode();

            dvMessage.InnerText = Resources.ExpressCMS.ResourceManager.GetString("NewsLetterSuccessSubscribtion");
        }
Ejemplo n.º 2
0
 public void PopulateContact(SqlDataReader _dtr, Contact obj)
 {
     int columnIndex = 0;
     columnIndex = _dtr.GetOrdinal(ContactDataMapper.CN_ID);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.ID = _dtr.GetInt32((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(ContactDataMapper.CN_FIRSTNAME);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.FirstName = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(ContactDataMapper.CN_SURNAME);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.SurName = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(ContactDataMapper.CN_EMAIL);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Email = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(ContactDataMapper.CN_MOBILE);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Mobile = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(ContactDataMapper.CN_PHONE2);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Phone2 = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(ContactDataMapper.CN_ZIPCODE);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.ZipCode = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(ContactDataMapper.CN_GUID);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Guid = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(ContactDataMapper.CN_STATUS);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Status = (TG.ExpressCMS.DataLayer.Enums.RootEnums.ContactStatus)_dtr.GetInt32((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(ContactDataMapper.CN_ISDELETED);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.IsDeleted = _dtr.GetBoolean((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(ContactDataMapper.CN_COUNTRY);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Country = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(ContactDataMapper.CN_COMPANY);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Company = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(ContactDataMapper.CN_NOTES);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Notes = _dtr.GetString((columnIndex));
     }
 }
Ejemplo n.º 3
0
        public IList<Contact> GetByGroupID(int groupID)
        {

            Contact obj = null;

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


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

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new Contact();

                        while (_dtreader.Read())
                        {
                            obj = GetContact(_dtreader, colobj);
                            GetEntityFromReader(_dtreader, obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

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

            return colobj;
        }
Ejemplo n.º 4
0
 public Contact GetContact(SqlDataReader _dtr, IList<Contact> colobj)
 {
     Contact obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_ID].ToString())).SingleOrDefault();
     if (null == obj)
     {
         obj = new Contact();
         colobj.Add(obj);
     }
     return obj;
 }
Ejemplo n.º 5
0
 private void GetEntityFromReader(SqlDataReader _dtr, Contact obj)
 {
     PopulateContact(_dtr, obj);
 }
Ejemplo n.º 6
0
        public IList<Contact> GetAll()
        {

            Contact obj = null;

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

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

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

            return colobj;
        }
Ejemplo n.º 7
0
        public Contact GetByEmail(string eMail)
        {

            Contact obj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = "dbo.[usp_SelectContactByEmail]";

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_EMAIL, SqlDbType.NVarChar);
            parameterID.Value = eMail;
            parameterID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterID);
            #endregion;

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

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

            return obj;
        }
Ejemplo n.º 8
0
        public Contact GetByID(int ID)
        {

            Contact obj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTContact;

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

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

            return obj;
        }
Ejemplo n.º 9
0
        public void Update(Contact obj)
        {
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = UPDATEContact;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_ID, SqlDbType.Int);
            parameterID.Value = obj.ID;
            parameterID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterID);
            SqlParameter parameterFirstName = new SqlParameter(PN_FIRSTNAME, SqlDbType.NVarChar);
            parameterFirstName.Value = obj.FirstName;
            parameterFirstName.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterFirstName);
            SqlParameter parameterSurName = new SqlParameter(PN_SURNAME, SqlDbType.NVarChar);
            parameterSurName.Value = obj.SurName;
            parameterSurName.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterSurName);
            SqlParameter parameterEmail = new SqlParameter(PN_EMAIL, SqlDbType.NVarChar);
            parameterEmail.Value = obj.Email;
            parameterEmail.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterEmail);
            SqlParameter parameterMobile = new SqlParameter(PN_MOBILE, SqlDbType.NVarChar);
            parameterMobile.Value = obj.Mobile;
            parameterMobile.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterMobile);
            SqlParameter parameterPhone2 = new SqlParameter(PN_PHONE2, SqlDbType.NVarChar);
            parameterPhone2.Value = obj.Phone2;
            parameterPhone2.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterPhone2);
            SqlParameter parameterZipCode = new SqlParameter(PN_ZIPCODE, SqlDbType.NVarChar);
            parameterZipCode.Value = obj.ZipCode;
            parameterZipCode.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterZipCode);
            SqlParameter parameterGuid = new SqlParameter(PN_GUID, SqlDbType.NVarChar);
            parameterGuid.Value = obj.Guid;
            parameterGuid.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterGuid);
            SqlParameter parameterStatus = new SqlParameter(PN_STATUS, SqlDbType.Int);
            parameterStatus.Value = Convert.ToInt32(obj.Status);
            parameterStatus.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterStatus);
            SqlParameter parameterIsDeleted = new SqlParameter(PN_ISDELETED, SqlDbType.Int);
            parameterIsDeleted.Value = obj.IsDeleted;
            parameterIsDeleted.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterIsDeleted);
            SqlParameter parameterCountry = new SqlParameter(PN_COUNTRY, SqlDbType.NVarChar);
            parameterCountry.Value = obj.Country;
            parameterCountry.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterCountry);
            SqlParameter parameterCompany = new SqlParameter(PN_COMPANY, SqlDbType.NVarChar);
            parameterCompany.Value = obj.Company;
            parameterCompany.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterCompany);
            SqlParameter parameterNotes = new SqlParameter(PN_NOTES, SqlDbType.NVarChar);
            parameterNotes.Value = obj.Notes;
            parameterNotes.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterNotes);
            #endregion;

            _connection.Open();
            _command.ExecuteNonQuery();
            _connection.Close();
        }
Ejemplo n.º 10
0
        public static void Update(Contact obj)
        {
            ContactDataMapper objCaller = new ContactDataMapper();

            objCaller.Update(obj);
        }
Ejemplo n.º 11
0
        public static int Add(Contact obj)
        {
            ContactDataMapper objCaller = new ContactDataMapper();

            return objCaller.Add(obj);
        }