Beispiel #1
0
        private void linkLabel5_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.Hide();
            Student_Details g = new Student_Details();

            g.Show();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (lbllastname.Text == "" && lblFirstname.Text == "" && lblcontact.Text == "" && lblemail.Text == "" && lblerror.Text == "" && lblregdesig.Text == "")
            {
                string k = "Select Count(Id) from  Person where FirstName ='" + txtfirstname.Text + "' and LastName = '" + txtlastname.Text + "' and Contact = '" + txtcontact.Text + "'and Id != '" + Convert.ToInt32(dataGridView1.CurrentRow.Cells["Id"].Value) + "'";

                Student st = new Student();
                bool    ry = st.uniqueperson(txtfirstname.Text, txtlastname.Text, txtcontact.Text, k);

                string kl = "Select Count(Id) from Student where RegistrationNo ='" + txtregno.Text + "' and Id != '" + Convert.ToInt32(dataGridView1.CurrentRow.Cells["Id"].Value) + "'";

                bool v = st.uniqueregno(txtregno.Text, kl);

                if (ry == false)
                {
                    lblerror.Text = "This Person has already been added in Record";
                }
                else if (v == false)
                {
                    lblerror.Text = "This RegistrationNo is already in Record";
                }

                else if (ry == true && v == true)
                {
                    try
                    {
                        string em = "Select Id from Lookup where Value = '" + cmbgender.Text + "' ";

                        int    y = dbConnection.getInstance().getScalerData(em);
                        string o = dataGridView1.CurrentRow.Cells["Id"].FormattedValue.ToString();
                        int    u = Convert.ToInt32(o);
                        string s = "Update Person SET FirstName = '" + txtfirstname.Text + "', LastName = '" + txtlastname.Text + "',Contact = '" + txtcontact.Text + "',Email = '" + txtemail.Text + "',DateOfBirth = '" + dtpdob.Value + "',Gender = '" + y + "'  where Id = '" + u + "' ";
                        dbConnection.getInstance().exectuteQuery(s);
                        string stU = "Update Student SET RegistrationNo = '" + txtregno.Text + "' where Id = '" + u + "' ";
                        dbConnection.getInstance().exectuteQuery(stU);
                        MessageBox.Show("Updated");
                        panel2.Visible = false;
                        this.Hide();
                        Student_Details frm = new Student_Details();
                        frm.Show();
                    }
                    catch (Exception et)
                    {
                        throw (et);
                    }
                }
            }
        }