private void txtYear_Validating(object sender, CancelEventArgs e)
        {
            ReferencesValidation r = new ReferencesValidation();

            if (r.yearValid(txtYear.Text) == false)
            {
                MessageBox.Show("Please enter is YYYY format.");
                txtYear.Focus();
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Reference r = new Reference();

            r.Title         = txtTitle.Text;
            r.Authors_Fname = txtAuthors_Fname.Text;
            r.Authors_Lname = txtAuthors_Lname.Text;
            r.Document_type = txtDocumenttype.Text;
            r.Year          = txtYear.Text;
            r.Publisher     = txtPublisher.Text;
            r.City          = txtCity.Text;
            r.Abstract      = txtAbstract.Text;
            r.Name          = txtName.Text;
            r.Issue         = txtIssue.Text;
            r.Volume        = txtVolume.Text;
            r.Pageno        = txtPageno.Text;
            r.Notes         = txtNotes.Text;
            r.Userid        = userid;

            ReferencesValidation rv = new ReferencesValidation();

            string[] parameters = new string[] { txtTitle.Text, txtAuthors_Fname.Text, txtAuthors_Lname.Text,
                                                 txtDocumenttype.Text, txtYear.Text, txtPublisher.Text, txtAbstract.Text, txtName.Text,
                                                 txtIssue.Text, txtVolume.Text, txtPageno.Text };
            if (rv.checkEmpty(parameters) == true)
            {
                if (rv.numberValid(txtVolume.Text) == true)
                {
                    if (rv.numberValid(txtPageno.Text) == true)
                    {
                        r.insert();
                        MessageBox.Show("Reference added sucessfully.");
                        formclear();
                    }
                    else
                    {
                        MessageBox.Show("Please enter numberic value for Page number.");
                        txtPageno.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Please enter numberic value for Page number.");
                    txtVolume.Focus();
                }
            }
            else
            {
                MessageBox.Show("Don't leave any field with * empty.");
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            ReferencesValidation rv = new ReferencesValidation();

            string[] parameters = new string[] { txtTitle.Text, txtAuthors_Fname.Text, txtAuthors_Fname.Text,
                                                 txtDocumenttype.Text, txtYear.Text, txtPublisher.Text, txtAbstract.Text, txtName.Text,
                                                 txtIssue.Text, txtVolume.Text, txtPageno.Text };
            if (rv.checkEmpty(parameters) == true)
            {
                if (rv.numberValid(txtPageno.Text) == true)
                {
                    try
                    {
                        string qry = "update tbl_References set Title ='" + txtTitle.Text
                                     + "', Authors_Fname ='" + txtAuthors_Fname.Text + "', Authors_Lname ='"
                                     + txtAuthors_Lname.Text + "', Document_type ='" + txtDocumenttype.Text
                                     + "', Year ='" + txtYear.Text + "', Publisher ='" + txtPublisher.Text
                                     + "', City ='" + txtCity.Text + "', Abstract ='" + txtAbstract.Text
                                     + "', Name ='" + txtName.Text + "', Issue ='" + txtIssue.Text + "', Volume ='"
                                     + txtVolume.Text + "', Page_no =" + int.Parse(txtPageno.Text) + ", Notes ='"
                                     + txtNotes.Text + "' where Ref_Id =" + referenceId;
                        DatabaseCon dbcon = new DatabaseCon();
                        dbcon.Query = qry;
                        dbcon.ExecuteQuery();
                        MessageBox.Show("Done.");
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                else
                {
                    MessageBox.Show("Please enter numberic value for Page number.");
                    txtPageno.Focus();
                }
            }
            else
            {
                MessageBox.Show("Don't leave any field with * empty.");
            }
        }