Beispiel #1
0
        private void inputValidator(object sender, KeyPressEventArgs e)
        {
            TextBox t;
            if (sender is TextBox)
            {
                t = (TextBox)sender;
                if (t.Name == txtCustName.Name)
                {
                    e.Handled = true;
                    CustomerSearchDialog dialog = new CustomerSearchDialog();
                    dialog.ShowDialog(this);

                    if (dialog.DialogResult == DialogResult.OK)
                    {
                        Customer c = dialog.ReturnCustomer();
                        if (c != null)
                        {
                            txtCustName.Text = c.cust_name.Trim();
                            txtAddress.Text = c.cust_address.Trim();
                            txtPhone.Text = c.cust_phone.Trim();

                            // Update Sale order
                            saleOrder.cust_id = c.cust_id;
                        }
                    }
                }
                if (t.Name == txtPhone.Name)
                {
                    // If new input is not integer then disallow the character
                    if (!Char.IsDigit(e.KeyChar) & e.KeyChar != (char)8)
                        e.Handled = true;
                }
                if (t.Name == txtTakenMoney.Name)
                {
                    // If new input is not decimal then disallow the characte
                    decimal takenMoney;
                    string enterNumber = txtTakenMoney.Text + e.KeyChar.ToString();
                    bool parsed = decimal.TryParse(enterNumber, out takenMoney);
                    if (!parsed)
                        e.Handled = true;
                    else
                    {
                        decimal total = decimal.Parse(lblTotal.Text.ToString());
                        if (takenMoney > total)
                            e.Handled = true;
                        else
                            lblDept.Text = (total - takenMoney).ToString("#,##0.000");
                    }
                    // But accept backspace
                    if (e.KeyChar == (char)8)
                    {
                        e.Handled = false;
                    }
                }
            }
        }
Beispiel #2
0
 private void addToolStripMenuItem_Click(object sender, EventArgs e)
 {
     CustomerSearchDialog dialog = new CustomerSearchDialog();
     dialog.ShowDialog(this);
 }
Beispiel #3
0
        private void btnCustSearch_Click(object sender, EventArgs e)
        {
            CustomerSearchDialog dialog = new CustomerSearchDialog();
            dialog.ShowDialog(this);

            if (dialog.DialogResult == DialogResult.OK)
            {
                cust = dialog.ReturnCustomer();
                if (cust != null)
                {
                    txtCustName.Text = cust.cust_name.Trim();
                    txtAddress.Text = cust.cust_address.Trim();
                    txtPhone.Text = cust.cust_phone.Trim();
                    saleOrder.cust_id = cust.cust_id;
                    // Update Sale order
                }
            }
        }
Beispiel #4
0
        private void txtCustomer_Enter(object sender, EventArgs e)
        {
            CustomerSearchDialog dialog = new CustomerSearchDialog();
            dialog.ShowDialog(this);

            if (dialog.DialogResult == DialogResult.OK)
            {
                Customer c = dialog.ReturnCustomer();
                if (c != null)
                {
                    txtCustomer.Text = c.cust_name.Trim();
                }
            }
        }