private void button1_Click(object sender, EventArgs e)
 {
     if (txtName.Text != "" && txtTotalmarks.Text != "" && txtObtainedMarks.Text != "")
     {
         if (isEdit)
         {
             try {
                 string update = string.Format("update Evaluation set Name='{0}', TotalMarks='{1}', TotalWeightage='{2}' where Id='{3}'", txtName.Text, Convert.ToInt32(txtTotalmarks.Text), Convert.ToInt32(txtObtainedMarks.Text), Convert.ToInt64(id));
                 DatabaseConnection.getInstance().executeQuery(update);
                 MessageBox.Show("Data Updated Successfully!");
                 txtName.Text = ""; txtTotalmarks.Text = ""; txtObtainedMarks.Text = "";
                 isEdit       = false;
             } catch (Exception err)
             {
                 MessageBox.Show("Error " + err.Message);
             }
         }
         else
         {
             try
             {
                 string query = string.Format("Insert into Evaluation values('{0}','{1}','{2}')", txtName.Text, Convert.ToInt32(txtTotalmarks.Text), Convert.ToInt32(txtObtainedMarks.Text));
                 DatabaseConnection.getInstance().executeQuery(query);
                 MessageBox.Show("Data Inserted Successfully!");
                 txtName.Text = ""; txtTotalmarks.Text = ""; txtObtainedMarks.Text = "";
             }
             catch (Exception err)
             {
                 MessageBox.Show("Error " + err.Message);
             }
         }
     }
     else
     {
         label1.Visible = true;
         label1.Text    = "Please Fill Required Field!";
     }
     dataGridView1 = null;
     this.evaluationTableAdapter.Fill(this.projectADataSet5.Evaluation);
 }
Exemplo n.º 2
0
        private void Manage_Student_Load(object sender, EventArgs e)
        {
            dataGridView1.BorderStyle = BorderStyle.None;
            dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(238, 239, 249);
            dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
            dataGridView1.DefaultCellStyle.SelectionBackColor = Color.DarkTurquoise;
            dataGridView1.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke;
            dataGridView1.BackgroundColor = Color.White;

            string query = "select Student.Id, Student.RegistrationNo, Person.Id, Person.FirstName, Person.LastName, Person.Contact, Person.Email, Person.DateOfBirth, Person.Gender from Person join Student on Person.Id=Student.Id";
            var    data  = DatabaseConnection.getInstance().getAllData(query);

            data.Fill(table);
            dataGridView1.DataSource = table;

            DataGridViewColumn col = dataGridView1.Columns[2];

            col.Visible = false;

            DataGridViewButtonColumn button = new DataGridViewButtonColumn();

            button.Name       = "edit";
            button.HeaderText = "Edit";
            button.Text       = "Edit";
            button.UseColumnTextForButtonValue = true;
            this.dataGridView1.Columns.Add(button);

            DataGridViewButtonColumn button1 = new DataGridViewButtonColumn();

            button1.Name       = "delete";
            button1.HeaderText = "Delete";
            button1.Text       = "DEL";
            button1.UseColumnTextForButtonValue = true;
            this.dataGridView1.Columns.Add(button1);
            //// TODO: This line of code loads data into the 'projectADataSet.Student' table. You can move, or remove it, as needed.
            //this.studentTableAdapter.Fill(this.projectADataSet.Student);
            //// TODO: This line of code loads data into the 'projectADataSet.Person' table. You can move, or remove it, as needed.
            //this.personTableAdapter.Fill(this.projectADataSet.Person);
        }
Exemplo n.º 3
0
        private void deladd_Click(object sender, EventArgs e)
        {
            if (dataGridadd.SelectedCells.Count != 0)
            {
                int rw = dataGridadd.SelectedCells[0].RowIndex;

                String     cmd = String.Format("Select Id from Lookup  Where Value = 'Active'");
                SqlCommand a   = new SqlCommand(cmd, DatabaseConnection.getInstance().getConnection());
                int        st;
                st  = (Int32)a.ExecuteScalar();
                cmd = String.Format("Select Person.Id From Person where FirstName + ' ' +LastName ='{0}' ", dataGridadd.Rows[rw].Cells["Name"].Value.ToString());
                a   = new SqlCommand(cmd, DatabaseConnection.getInstance().getConnection());
                int id;
                id  = (Int32)a.ExecuteScalar();
                cmd = string.Format("UPDATE GroupStudent SET Status = '{1}'  where StudentId = '{0}'", id, st);
                SqlCommand del   = new SqlCommand(cmd, DatabaseConnection.getInstance().getConnection());
                int        count = del.ExecuteNonQuery();
                groups     p     = new groups();
                this.Hide();
                p.Show();
            }
        }
Exemplo n.º 4
0
        public advisors()
        {
            InitializeComponent();
            DatabaseConnection.getInstance().ConnectionString = "Data Source=HIBA\\SQLSERVER;Initial Catalog=ProjectA;Integrated Security=False;User ID=sa;Password=05feb1999;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";

            String         cmd     = "Select Person.Id, FirstName , LastName,Designation,Salary ,Contact,Email,DateOfBirth ,Person.Gender  from Advisor JOIN Person ON Advisor.Id = Person.Id";
            var            reader  = DatabaseConnection.getInstance().getData(cmd);
            List <advisor> persons = new List <advisor>();

            while (reader.Read())
            {
                advisor pro = new advisor();
                pro.FirstName   = reader.GetString(1);
                pro.LastName    = reader.GetString(2);
                pro.Id          = (int)reader.GetValue(0);
                pro.Email       = reader.GetString(6);
                pro.Contact     = reader.GetString(5);
                pro.DateOfBirth = (DateTime)reader.GetValue(7);
                pro.salary      = Convert.ToDecimal(reader.GetValue(4));

                cmd = "Select Value from Lookup Where Id = (SELECT Designation FROM Advisor where Id = " + pro.Id + ")";



                SqlCommand a = new SqlCommand(cmd, DatabaseConnection.getInstance().getConnection());

                pro.designation = a.ExecuteScalar().ToString();

                cmd = "Select Value from Lookup Where Id = (SELECT Gender FROM Person where Id = " + pro.Id + ")";



                a = new SqlCommand(cmd, DatabaseConnection.getInstance().getConnection());

                pro.Gender = a.ExecuteScalar().ToString();
                persons.Add(pro);
            }
            dataGridadd.DataSource = persons;
        }
        private void Manage_Project_Advisor_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'projectADataSet9.ProjectAdvisor' table. You can move, or remove it, as needed.
            this.projectAdvisorTableAdapter.Fill(this.projectADataSet9.ProjectAdvisor);
            dataGridView1.BorderStyle = BorderStyle.None;
            dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(238, 239, 249);
            dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
            dataGridView1.DefaultCellStyle.SelectionBackColor = Color.DarkTurquoise;
            dataGridView1.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke;
            dataGridView1.BackgroundColor = Color.White;

            // TODO: This line of code loads data into the 'projectADataSet9.ProjectAdvisor' table. You can move, or remove it, as needed.
            this.projectAdvisorTableAdapter.Fill(this.projectADataSet9.ProjectAdvisor);
            string query = "select Title from Project";
            var    str   = DatabaseConnection.getInstance().getAllData(query);

            str.Fill(table);
            comboProject.DataSource    = table;
            comboProject.DisplayMember = "Title";
            comboProject.ValueMember   = "Title";

            DataGridViewButtonColumn button = new DataGridViewButtonColumn();

            button.Name       = "edit";
            button.HeaderText = "Edit";
            button.Text       = "Edit";
            button.UseColumnTextForButtonValue = true;
            this.dataGridView1.Columns.Add(button);

            DataGridViewButtonColumn button1 = new DataGridViewButtonColumn();

            button1.Name       = "delete";
            button1.HeaderText = "Delete";
            button1.Text       = "DEL";
            button1.UseColumnTextForButtonValue = true;
            this.dataGridView1.Columns.Add(button1);
        }
Exemplo n.º 6
0
        private void saveupadd_Click(object sender, EventArgs e)
        {
            advisor p = new advisor();

            Regexp(@"^[a-zA-Z]{1,100}", addfnametext, addfnme, "First name");
            Regexp(@"^[a-zA-Z]{1,100}", addlnametext, addlnme, "Last name");
            Regexp(@"^[0-9]{1,20}", addcontacttxt, adcon, "Contact");
            Regexp(@"^([\\w\\.\\-]+)@([\\w\\-]+)((\\.(\\w){2,3})+)$", addemailtext, emailad, "Email");
            Regexp(@"^[0-9]{1,30}", addsaltext, saladd, "Salary");
            p.FirstName   = addfnametext.Text;
            p.LastName    = addlnametext.Text;
            p.Contact     = addcontacttxt.Text;
            p.Email       = addemailtext.Text;
            p.DateOfBirth = addobtext.Value;
            p.salary      = Convert.ToDecimal(addsaltext.Text);
            String     cmd = String.Format("Select Id from Lookup Where Value = '{0}'", addgendercombo.Text);
            SqlCommand a   = new SqlCommand(cmd, DatabaseConnection.getInstance().getConnection());
            int        Gender;

            Gender = (Int32)a.ExecuteScalar();

            cmd = String.Format("Update Person SET FirstName = '{0}', LastName = '{1}', Contact = '{2}', Email = '{3}', DateOfBirth = '{4}', Gender = '{5}' WHERE Id = '{6}'", p.FirstName, p.LastName, p.Contact, p.Email, p.DateOfBirth, Gender, ide);
            DatabaseConnection.getInstance().exectuteQuery(cmd);
            cmd = String.Format("Select Id from Lookup Where Value = '{0}'", degtext.Text);
            a   = new SqlCommand(cmd, DatabaseConnection.getInstance().getConnection());
            int designation;

            designation = (Int32)a.ExecuteScalar();

            cmd = String.Format("UPDATE Advisor SET Id = '{0}', Designation = '{1}', Salary = '{2}' WHERE Id = '{2}'", ide, designation, p.salary, ide);
            DatabaseConnection.getInstance().exectuteQuery(cmd);

            advisors s = new advisors();

            this.Hide();
            s.Show();
        }
Exemplo n.º 7
0
        public adstud()
        {
            InitializeComponent();
            DatabaseConnection.getInstance().ConnectionString = "Data Source=HIBA\\SQLSERVER;Initial Catalog=ProjectA;Integrated Security=False;User ID=sa;Password=05feb1999;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
            String        cmd    = String.Format("SELECT FirstName +' '+ LastName as [Name]  FROM Student Join Person On (Person.Id = Student.Id) WHERE ( Student.Id NOT IN (SELECT StudentId From GroupStudent))");
            SqlDataReader reader = DatabaseConnection.getInstance().getData(cmd);

            while (reader.Read())
            {
                stucombo.Items.Add(reader["Name"].ToString());
            }
            cmd    = String.Format("SELECT FirstName +' '+ LastName as [Name]  FROM Student Join Person On (Person.id = Student.id) WHERE ( Student.Id IN (SELECT StudentId From GroupStudent where (Status = (Select Id from Lookup where (Value = 'InActive')))))");
            reader = DatabaseConnection.getInstance().getData(cmd);
            while (reader.Read())
            {
                stucombo.Items.Add(reader["Name"].ToString());
            }
            cmd    = String.Format("SELECT Title From GroupProject JOIN Project ON GroupProject.ProjectId = Project.Id ");
            reader = DatabaseConnection.getInstance().getData(cmd);
            while (reader.Read())
            {
                procombo.Items.Add(reader["Title"].ToString());
            }
        }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            string date  = DateTime.Now.ToShortDateString();
            string query = "insert into Group1(Created_On) values('" + date + "')";

            DatabaseConnection.getInstance().executeQuery(query);
            string countMaxId = string.Format("select max(Id) from Group1");
            var    re         = DatabaseConnection.getInstance().readData(countMaxId);
            int    count      = 0;

            while (re.Read())
            {
                count = re.GetInt32(0);
            }
            int id;

            if (list.Count() > 4 || list.Count() < 2)
            {
                label8.Visible = true;
                label8.Text    = "Student Length should be between 2 and 4";
            }

            else
            {
                for (int i = 0; i < list.Count; i++)
                {
                    id = list[i].Id;
                    string query1 = string.Format("insert into GroupStudent(GroupId,StudentId,Status,AssignmentDate) values('{0}','{1}','{2}','{3}')", count, id, 4, date);
                    DatabaseConnection.getInstance().executeQuery(query1);
                }
                dataGridView1.DataSource = null;
                Show_Student_Group ssg = new Show_Student_Group();
                this.Hide();
                ssg.Show();
            }
        }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 4)
            {
                try
                {
                    rowIndex = e.RowIndex;
                    DataGridViewRow row = dataGridView1.Rows[rowIndex];
                    id                    = row.Cells[0].Value.ToString();
                    txtName.Text          = row.Cells[1].Value.ToString();
                    txtTotalmarks.Text    = row.Cells[2].Value.ToString();
                    txtObtainedMarks.Text = row.Cells[3].Value.ToString();

                    isEdit = true;
                }
                catch (Exception err)
                {
                    MessageBox.Show("Error " + err.Message);
                }
            }

            else if (e.ColumnIndex == 5 && DialogResult.Yes == MessageBox.Show("Do You Want Delete ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
            {
                try
                {
                    string eID   = dataGridView1.CurrentRow.Cells["idDataGridViewTextBoxColumn"].Value.ToString();
                    string query = string.Format("delete Evaluation where Id='{0}'", Convert.ToInt32(eID));
                    DatabaseConnection.getInstance().executeQuery(query);
                    MessageBox.Show("Deleted Successfully!");
                }
                catch (Exception err)
                {
                    MessageBox.Show("Error " + err.Message);
                }
            }
        }
Exemplo n.º 10
0
        public addproject(int id)
        {
            InitializeComponent();
            createbtn.Hide();
            ide = id;

            adadd.Text = "EDIT PROJECT";
            DatabaseConnection.getInstance().ConnectionString = "Data Source=HIBA\\SQLSERVER;Initial Catalog=ProjectA;Integrated Security=False;User ID=sa;Password=05feb1999;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";


            String        cmd    = "SELECT Id, Title, Description FROM Project WHERE Id = " + id.ToString();
            SqlDataReader reader = DatabaseConnection.getInstance().getData(cmd);
            Project       e      = new Project();

            while (reader.Read())
            {
                e.Id          = (int)reader.GetValue(0);
                e.title       = reader.GetString(1);
                e.description = reader.GetString(2);
            }

            nametext.Text = e.title;
            desctxt.Text  = e.description.ToString();
        }
Exemplo n.º 11
0
        private void createbtn_Click(object sender, EventArgs e)
        {
            Evaluation evl = new Evaluation();

            Regexp(@"^[a-zA-Z]{1,100}", nametext, addnme, "name");
            Regexp(@"^[0-9]{1,20}", tmrkstxt, tmeks, "Contact");
            Regexp(@"^[0-9]{1,20}", obttext, obt, "Contact");
            Regexp(@"^[0-9]{1,20}", twttxt, twt, "Contact");
            if (Convert.ToInt32(obttext.Text) > Convert.ToInt32(tmrkstxt.Text))
            {
                MessageBox.Show("Obtain marks should be less than or equal to Total Marks");
                obttext.Clear();
            }
            else
            {
                evl.Name       = nametext.Text;
                evl.totalmarks = Convert.ToInt32(tmrkstxt.Text);
                evl.weightage  = Convert.ToInt32(twttxt.Text);
                String cmd = String.Format("INSERT INTO Evaluation(Name,TotalMarks,TotalWeightage) values('{0}','{1}','{2}' )", evl.Name, evl.totalmarks, evl.weightage);
                DatabaseConnection.getInstance().exectuteQuery(cmd);
                cmd = String.Format("SELECT GroupProject.GroupId FROM Project JOIN GroupProject On (Project.Id = GroupProject.ProjectId) WHERE (title = '{0}')", procombo.Text);
                SqlCommand a = new SqlCommand(cmd, DatabaseConnection.getInstance().getConnection());
                int        id;
                id  = (Int32)a.ExecuteScalar();
                cmd = String.Format("SELECT Max(Id) FROM Evaluation");
                a   = new SqlCommand(cmd, DatabaseConnection.getInstance().getConnection());
                int ide;
                ide = (Int32)a.ExecuteScalar();

                cmd = String.Format("INSERT INTO GroupEvaluation(GroupId,EvaluationId,ObtainedMarks,EvaluationDate) values('{0}','{1}','{2}',GetDate() )", id, ide, obttext.Text);
                DatabaseConnection.getInstance().exectuteQuery(cmd);
                evaluations s = new evaluations();
                this.Hide();
                s.Show();
            }
        }
Exemplo n.º 12
0
        public asad()
        {
            InitializeComponent();
            DatabaseConnection.getInstance().ConnectionString = "Data Source=HIBA\\SQLSERVER;Initial Catalog=ProjectA;Integrated Security=False;User ID=sa;Password=05feb1999;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
            String        cmd    = String.Format("SELECT FirstName+LastName as [Name] FROM Advisor JOIN Person ON (Advisor.Id = Person.Id)");
            SqlDataReader reader = DatabaseConnection.getInstance().getData(cmd);

            while (reader.Read())
            {
                advcombo.Items.Add(reader["Name"].ToString());
            }
            cmd    = String.Format("SELECT Value FROM Lookup WHERE (Category = 'ADVISOR_ROLE')");
            reader = DatabaseConnection.getInstance().getData(cmd);
            while (reader.Read())
            {
                advr.Items.Add(reader["Value"].ToString());
            }
            cmd    = String.Format("SELECT Title FROM Project");
            reader = DatabaseConnection.getInstance().getData(cmd);
            while (reader.Read())
            {
                procombo.Items.Add(reader["Title"].ToString());
            }
        }
Exemplo n.º 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            String     cmd = String.Format("Select Id from Person  Where FirstName +' ' +LastName = '{0}'", stucombo.Text);
            SqlCommand a   = new SqlCommand(cmd, DatabaseConnection.getInstance().getConnection());
            int        stu;

            stu = (Int32)a.ExecuteScalar();
            cmd = String.Format("Select GroupProject.GroupId from Project Join GroupProject On PRoject.Id = GroupProject.ProjectId Where title = '{0}'", procombo.Text);
            a   = new SqlCommand(cmd, DatabaseConnection.getInstance().getConnection());
            int pro;

            pro = (Int32)a.ExecuteScalar();
            cmd = String.Format("Select Id from Lookup  Where Value = 'Active'");
            a   = new SqlCommand(cmd, DatabaseConnection.getInstance().getConnection());
            int st;

            st  = (Int32)a.ExecuteScalar();
            cmd = String.Format("INSERT INTO GroupStudent(GroupId,StudentId,Status,AssignmentDate) values('{0}','{1}','{2}',GetDate() )", pro, stu, st);
            DatabaseConnection.getInstance().exectuteQuery(cmd);
            grp g = new grp();

            this.Hide();
            g.Show();
        }
Exemplo n.º 14
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con        = new SqlConnection(conStr);
            SqlCommand    checkExist = new SqlCommand("select count(*) from Student where RegistrationNo=@registrationNo", con);

            checkExist.Parameters.AddWithValue("@registrationNo", txtRegNo.Text);
            // checkExist.CommandType = System.Data.CommandType.Text;
            con.Open();
            int asdas = (int)checkExist.ExecuteScalar();

            if (txtRegNo.Text == "" || txtFName.Text == "" || txtLName.Text == "" || txtContact.Text == "" || txtEmail.Text == "" || txtGender.Text == "")
            {
                label8.Visible = true;
                label8.Text    = "Please fill the Required Field....";
            }
            else if (txtRegNo.Text.Count() != 11 || txtRegNo.Text.Split('-')[0].Any(char.IsLetter) || txtRegNo.Text[4] != '-' ||
                     txtRegNo.Text[5] != 'C' || txtRegNo.Text[6] != 'S' || txtRegNo.Text[7] != '-')
            {
                txtRegNo.Focus();
                label8.Visible = true;
                label8.Text    = "i.e 2016-CS-315";
            }
            else if (txtContact.Text.Count() != 12 || txtContact.Text[4] != '-' || txtContact.Text.Any(char.IsLetter) == true)
            {
                label8.Text = "";
                txtContact.Focus();
                lbContact.Text      = "i.e 0123-3456789";
                lbContact.ForeColor = Color.Red;
            }
            else if (isEdit)
            {
                //if (asdas > 0)
                //{
                //    label8.Visible = true;
                //    label8.Text = "Registration No already exist";
                //}
                //else
                //{
                string update = string.Format("update Person set FirstName='{0}', LastName='{1}', Contact='{2}',Email='{3}',DateOfBirth='{4}', Gender=(select Id from Lookup where Value='{5}') where Id='{6}'", txtFName.Text, txtLName.Text, txtContact.Text, txtEmail.Text, Convert.ToDateTime(txtDOB.Value), txtGender.Text, id);
                DatabaseConnection.getInstance().executeQuery(update);
                string updateStudent = string.Format("update Student set RegistrationNo='{0}' where Id='{1}'", txtRegNo.Text, id);
                DatabaseConnection.getInstance().executeQuery(updateStudent);
                MessageBox.Show("Data Updated Successfully...");
                txtRegNo.Text = ""; txtFName.Text = ""; txtLName.Text = ""; txtContact.Text = ""; txtEmail.Text = ""; txtGender.Text = ""; label8.Text = "";
                Manage_Student ms = new Manage_Student();
                this.Hide();
                ms.Show();
                //}
            }

            else if (asdas > 0)
            {
                label8.Visible = true;
                label8.Text    = "Registration No already exist";
                con.Close();
            }
            else
            {
                try
                {
                    string countMaxId = string.Format("select max(Id) from Person");
                    var    re         = DatabaseConnection.getInstance().readData(countMaxId);
                    int    count      = 0;
                    while (re.Read())
                    {
                        count = re.GetInt32(0);
                    }
                    string query = string.Format("insert into Person(FirstName,LastName,Contact,Email,DateOfBirth,Gender) values('{0}','{1}','{2}','{3}','{4}',(select Id from Lookup where Value='{5}'))", txtFName.Text, txtLName.Text, txtContact.Text, txtEmail.Text, Convert.ToDateTime(txtDOB.Value), txtGender.Text);
                    DatabaseConnection.getInstance().executeQuery(query);
                    string qwrt = "insert into Student(Id, RegistrationNo) values('" + (count + 1) + "','" + txtRegNo.Text + "')";
                    DatabaseConnection.getInstance().executeQuery(qwrt);
                    MessageBox.Show("Data Inserted Successfully!");
                    txtRegNo.Text = ""; txtFName.Text = ""; txtLName.Text = ""; txtContact.Text = ""; txtEmail.Text = ""; txtGender.Text = ""; label8.Text = "";
                    Manage_Student ms = new Manage_Student();
                    this.Hide();
                    ms.Show();
                }
                catch
                {
                    int    count = 1;
                    string query = string.Format("insert into Person(FirstName,LastName,Contact,Email,DateOfBirth,Gender) values('{0}','{1}','{2}','{3}','{4}',(select Id from Lookup where Value='{5}'))", txtFName.Text, txtLName.Text, txtContact.Text, txtEmail.Text, Convert.ToDateTime(txtDOB.Value), txtGender.Text);
                    DatabaseConnection.getInstance().executeQuery(query);
                    string qwrt = "insert into Student(Id, RegistrationNo) values('" + count + "','" + txtRegNo.Text + "')";
                    DatabaseConnection.getInstance().executeQuery(qwrt);
                    MessageBox.Show("Data Inserted Successfully!");
                    txtRegNo.Text = ""; txtFName.Text = ""; txtLName.Text = ""; txtContact.Text = ""; txtEmail.Text = ""; txtGender.Text = ""; label8.Text = "";
                    Manage_Student ms = new Manage_Student();
                    this.Hide();
                    ms.Show();
                }
            }
        }
Exemplo n.º 15
0
        private void button3_Click(object sender, EventArgs e)
        {
            Document document = new Document();

            PdfWriter.GetInstance(document, new FileStream("C:/Users/HIBA/Desktop/ProjectA/ProjectA/groupReport.pdf", FileMode.Create));
            document.Open();


            PdfPTable table = new PdfPTable(4);

            //actual width of table in points

            table.TotalWidth = 216f;

            //fix the absolute width of the table

            table.LockedWidth = true;



            //relative col widths in proportions - 1/3 and 2/3

            float[] widths = new float[] { 150f, 150f, 150f, 150f };

            table.SetWidths(widths);

            table.HorizontalAlignment = 0;

            //leave a gap before and after the table

            table.SpacingBefore = 20f;

            table.SpacingAfter = 30f;



            PdfPCell cell = new PdfPCell(new Phrase("GROUP EVALUATION REPORT"));

            cell.Colspan = 4;

            cell.Border = 0;

            cell.HorizontalAlignment = 1;
            table.AddCell(cell);
            table.AddCell("Project Name");
            table.AddCell("Student Name");
            table.AddCell("Evaluation Name");
            table.AddCell("Obtained Marks");



            using (DatabaseConnection.getInstance().getConnection())

            {
                string query = "SELECT Title as [Project Name], Person.FirstName+ ' ' + Person.LastName as [Student Name],Evaluation.Name as [Evaluation], ObtainedMarks FROM Person Join Student On person.Id = Student.Id Join GroupStudent On GroupStudent.StudentId = Student.Id Join GroupEvaluation on GroupEvaluation.GroupId = GroupStudent.GroupId Join Evaluation On GroupEvaluation.EvaluationId = Evaluation.Id Join GroupProject on GroupProject.GroupId = GroupStudent.GroupId Join PRoject on Project.Id = GroupProject.ProjectId ";

                SqlCommand cmd = new SqlCommand(query, DatabaseConnection.getInstance().getConnection());



                using (SqlDataReader rdr = cmd.ExecuteReader())

                {
                    while (rdr.Read())

                    {
                        table.AddCell(rdr[0].ToString());

                        table.AddCell(rdr[1].ToString());
                        table.AddCell(rdr[2].ToString());
                        table.AddCell(rdr[3].ToString());
                    }
                }

                document.Add(table);
            }

            document.Close();
        }
Exemplo n.º 16
0
        private void button1_Click(object sender, EventArgs e)
        {
            int           asdas = 0;
            SqlConnection con   = new SqlConnection(conStr);

            try
            {
                SqlCommand checkExist = new SqlCommand("select count(*) from GroupEvaluation where GroupId=(select Id from Group1 where Id=@title) AND EvaluationId=(select Id from Evaluation where Name=@groupId)", con);
                checkExist.Parameters.AddWithValue("@title", comGroupId.Text);
                checkExist.CommandType = System.Data.CommandType.Text;
                checkExist.Parameters.AddWithValue("@groupId", comEvaluationId.Text);
                con.Open();
                asdas = (int)checkExist.ExecuteScalar();
            }
            catch
            {
                label4.Text = "Already Exists";
            }
            string date       = DateTime.Now.ToShortDateString();
            string query1     = "select TotalMarks from Evaluation";
            var    totalMarks = DatabaseConnection.getInstance().getRowsCount(query1);

            if (isEdit)
            {
                try
                {
                    string query = string.Format("update GroupEvaluation set GroupId='{0}', EvaluationId=(select Id from Evaluation where Name='{1}'), ObtainedMarks='{2}', EvaluationDate='{3}' where GroupId='{4}'", int.Parse(comGroupId.Text), comEvaluationId.Text, int.Parse(textBox3.Text), date, int.Parse(grpId));
                    DatabaseConnection.getInstance().executeQuery(query);
                    MessageBox.Show("Data updated Successfully!");
                    dataGridView1 = null;
                    this.groupEvaluationTableAdapter.Fill(this.projectADataSet7.GroupEvaluation);
                    isEdit          = false;
                    comGroupId.Text = ""; comEvaluationId.Text = ""; textBox3.Text = "";
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }
            }

            else if (comGroupId.Text == "" || comEvaluationId.Text == "" || textBox3.Text == "")
            {
                label4.Text = "Please Fill the Required Field!";
            }

            else if (textBox3.Text.Any(char.IsLetter) == true)
            {
                textBox3.Focus();
                label4.Text = "Integer Value!";
            }
            else if (asdas > 0)
            {
                comGroupId.Focus();
                label4.Text = "Group Already Exists";
                con.Close();
            }

            else if (totalMarks < int.Parse(textBox3.Text))
            {
                textBox3.Focus();
                label4.Text = "Obtained Marks should be Less than Total Marks";
            }
            else
            {
                try
                {
                    string query = string.Format("insert into GroupEvaluation values('{0}',(select Id from Evaluation where Name='{1}'),'{2}','{3}')", int.Parse(comGroupId.Text), comEvaluationId.Text, int.Parse(textBox3.Text), date);
                    DatabaseConnection.getInstance().executeQuery(query);
                    MessageBox.Show("Data Inserted Successfully!");
                    dataGridView1 = null;
                    this.groupEvaluationTableAdapter.Fill(this.projectADataSet7.GroupEvaluation);
                    comGroupId.Text = ""; comEvaluationId.Text = ""; textBox3.Text = "";
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }
            }
        }
Exemplo n.º 17
0
 public Person()
 {
     InitializeComponent();
     GetStudentRecord();
     DatabaseConnection.getInstance().ConnectionString = "Data Source=TAYYABA-RASHEED;Initial Catalog=ProjectA;User ID=sa;Password=alohamora";
 }
Exemplo n.º 18
0
 private void Person_FormClosed(object sender, FormClosedEventArgs e)
 {
     DatabaseConnection.getInstance().closeConnection();
 }
Exemplo n.º 19
0
 public Manage_Project()
 {
     InitializeComponent();
     DatabaseConnection.getInstance().ConnectionString = "Data Source=HIBA\\SQLSERVER;Initial Catalog=ProjectA;Integrated Security=False;User ID=sa;Password=05feb1999;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
 }
Exemplo n.º 20
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string date = DateTime.Now.ToShortDateString();

            if (comboAdvisor.Text == "Professor")
            {
                id = 6;
            }
            else if (comboAdvisor.Text == "Associate Professor")
            {
                id = 7;
            }
            else if (comboAdvisor.Text == "Assisstant Professor")
            {
                id = 8;
            }
            else if (comboAdvisor.Text == "Lecturer")
            {
                id = 9;
            }
            else if (comboAdvisor.Text == "Industry Professional")
            {
                id = 10;
            }

            if (isEdit)
            {
                try
                {
                    string update = string.Format("update ProjectAdvisor set AdvisorId=(select Id from Advisor where Designation='{0}'), ProjectId=(select Id from Project where Title='{1}'), AdvisorRole=(select Id from Lookup where Value='{2}'),AssignmentDate='{3}' where AdvisorId='{4}' and ProjectId='{5}'", id, comboProject.Text, comboRole.Text, date, int.Parse(advisorId), int.Parse(projectId));
                    DatabaseConnection.getInstance().executeQuery(update);
                    MessageBox.Show("Data Updated Successfully!");
                    dataGridView1 = null;
                    this.projectAdvisorTableAdapter.Fill(this.projectADataSet9.ProjectAdvisor);
                    comboAdvisor.Text = ""; comboProject.Text = ""; comboRole.Text = "";
                    isEdit            = false;
                }
                catch (Exception err)
                {
                    MessageBox.Show("Error " + err.Message);
                }
            }
            else
            {
                if (comboAdvisor.Text != "" && comboProject.Text != "" && comboRole.Text != "")
                {
                    try
                    {
                        string query = string.Format("insert into ProjectAdvisor values((select Id from Advisor where Designation='{0}'),(select Id from Project where Title='{1}'),(select Id from Lookup where Value='{2}'),'{3}')", id, comboProject.Text, comboRole.Text, date);
                        DatabaseConnection.getInstance().executeQuery(query);
                        MessageBox.Show("Data Inserted Successfully!");
                        this.projectAdvisorTableAdapter.Fill(this.projectADataSet9.ProjectAdvisor);
                        comboAdvisor.Text = ""; comboProject.Text = ""; comboRole.Text = "";
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show("Error " + err.Message);
                    }
                }
                else
                {
                    label4.Text = "Please Fill the Required Field!";
                }
            }
        }