Example #1
0
        //  Load data file sets max date to this year and sets add mode.

        private void RebateForm_Load(object sender, EventArgs e)
        {
            RebateFileHandler rebate_File = new RebateFileHandler();

            rebate_File.ReadRebateList(RebateList);

            Date.MaxDate         = new DateTime(DateTime.Now.Year, 12, 31);
            UndoMenuItem.Enabled = false;
            SetAddMode();
        }
Example #2
0
        // Removes record from ListView when delete is pressed and writes to file.

        private void Delete_Click(object sender, EventArgs e)
        {
            deletedRecord      = (RebateRecord)RebateList.SelectedItems[0].Tag;
            deletedRecordIndex = RebateList.SelectedItems[0].Index;
            RebateList.SelectedItems[0].Remove();
            RebateFileHandler rebate_File = new RebateFileHandler();

            rebate_File.WriteRebateList(RebateList);
            UndoMenuItem.Enabled = true;
            ClearForm();

            Status_label.Text = "Deleted Rebate";
        }
Example #3
0
        // After saving, the records are written to file.
        private void Save_Click(object sender, EventArgs e)
        {
            RebateRecord      entered_Record;
            RebateFileHandler rebate_File = new RebateFileHandler();

            switch (curr_Mode)
            {
            case ADD:
                entered_Record               = new RebateRecord();
                entered_Record.firstName     = firstName.Text;
                entered_Record.middleInitial = Minitial.Text;
                entered_Record.lastName      = lastName.Text;
                entered_Record.Address1      = Address1.Text;
                entered_Record.Address2      = Address2.Text;
                entered_Record.City          = City.Text;
                entered_Record.State         = State.Text;
                entered_Record.Zip           = new string(Zip.Text.Where(char.IsDigit).ToArray());
                entered_Record.Gender        = Gender.Text;
                entered_Record.Phone         = new string(Phone.Text.Where(char.IsDigit).ToArray());
                entered_Record.Email         = Email.Text;
                entered_Record.Proof         = Proof.Text;
                entered_Record.Date          = Date.Value;
                entered_Record.StartTime     = start_time;
                entered_Record.SaveTime      = DateTime.Now;
                entered_Record.Backspace     = backSpace_count;
                if (!SearchListViewItem(RebateList, entered_Record))
                {
                    AddListViewItem(RebateList, entered_Record);

                    rebate_File.WriteRebateList(RebateList);

                    ClearForm();
                }
                break;

            case MODIFY:
                entered_Record               = new RebateRecord((RebateRecord)RebateList.SelectedItems[0].Tag);
                entered_Record.firstName     = firstName.Text;
                entered_Record.middleInitial = Minitial.Text;
                entered_Record.lastName      = lastName.Text;
                entered_Record.Address1      = Address1.Text;
                entered_Record.Address2      = Address2.Text;
                entered_Record.City          = City.Text;
                entered_Record.State         = State.Text;
                entered_Record.Zip           = new string(Zip.Text.Where(char.IsDigit).ToArray());
                entered_Record.Gender        = Gender.Text;
                entered_Record.Phone         = new string(Phone.Text.Where(char.IsDigit).ToArray());
                entered_Record.Email         = Email.Text;
                entered_Record.Proof         = Proof.Text;
                entered_Record.Date          = Date.Value;
                if (!SearchListViewItem(RebateList, entered_Record))
                {
                    ModifyListViewItem(RebateList, entered_Record);

                    rebate_File.WriteRebateList(RebateList);

                    ClearForm();
                }
                break;
            }
        }