Exemplo n.º 1
0
        private bool RequiredEntriesComplete(List <Control> listControl)
        {
            bool isValid = true;
            // check to see if all the textboxes/comboboxes have been completed.
            ControlErrorCheck errCheck = new ControlErrorCheck();

            foreach (Control x in listControl)
            {
                if (errCheck.IsComplete(x) == false)
                {
                    DisplayErrorMessage(lblErrorMessage3, errCheck.Message);
                    SetTextBoxFocusForError(x); // This will clear the text box and set focus
                    isValid = false;
                    break;
                }
            }
            return(isValid);
        }
Exemplo n.º 2
0
        private bool ValidateGasSales()
        {
            bool    isValid = true;
            decimal newDecimal;

            FormValidation verify = new FormValidation();
            List <TextBox> tbList = RequiredControlsForValidation();

            foreach (TextBox tb in tbList)
            {
                if (tb.Name.Contains("txtUnleaded") || tb.Name.Contains("txtPlus") || tb.Name.Contains("txtPremium"))
                { // this will only execute if the text boxes require only decimals
                    if (verify.IsDecimal(tb.Text.Trim(), out newDecimal))
                    {
                        CleanTextBoxValues(tb);
                        tb.Text = newDecimal.ToString();
                    }
                    else
                    {
                        isValid = false;
                    }
                }
                else
                {
                    if (verify.IsCurrency(tb.Text.Trim(), out newDecimal))
                    {
                        // CleanTextBoxValues for this application will round to teh nearest 100th.
                        CleanTextBoxValues(tb);
                        tb.Text = newDecimal.ToString();
                    }
                    else
                    {
                        isValid = false;
                    }
                }
                if (isValid == false)
                {
                    SetTextBoxFocusForError(tb);
                    DisplayErrorMessage(lblGasSalesErrorMessage,
                                        "Please enter only numbers/currency for the \n" + ControlErrorCheck.ReturnControlNameForDisplay(tb) + " input box.");
                    break;
                }
            }
            return(isValid);
        }
Exemplo n.º 3
0
        //****************************Daily Sales Department Panel*****************************************************

        private void btnAdd_Click(object sender, EventArgs e)
        {
            // error checking
            bool isValid = false;

            // Clean values
            CleanTextBoxValues(txtDeptSoldAmount);
            ResetAllErrorMessage();
            isValid = ValidateDeptSalesEntry();

            //DataGridViewRow row = new DataGridViewRow();
            //row.Cells[0].Value = "XYZ";
            //row.Cells[1].Value = 50.2;


            if (isValid == true)
            {
                // update the list view box
                // only update if the sales department has not already been included.
                DataTable dt        = dgSalesDept.DataSource as DataTable;
                DataRow[] arrSearch = dt.Select("SalesDept = '" + ddDepartment.Text + "'");
                for (int x = 0; x < dt.Columns.Count; x++)
                {
                    lblResults2.Text += "Column-" + dt.Columns[x].ColumnName + "-" + dt.Columns[x].GetType() + "\n";
                }
                //Create the new row
                FormValidation validate = new FormValidation();
                decimal        newdecimal;
                // add new value to the datatable:
                // verify that the table does not already have the same department.
                if (arrSearch.Length == 0)
                {
                    lblResults2.Text += "---upper\n";
                    DataRow dr = dt.NewRow();

                    dr[0]             = ddDepartment.Text;
                    lblResults2.Text += dr[0].ToString() + "---upper\n";
                    dr[1]             = ddQuantity.Text;
                    lblResults2.Text += dr[1].ToString() + "---upper\n";
                    validate.IsCurrency(txtDeptSoldAmount.Text, out newdecimal);
                    dr[2]             = newdecimal;
                    dr[3]             = GetSalesDeptIDByName(ddDepartment.Text.Trim());
                    lblResults2.Text += dr[3].ToString() + "---upper\n";
                    dr[4]             = SalesDateId;
                    lblResults2.Text += dr[4].ToString() + "---upper\n";

                    //int count = dgSalesDept.Rows.Add(); // the add method will return the index of the row that was just created.

                    dt.Rows.Add(dr);
                    ResetSalesDeptEntry();
                }
                else
                {
                    // this department already exists -- errMessage

                    DisplayErrorMessage(lblDeptSalesErrorMessage, ControlErrorCheck.ReturnControlNameForDisplay(ddDepartment) +
                                        " already exists for this date. \n Please enter data for a " +
                                        "different day or delete the row below and re-enter this data.");
                    SetTextBoxFocusForError(lblSalesDepartment);

                    //lblResults2.Text += arrSearch.Length.ToString() + "--asdf-upper\n";
                }
            }
        }