Пример #1
0
        private void ListViewRebateRecords_EditEvent()
        {
            //First changes the mode to EditMode
            ChangeCurrentMode(Domain.CurrentMode.editMode);

            //Enables Delte Button
            btnDelete.Enabled = true;

            //Does not do the edit event if there are no selected items
            if (listViewRebateRecords.SelectedItems.Count == 0)
            {
                return;
            }

            //Obtains rebateInfo from single selected item
            Domain.RebateInfo rebateInfo = (Domain.RebateInfo)listViewRebateRecords.SelectedItems[0].Tag;

            //Populates fields from rebateInfo
            txtFirstName.Text                = rebateInfo.Fname;
            txtMiddleInitial.Text            = rebateInfo.Minit;
            txtLastName.Text                 = rebateInfo.Lname;
            txtAddrLine1.Text                = rebateInfo.Addr1;
            txtAddrLine2.Text                = rebateInfo.Addr2;
            txtCity.Text                     = rebateInfo.City;
            txtState.Text                    = rebateInfo.State;
            txtZipCode.Text                  = rebateInfo.Zip;
            cboGender.SelectedIndex          = cboGender.FindStringExact(rebateInfo.Gender);
            masktxtPhoneNum.Text             = rebateInfo.PhoneNum;
            txtEmail.Text                    = rebateInfo.Email;
            cboProofPurchase.SelectedIndex   = cboProofPurchase.FindStringExact(rebateInfo.ProofPurchase);
            dateTimePickerDateReceived.Value = DateTime.ParseExact(rebateInfo.DateRecieved, "M/dd/yyyy", CultureInfo.InvariantCulture);

            //After populating it will check for valid (should be valid)
            CheckFields_ShowErrorColors();
        }
Пример #2
0
        private void AddMode_Save(Domain.RebateInfo rebateInfo)
        {
            //Add ListViewItem to ListView
            ListViewItem item = new ListViewItem(new[] { rebateInfo.Fname, rebateInfo.Lname, rebateInfo.PhoneNum });

            item.Tag = rebateInfo;
            listViewRebateRecords.Items.Add(item);
        }
Пример #3
0
        private Boolean CheckUnique()
        {
            Boolean uniqueFlag = false;

            if (BLL.BLLSingleton.Instance.currentMode.Equals(Domain.CurrentMode.addMode))
            {
                if (BLL.BLLSingleton.Instance.CheckUnique(txtFirstName.Text, txtLastName.Text, masktxtPhoneNum.Text))
                {
                    lblFirstName.BackColor = default(Color);
                    lblLastName.BackColor  = default(Color);
                    lblPhoneNum.BackColor  = default(Color);
                    uniqueFlag             = true;
                }
                else
                {
                    lblFirstName.BackColor = Color.Red;
                    lblLastName.BackColor  = Color.Red;
                    lblPhoneNum.BackColor  = Color.Red;
                    uniqueFlag             = false;
                }
            }

            if (BLL.BLLSingleton.Instance.currentMode.Equals(Domain.CurrentMode.editMode))
            {
                //Does not do the follwing if there are no selected items
                if (listViewRebateRecords.SelectedItems.Count == 0)
                {
                    return(false);
                }

                Domain.RebateInfo rebateInfo = (Domain.RebateInfo)listViewRebateRecords.SelectedItems[0].Tag;

                Boolean currentRecordMatch = false;

                if (txtFirstName.Text.Equals(rebateInfo.Fname) && txtLastName.Text.Equals(rebateInfo.Lname) && masktxtPhoneNum.Text.Equals(rebateInfo.PhoneNum))
                {
                    currentRecordMatch = true;
                }

                if (BLL.BLLSingleton.Instance.CheckUnique(txtFirstName.Text, txtLastName.Text, masktxtPhoneNum.Text) || currentRecordMatch)
                {
                    lblFirstName.BackColor = default(Color);
                    lblLastName.BackColor  = default(Color);
                    lblPhoneNum.BackColor  = default(Color);
                    uniqueFlag             = true;
                }
                else
                {
                    lblFirstName.BackColor = Color.Red;
                    lblLastName.BackColor  = Color.Red;
                    lblPhoneNum.BackColor  = Color.Red;
                    uniqueFlag             = false;
                }
            }


            return(uniqueFlag);
        }
Пример #4
0
        private ICollection <Domain.RebateInfo> RebateInfoListViewToList(ListView listView)
        {
            List <Domain.RebateInfo> rebateInfos = new List <Domain.RebateInfo>();

            foreach (ListViewItem item in listView.Items)
            {
                Domain.RebateInfo tempRebateInfo = (Domain.RebateInfo)item.Tag;

                rebateInfos.Add(tempRebateInfo);
            }

            return(rebateInfos);
        }
Пример #5
0
        private void EditMode_Save(Domain.RebateInfo rebateInfo)
        {
            //Does not do the follwing if there are no selected items
            if (listViewRebateRecords.SelectedItems.Count == 0)
            {
                return;
            }

            //Get selected ListViewItem
            ListViewItem selectedItem = listViewRebateRecords.SelectedItems[0];

            //Set new values to ListView
            selectedItem.SubItems[0].Text = rebateInfo.Fname;
            selectedItem.SubItems[1].Text = rebateInfo.Lname;
            selectedItem.SubItems[2].Text = rebateInfo.PhoneNum;
            selectedItem.Tag = rebateInfo;
        }
Пример #6
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            //First records when button save was clicked. Also checks if its in addmode
            if (mainform_TimePressedSave.Equals(Domain.CurrentMode.defaultHiddenVarTime) && BLL.BLLSingleton.Instance.currentMode.Equals(Domain.CurrentMode.addMode))
            {
                mainform_TimePressedSave = DateTime.Now.ToString();
            }

            //testing
            //MessageBox.Show(mainform_TimeFirstEntered);
            //MessageBox.Show(mainform_TimePressedSave);
            //MessageBox.Show(mainform_NumPressedBackSpace.ToString());

            if (FieldsValidation())
            {
                //First creates a rebateInfo to store field data
                Domain.RebateInfo rebateInfo = new Domain.RebateInfo();
                rebateInfo.Fname         = txtFirstName.Text;
                rebateInfo.Minit         = txtMiddleInitial.Text;
                rebateInfo.Lname         = txtLastName.Text;
                rebateInfo.Addr1         = txtAddrLine1.Text;
                rebateInfo.Addr2         = txtAddrLine2.Text;
                rebateInfo.City          = txtCity.Text;
                rebateInfo.State         = txtState.Text;
                rebateInfo.Zip           = txtZipCode.Text;
                rebateInfo.Gender        = cboGender.SelectedItem.ToString();
                rebateInfo.PhoneNum      = masktxtPhoneNum.Text;
                rebateInfo.Email         = txtEmail.Text;
                rebateInfo.ProofPurchase = cboProofPurchase.SelectedItem.ToString();
                rebateInfo.DateRecieved  = dateTimePickerDateReceived.Value.ToString("M/dd/yyyy");

                //Different Modes will save in different ways
                if (BLL.BLLSingleton.Instance.currentMode.Equals(Domain.CurrentMode.addMode))
                {
                    //Will use new hidden variable values
                    rebateInfo.TimeFirstEntered    = mainform_TimeFirstEntered;
                    rebateInfo.TimePressedSave     = mainform_TimePressedSave;
                    rebateInfo.NumPressedBackSpace = mainform_NumPressedBackSpace.ToString();

                    AddMode_Save(rebateInfo);
                }
                else if (BLL.BLLSingleton.Instance.currentMode.Equals(Domain.CurrentMode.editMode))
                {
                    //Does not do the follwing if there are no selected items
                    if (listViewRebateRecords.SelectedItems.Count == 0)
                    {
                        return;
                    }

                    //Get selected ListViewItem
                    Domain.RebateInfo rebateInfo_OLDVALUES = (Domain.RebateInfo)listViewRebateRecords.SelectedItems[0].Tag;

                    //Will use old hidden variable values
                    rebateInfo.TimeFirstEntered    = rebateInfo_OLDVALUES.TimeFirstEntered;
                    rebateInfo.TimePressedSave     = rebateInfo_OLDVALUES.TimePressedSave;
                    rebateInfo.NumPressedBackSpace = rebateInfo_OLDVALUES.NumPressedBackSpace;

                    EditMode_Save(rebateInfo);
                }

                //Will save the listview as list to the DAL
                BLL.BLLSingleton.Instance.SaveRebateInfo(RebateInfoListViewToList(listViewRebateRecords));

                //Refreshes the form to default
                RefreshForm();
            }
        }