private void LoadEmails() { //create instance of the EmailCollection clsEmailCollection Emails = new clsEmailCollection(); //set the data source to the list of emails in the collection class dataGridViewInbox.DataSource = FillGridArchive(); //hide the emailAddressNo dataGridViewInbox.Columns["EmailAddressNo"].Visible = false; //hide the timestamp dataGridViewInbox.Columns["EmailTimeStamp"].Visible = false; //hide the archive no dataGridViewInbox.Columns["ArchiveNo"].Visible = false; dataGridViewInbox.Columns["EmailNo"].Visible = false; try { //this safeguards us incase somebody clicks the "view email" button before selecting a row Int32 SelectedIndex = 0; //this puts the emailno and emailaddressno ready for the parameters to frmViewEmail ArchiveNo = Convert.ToInt32(dataGridViewInbox["ArchiveNo", SelectedIndex].Value); EmailAddressNo = Convert.ToInt32(dataGridViewInbox["EmailAddressNo", SelectedIndex].Value); EmailNo = Convert.ToInt32(dataGridViewInbox["EmailNo", SelectedIndex].Value); } catch { MessageBox.Show("There are no Emails in the archive!"); this.Close(); } }
public void GetEmailAddressOK() { //create instance of the class clsEmailCollection AllEmails = new clsEmailCollection(); string LocalEmailAddress = "*****@*****.**"; //check to see if it works ok string DatabaseEmailAdddress = AllEmails.GetEmailAddress(1); Assert.AreEqual(LocalEmailAddress, DatabaseEmailAdddress); }
public void ViewArchiveEmail(int EmailAddressNo, int ArchiveNo) { clsEmail OneEmail = new clsEmail(); clsEmailCollection AllEmails = new clsEmailCollection(); EmailAddress = AllEmails.GetEmailAddress(EmailAddressNo); bool IsArchive = true; AllEmails.GetOneEmail(ArchiveNo, IsArchive, out EmailSubject, out EmailContent); txtBxSubject.Text = EmailSubject; txtBxContent.Text = EmailContent; txtBxFrom.Text = EmailAddress; }
//this will be the function that shows the new email and it accepts the emailno selected in //the datagridview public void NewEmail(int EmailAddressNo, int EmailNo) { //txtBxFrom.Text = Convert.ToString(EmailAddressNo); clsEmail OneEmail = new clsEmail(); clsEmailCollection AllEmails = new clsEmailCollection(); EmailAddress = AllEmails.GetEmailAddress(EmailAddressNo); bool IsArchive = false; AllEmails.GetOneEmail(EmailNo, IsArchive, out EmailSubject, out EmailContent); txtBxSubject.Text = EmailSubject; txtBxContent.Text = EmailContent; txtBxFrom.Text = EmailAddress; }
private List<clsEmail> FillGridArchive() { //instance of the database connection class clsDataConnection DB = new clsDataConnection(); List<clsEmail> allEmails = new List<clsEmail>(); //exectue the stored procedure DB.Execute("sproc_tblArchive_SelectAll"); //get the count Int32 RecordCount = DB.Count; //set up index for the loop Int32 Index = 0; //while there are records to process while (Index < RecordCount) { //create a new instance of the email class clsEmail AEmail = new clsEmail(); //create instance of clsEmailCollection class clsEmailCollection ACollectionEmail = new clsEmailCollection(); //get the archive number AEmail.ArchiveNo = DB.DataTable.Rows[Index]["ArchiveNo"].ToString(); //get the email subject AEmail.EmailSubject = DB.DataTable.Rows[Index]["EmailSubject"].ToString(); //get the primary key AEmail.EmailNo = Convert.ToInt32(DB.DataTable.Rows[Index]["EmailNo"]); //get the email Content AEmail.EmailContent = DB.DataTable.Rows[Index]["EmailContent"].ToString(); //get the email address recieving AEmail.EmailAddressNo = Convert.ToInt32(DB.DataTable.Rows[Index]["EmailAddressNo"]); //passess the EmailAddressNo to get the EmailAddress AEmail.EmailAddress = ACollectionEmail.GetEmailAddress(AEmail.EmailAddressNo); //add the Email to the private data allEmails.Add(AEmail); //add to the index Index++; } return allEmails; }
public void ListEmailsAndCountOK() { //create an instance of the class we want to create clsEmailCollection AllAddresses = new clsEmailCollection(); //create some test data to assign to the property //in this case the data needs to be a list of objects List<clsEmail> TestList = new List<clsEmail>(); //add an item to the list //create the item of test data clsEmail TestItem = new clsEmail(); //set its properties TestItem.EmailAddress = "*****@*****.**"; TestItem.EmailAddressNo = 1; TestItem.EmailSubject = "blahblah"; TestItem.EmailContent = "blahblahblahblah"; //add the item to the test list TestList.Add(TestItem); //assign the data to the property AllAddresses.AllEmails = TestList; //test to see that the two values are the same Assert.AreEqual(AllAddresses.CountEmails, TestList.Count); }
private void FrmViewInbox_Load(object sender, EventArgs e) { //new form Form f = new Form(); //define the size of the form f.Size = new Size(400, 200); //make no border style f.FormBorderStyle = FormBorderStyle.None; //don't minimize the box f.MinimizeBox = false; //change the background colour f.BackColor = System.Drawing.Color.DarkBlue; //change the text in the form f.Text = "Just Loading"; //don't maximise box f.MaximizeBox = true; //initalise the new resource manager ResourceManager rm = Resources.ResourceManager; //add the bitmap image Image im = (Bitmap)rm.GetObject("Spinning_Gif"); //initalise the picturebox PictureBox pb = new PictureBox(); //fill the dock pb.Dock = DockStyle.Fill; pb.Image = im; pb.Location = new Point(5, 5); //show the form and add the controls. f.Controls.Add(pb); f.Show(); //this protects us for any internet connection outages bool Result = CheckForInternetConnection(); //this runs if the internet connection is all ok if (Result == true) { //create instance of the EmailCollection clsEmailCollection Emails = new clsEmailCollection(); //this will add new emails from the server online Emails.UpdateEmails(); LoadEmails(); f.Close(); } else { LoadEmails(); //this runs if the internet connection is not good. MessageBox.Show("You must have an active internet connection to retrieve latest emails."); f.Close(); } }
private void LoadEmails() { //create instance of the EmailCollection clsEmailCollection Emails = new clsEmailCollection(); //set the data source to the list of emails in the collection class dataGridViewInbox.DataSource = Emails.AllEmails; //hide the emailTimeStamp dataGridViewInbox.Columns["EmailTimeStamp"].Visible = false; //hide the Email Content, this is for the viewEmail page dataGridViewInbox.Columns["EmailContent"].Visible = false; //hide the emailNo dataGridViewInbox.Columns["EmailNo"].Visible = false; //hide the archive no dataGridViewInbox.Columns["ArchiveNo"].Visible = false; //hide the emailAddressNo dataGridViewInbox.Columns["EmailAddressNo"].Visible = false; //this safeguards us incase somebody clicks the "view email" button before selecting a row Int32 SelectedIndex = 0; //this puts the emailno and emailaddressno ready for the parameters to frmViewEmail EmailNo = (Int32)dataGridViewInbox["EmailNo", SelectedIndex].Value; EmailAddressNo = (Int32)dataGridViewInbox["EmailAddressNo", SelectedIndex].Value; }
public void CheckIfUpdatedEmails() { clsEmailCollection Emails = new clsEmailCollection(); Emails.UpdateEmails(); }