Example #1
0
        //submit button tab1 click
        private void buttonSubmitApplication_Click(object sender, EventArgs e)
        {
            bool containsLetter = false;                      //phone no validating
            string phoneNumber = textBoxContact.Text.Trim();
            if (phoneNumber.Length < 10)
                containsLetter = true;
            else
            {
                for (int i = 0; i < phoneNumber.Length; i++)
                {
                    if (!char.IsNumber(phoneNumber[i]))
                    {
                        containsLetter = true;
                    }
                }
            }
            if (containsLetter)
            {
                MessageBox.Show("Please enter all the data before submission and make sure contact no and NIC no is valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            bool nicwrong = false;                              //nic validating
            string nic = textBoxNIC.Text;
            if (nic.Length < 10)
                nicwrong = true;
            else
            {
                for (int i = 0; i < 9; i++)
                {
                    if (!char.IsNumber(nic[i]))
                    {
                        nicwrong = true;
                    }
                }
                if (nic[9] != 'V' && nic[9] != 'v')
                    nicwrong = true;
            }
            if (nicwrong)
            {
                MessageBox.Show("Please enter all the data before submission and make sure NIC no is in correct format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (valid())                                        //validating of required fields filled
            {
                ApplicationRow approw;
                int refno;
                if (dbmap.hasEntry("reference"))
                {
                    refno = int.Parse(dbmap.get("no", "reference"));//get a reference no  from database 'mapno'
                    int upref = refno + 1;
                    dbmap.update("no", "reference", upref.ToString());
                }
                else
                {
                    dbmap.insert(new MapnoRow("reference",10001));
                    refno = 10000;
                }

                if (comboCategory.SelectedIndex == 0)           //add data to database 'applicaton' if domestoc category
                {
                    ApplicationForm app = new ApplicationForm(comboTitle.SelectedItem.ToString(), textBoxName.Text, textBoxNIC.Text,
                        comboCategory.SelectedItem.ToString(), textBoxAddressConnection.Text, textBoxGramaNiladhari.Text, textBoxDivisionalSec.Text,
                        textBoxDistrict.Text, textBoxAddressMail.Text, textBoxEmail.Text, int.Parse(textBoxContact.Text),
                        comboBoxApplicantType.SelectedItem.ToString(), checkBoxDocsSubmitted.Checked, checkBoxPreviousConnection.Checked, textBoxPreviousAccountNo.Text,
                        comboBoxPreviousCategory.SelectedItem.ToString(), refno);//reference 0*************dn
                    approw = new ApplicationRow(app.title, app.name, app.nic, app.category, app.address,
                        app.gramaDivision, app.divisionalSecretariat, app.district, app.mail, app.email, app.contact,
                        app.applicantType, app.submittedDocs, app.preaccountNo, app.preCategory, app.refno, null, null, 0, 0);

                    dbapp.insert(approw);
                }
                else                                    //add data to database 'applicaton' if business category
                {
                    BusinessApplicationForm app1 = new BusinessApplicationForm(comboTitle.SelectedItem.ToString(), textBoxName.Text, textBoxNIC.Text,
                        comboCategory.SelectedItem.ToString(), textBoxAddressConnection.Text, textBoxGramaNiladhari.Text, textBoxDivisionalSec.Text,
                        textBoxDistrict.Text, textBoxAddressMail.Text, textBoxEmail.Text, int.Parse(textBoxContact.Text),
                        comboBoxApplicantType.SelectedItem.ToString(), checkBoxDocsSubmitted.Checked, checkBoxPreviousConnection.Checked, textBoxPreviousAccountNo.Text,
                        comboBoxPreviousCategory.SelectedItem.ToString(), textBox1Company.Text, textBoxPost.Text, refno);//reference 0****dn
                    approw = new ApplicationRow(app1.title, app1.name, app1.nic, app1.category, app1.address,
                        app1.gramaDivision, app1.divisionalSecretariat, app1.district, app1.mail, app1.email, app1.contact,
                        app1.applicantType, app1.submittedDocs, app1.preaccountNo, app1.preCategory, app1.refno,
                        app1.company, app1.post, 0, 0);
                    dbapp.insert(approw);
                }

                //show the reference no via message box
                MessageBox.Show("Your Connection Reference No is: " + refno, "Reference Number", MessageBoxButtons.OK);
                button2Click();                 //clear all fields
            }
            else   //show an error message if not completed the application
                MessageBox.Show("Please enter all the required data before submission", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Example #2
0
        private void buttonSubmitApplication_Click(object sender, EventArgs e) //submit button tab1 click
        {
            bool   containsLetter = false;                                     //phone no validating
            string phoneNumber    = textBoxContact.Text.Trim();

            if (phoneNumber.Length < 10)
            {
                containsLetter = true;
            }
            else
            {
                for (int i = 0; i < phoneNumber.Length; i++)
                {
                    if (!char.IsNumber(phoneNumber[i]))
                    {
                        containsLetter = true;
                    }
                }
            }
            if (containsLetter)
            {
                MessageBox.Show("Please enter all the data before submission and make sure contact no and NIC no is valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            bool   nicwrong = false;                            //nic validating
            string nic      = textBoxNIC.Text;

            if (nic.Length < 10)
            {
                nicwrong = true;
            }
            else
            {
                for (int i = 0; i < 9; i++)
                {
                    if (!char.IsNumber(nic[i]))
                    {
                        nicwrong = true;
                    }
                }
                if (nic[9] != 'V' && nic[9] != 'v')
                {
                    nicwrong = true;
                }
            }
            if (nicwrong)
            {
                MessageBox.Show("Please enter all the data before submission and make sure NIC no is in correct format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (valid())                                        //validating of required fields filled
            {
                ApplicationRow approw;
                int            refno;
                if (dbmap.hasEntry("reference"))
                {
                    refno = int.Parse(dbmap.get("no", "reference"));//get a reference no  from database 'mapno'
                    int upref = refno + 1;
                    dbmap.update("no", "reference", upref.ToString());
                }
                else
                {
                    dbmap.insert(new MapnoRow("reference", 10001));
                    refno = 10000;
                }

                if (comboCategory.SelectedIndex == 0)           //add data to database 'applicaton' if domestoc category
                {
                    ApplicationForm app = new ApplicationForm(comboTitle.SelectedItem.ToString(), textBoxName.Text, textBoxNIC.Text,
                                                              comboCategory.SelectedItem.ToString(), textBoxAddressConnection.Text, textBoxGramaNiladhari.Text, textBoxDivisionalSec.Text,
                                                              textBoxDistrict.Text, textBoxAddressMail.Text, textBoxEmail.Text, int.Parse(textBoxContact.Text),
                                                              comboBoxApplicantType.SelectedItem.ToString(), checkBoxDocsSubmitted.Checked, checkBoxPreviousConnection.Checked, textBoxPreviousAccountNo.Text,
                                                              comboBoxPreviousCategory.SelectedItem.ToString(), refno);//reference 0*************dn
                    approw = new ApplicationRow(app.title, app.name, app.nic, app.category, app.address,
                                                app.gramaDivision, app.divisionalSecretariat, app.district, app.mail, app.email, app.contact,
                                                app.applicantType, app.submittedDocs, app.preaccountNo, app.preCategory, app.refno, null, null, 0, 0);

                    dbapp.insert(approw);
                }
                else                                    //add data to database 'applicaton' if business category
                {
                    BusinessApplicationForm app1 = new BusinessApplicationForm(comboTitle.SelectedItem.ToString(), textBoxName.Text, textBoxNIC.Text,
                                                                               comboCategory.SelectedItem.ToString(), textBoxAddressConnection.Text, textBoxGramaNiladhari.Text, textBoxDivisionalSec.Text,
                                                                               textBoxDistrict.Text, textBoxAddressMail.Text, textBoxEmail.Text, int.Parse(textBoxContact.Text),
                                                                               comboBoxApplicantType.SelectedItem.ToString(), checkBoxDocsSubmitted.Checked, checkBoxPreviousConnection.Checked, textBoxPreviousAccountNo.Text,
                                                                               comboBoxPreviousCategory.SelectedItem.ToString(), textBox1Company.Text, textBoxPost.Text, refno);//reference 0****dn
                    approw = new ApplicationRow(app1.title, app1.name, app1.nic, app1.category, app1.address,
                                                app1.gramaDivision, app1.divisionalSecretariat, app1.district, app1.mail, app1.email, app1.contact,
                                                app1.applicantType, app1.submittedDocs, app1.preaccountNo, app1.preCategory, app1.refno,
                                                app1.company, app1.post, 0, 0);
                    dbapp.insert(approw);
                }

                //show the reference no via message box
                MessageBox.Show("Your Connection Reference No is: " + refno, "Reference Number", MessageBoxButtons.OK);
                button2Click(); //clear all fields
            }
            else                //show an error message if not completed the application
            {
                MessageBox.Show("Please enter all the required data before submission", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }