示例#1
0
        /**
         *
         */
        private void PopulateDb()
        {
            string       line;
            StreamReader reader = new StreamReader(localDbPath);

            while ((line = reader.ReadLine()) != null)
            {
                string[] fields = line.Split(UserContactInformation.separator.ToCharArray());

                if (fields.Length == 6)
                {
                    UserContactInformation userInfo = new UserContactInformation();

                    userInfo.Email       = fields[0];
                    userInfo.FirstName   = fields[1];
                    userInfo.LastName    = fields[2];
                    userInfo.HomePhone   = fields[3];
                    userInfo.MobilePhone = fields[4];
                    userInfo.Message     = fields[5];

                    database.Add(userInfo.Email, userInfo);
                }
            }

            reader.Close();
        }
示例#2
0
 /**
  *
  */
 public void WriteDb(string key, UserContactInformation value)
 {
     if (!database.ContainsKey(key))
     {
         database.Add(key, value);
     }
     else
     {
         database.Remove(key);
         database.Add(key, value);
     }
 }
        /**
         * Treating the button click event.
         */
        protected void sendButton_Click(object sender, EventArgs e)
        {
            UserContactInformation userContactInfo = new UserContactInformation();

            userContactInfo.Email       = emailText.Text;
            userContactInfo.FirstName   = firstNameText.Text;
            userContactInfo.LastName    = lastNameText.Text;
            userContactInfo.HomePhone   = homePhoneText.Text;
            userContactInfo.MobilePhone = mobilePhoneText.Text;
            userContactInfo.Message     = messageText.Text;

            database.WriteDb(userContactInfo.Email, userContactInfo);

            emailText.Text       = "";
            firstNameText.Text   = "";
            lastNameText.Text    = "";
            homePhoneText.Text   = "";
            mobilePhoneText.Text = "";
            messageText.Text     = "";

            Response.Write("<script>alert('Contact information recorded sucessfully!')</script>");
        }