Example #1
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (SearchTextBox.Text == "")
                {
                    Refresh();
                    return;
                }
                String cmd    = "Select Id, Name, TotalMarks, TotalWeightage from Evaluation Where " + SearchCategory.Text + " = '" + SearchTextBox.Text + "'";
                var    reader = DatabaseConnection.getInstance().getData(cmd);

                List <EvaluationClass> students = new List <EvaluationClass>();
                while (reader.Read())
                {
                    EvaluationClass stu = new EvaluationClass();
                    stu.Id             = (int)reader.GetValue(0);
                    stu.Name           = reader.GetString(1);
                    stu.TotalMarks     = (int)reader.GetValue(2);
                    stu.TotalWeightage = (int)reader.GetValue(3);
                    students.Add(stu);
                }
                StudentDataGrid.DataSource = students;
                //StudentDataGrid.Columns[0].Visible = false;
                //StudentDataGrid.Columns[6].Visible = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
 private void SearchButtonE_Click(object sender, EventArgs e)
 {
     try
     {
         if (SearchTextBoxE.Text == "")
         {
             Refresh();
             return;
         }
         String cmd    = "Select Id, Name, TotalMarks, TotalWeightage, EvaluationDate from Evaluation JOIN GroupEvaluation ON Id = EvaluationId WHERE GroupId = " + id.ToString() + " AND " + SearchCategoryE.Text + " = '" + SearchTextBoxE.Text + "'";
         var    reader = DatabaseConnection.getInstance().getData(cmd);
         List <EvaluationClass> evaluation = new List <EvaluationClass>();
         while (reader.Read())
         {
             EvaluationClass stu = new EvaluationClass();
             stu.Id             = (int)reader.GetValue(0);
             stu.Name           = reader.GetString(1);
             stu.TotalMarks     = (int)reader.GetValue(2);
             stu.TotalWeightage = (int)reader.GetValue(3);
             stu.ObtainedMarks  = (int)reader.GetValue(4);
             stu.EvaluationDate = (DateTime)reader.GetValue(5);
             evaluation.Add(stu);
         }
         EvaluationDataGrid.DataSource            = evaluation;
         EvaluationDataGrid.Columns["Id"].Visible = false;
         for (int j = 0; j < EvaluationDataGrid.RowCount; j++)
         {
             EvaluationDataGrid.Rows[j].Cells[EvaluationDataGrid.Columns["Select"].Index].Value = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #3
0
 private void SearchButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (SearchTextBox.Text == "")
         {
             Refresh();
             return;
         }
         String cmd    = "Select Id, Name, TotalMarks, TotalWeightage from Evaluation WHERE " + SearchCategory.Text + " = '" + SearchTextBox.Text + "'";
         var    reader = DatabaseConnection.getInstance().getData(cmd);
         List <EvaluationClass> evaluation = new List <EvaluationClass>();
         while (reader.Read())
         {
             EvaluationClass stu = new EvaluationClass();
             stu.Id             = (int)reader.GetValue(0);
             stu.Name           = reader.GetString(1);
             stu.TotalMarks     = (int)reader.GetValue(2);
             stu.TotalWeightage = (int)reader.GetValue(3);
             evaluation.Add(stu);
         }
         ProjectDataGrid.DataSource = evaluation;
         for (int j = 0; j < ProjectDataGrid.RowCount; j++)
         {
             ProjectDataGrid.Rows[j].Cells[ProjectDataGrid.Columns["Select"].Index].Value = false;
         }
         ProjectDataGrid.Columns["Id"].Visible             = false;
         ProjectDataGrid.Columns["TotalWeightage"].Visible = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #4
0
        public void Refresh()
        {
            ProjectDataGrid.Columns.Clear();
            SearchCategory.Items.Clear();
            try
            {
                DataGridViewCheckBoxColumn checkColumn = new DataGridViewCheckBoxColumn();
                checkColumn.Name         = "Select";
                checkColumn.HeaderText   = "";
                checkColumn.TrueValue    = true;
                checkColumn.FalseValue   = false;
                checkColumn.Width        = 20;
                checkColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                checkColumn.ReadOnly     = false; //if the datagridview is resized (on form resize) the checkbox won't take up too much; value is relative to the other columns' fill values
                ProjectDataGrid.Columns.Add(checkColumn);
                String cmd    = "Select Id, Name, TotalMarks, TotalWeightage from Evaluation WHERE Id NOT IN (Select Id from Evaluation JOIN GroupEvaluation ON Id = EvaluationId WHERE GroupId = " + id.ToString() + ")";
                var    reader = DatabaseConnection.getInstance().getData(cmd);

                List <EvaluationClass> project = new List <EvaluationClass>();
                while (reader.Read())
                {
                    EvaluationClass stu = new EvaluationClass();
                    stu.Id             = (int)reader.GetValue(0);
                    stu.Name           = reader.GetString(1);
                    stu.TotalMarks     = (int)reader.GetValue(2);
                    stu.TotalWeightage = (int)reader.GetValue(3);
                    project.Add(stu);
                }
                ProjectDataGrid.DataSource = project;
                ProjectDataGrid.Columns["EvaluationDate"].Visible = false;
                ProjectDataGrid.Columns["ObtainedMarks"].Visible  = false;
                for (int j = 0; j < ProjectDataGrid.RowCount; j++)
                {
                    ProjectDataGrid.Rows[j].Cells[ProjectDataGrid.Columns["Select"].Index].Value = false;
                }
                ProjectDataGrid.Columns["Id"].Visible             = false;
                ProjectDataGrid.Columns["TotalWeightage"].Visible = false;
                cmd    = "Select Name, TotalMarks from Evaluation";
                reader = DatabaseConnection.getInstance().getData(cmd);
                int i = 0;
                while (reader.FieldCount > i)
                {
                    if (!SearchCategory.Items.Contains(reader.GetName(i)))
                    {
                        SearchCategory.Items.Add(reader.GetName(i));
                    }
                    i++;
                }
                SearchCategory.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #5
0
        private void Add_Click(object sender, EventArgs e)
        {
            int flag = 0;

            try
            {
                EvaluationClass stu = new EvaluationClass();
                if ((string.IsNullOrEmpty(NameTextBox.Text)))
                {
                    flag++;
                }
                else if (Regexp("^[a-zA-Z0-9]{1,100}", NameTextBox, NError, "Only alphabets are allowed.", 100))
                {
                    stu.Name = NameTextBox.Text;
                    flag++;
                }
                if ((string.IsNullOrEmpty(TMTextBox.Text)))
                {
                    flag++;
                }
                else if (Regexp("^[0-9]{1,3}", TMTextBox, TMError, "Only valid numbers are allowed.", 3))
                {
                    stu.TotalMarks = Convert.ToInt32(TMTextBox.Text);
                    flag++;
                }
                if ((string.IsNullOrEmpty(TWTextBox.Text)))
                {
                    flag++;
                }
                else if (Regexp("^[0-9]{1,3}", TWTextBox, TWError, "Only valid numbers are allowed.", 3))
                {
                    if (Convert.ToInt32(TWTextBox.Text) > 100)
                    {
                        Regexp("^[?]{1,3}", TWTextBox, TWError, "Weightage cannot exceed 100%", 3);
                        flag--;
                    }
                    stu.TotalWeightage = Convert.ToInt32(TWTextBox.Text);
                    flag++;
                }
                if (flag == 3)
                {
                    string cmd = String.Format("INSERT INTO Evaluation(Name, TotalMarks, TotalWeightage) values('{0}','{1}','{2}')", stu.Name, stu.TotalMarks, stu.TotalWeightage);
                    DatabaseConnection.getInstance().exectuteQuery(cmd);
                    par.Refresh();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #6
0
        public Evaluation()
        {
            InitializeComponent();
            this.MinimumSize = new Size(this.Width, this.Height);
            try
            {
                String cmd    = "Select Id, Name, TotalMarks, TotalWeightage from Evaluation";
                var    reader = DatabaseConnection.getInstance().getData(cmd);

                List <EvaluationClass> students = new List <EvaluationClass>();
                while (reader.Read())
                {
                    EvaluationClass stu = new EvaluationClass();
                    stu.Id             = (int)reader.GetValue(0);
                    stu.Name           = reader.GetString(1);
                    stu.TotalMarks     = (int)reader.GetValue(2);
                    stu.TotalWeightage = (int)reader.GetValue(3);
                    students.Add(stu);
                }
                StudentDataGrid.DataSource         = students;
                StudentDataGrid.Columns[0].Visible = false;
                DataGridViewButtonColumn bcol = new DataGridViewButtonColumn();
                bcol.HeaderText = "";
                bcol.Text       = "Edit";
                bcol.Name       = "btnEdit";
                bcol.UseColumnTextForButtonValue = true;
                StudentDataGrid.Columns.Add(bcol);
                DataGridViewButtonColumn bcol1 = new DataGridViewButtonColumn();
                bcol1.HeaderText = "";
                bcol1.Text       = "Delete";
                bcol1.Name       = "btnDelete";
                bcol1.UseColumnTextForButtonValue = true;
                StudentDataGrid.Columns.Add(bcol1);
                cmd    = "Select Name, TotalMarks, TotalWeightage from Evaluation";
                reader = DatabaseConnection.getInstance().getData(cmd);
                int i = 0;
                while (reader.FieldCount > i)
                {
                    if (!SearchCategory.Items.Contains(reader.GetName(i)))
                    {
                        SearchCategory.Items.Add(reader.GetName(i));
                    }
                    i++;
                }
                SearchCategory.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #7
0
        public EvaluationEdit(int id, MainPage parent)
        {
            par = parent;
            InitializeComponent();
            this.MinimumSize = new Size(this.Width, this.Height);
            NError.Text      = "";
            TMError.Text     = "";
            TWError.Text     = "";
            string cmd    = "Select Id, Name, TotalMarks, TotalWeightage from Evaluation where Id = " + id.ToString();
            var    reader = DatabaseConnection.getInstance().getData(cmd);

            stuold = new EvaluationClass();
            while (reader.Read())
            {
                stuold.Id             = (int)reader.GetValue(0);
                stuold.Name           = reader.GetString(1);
                stuold.TotalMarks     = (int)reader.GetValue(2);
                stuold.TotalWeightage = (int)reader.GetValue(3);
            }
            NameTextBox.Text = stuold.Name;
            TMTextBox.Text   = stuold.TotalMarks.ToString();
            TWTextBox.Text   = stuold.TotalWeightage.ToString();
        }
Example #8
0
        public void Refresh()
        {
            try
            {
                String cmd    = "Select Id, Name, TotalMarks, TotalWeightage from Evaluation";
                var    reader = DatabaseConnection.getInstance().getData(cmd);

                List <EvaluationClass> students = new List <EvaluationClass>();
                while (reader.Read())
                {
                    EvaluationClass stu = new EvaluationClass();
                    stu.Id             = (int)reader.GetValue(0);
                    stu.Name           = reader.GetString(1);
                    stu.TotalMarks     = (int)reader.GetValue(2);
                    stu.TotalWeightage = (int)reader.GetValue(3);
                    students.Add(stu);
                }
                StudentDataGrid.DataSource = students;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #9
0
        public void Refresh()
        {
            DeleteButtonP.Visible    = false;
            EvalDeleteButton.Visible = false;
            StudentDataGrid.Columns.Clear();
            SearchCategoryS.Items.Clear();
            ProjectDataGrid.Columns.Clear();
            SearchCategoryP.Items.Clear();
            EvaluationDataGrid.Columns.Clear();
            SearchCategoryE.Items.Clear();
            try
            {
                String cmd    = "Select Person.Id, FirstName, LastName, Contact, Email, DateOfBirth, Gender, RegistrationNo, GroupId, AssignmentDate, Value from ((Person JOIN Student ON Person.Id = Student.Id) JOIN GroupStudent ON Student.Id = StudentId) JOIN Lookup ON Lookup.Id = Status WHERE GroupId = " + id.ToString();
                var    reader = DatabaseConnection.getInstance().getData(cmd);

                List <StudentClass> students = new List <StudentClass>();
                while (reader.Read())
                {
                    StudentClass stu = new StudentClass();
                    stu.Id             = (int)reader.GetValue(0);
                    stu.FirstName      = reader.GetString(1);
                    stu.LastName       = reader.GetString(2);
                    stu.Contact        = reader.GetString(3);
                    stu.Email          = reader.GetString(4);
                    stu.DateOfBirth    = (DateTime)reader.GetValue(5);
                    stu.Gender         = (int)reader.GetValue(6);
                    stu.RegistrationNo = reader.GetString(7);
                    stu.GroupId        = (int)reader.GetValue(8);
                    stu.AssignmentDate = (DateTime)reader.GetValue(9);
                    stu.Status         = reader.GetString(10);
                    students.Add(stu);
                }
                StudentDataGrid.DataSource                     = students;
                StudentDataGrid.Columns["Id"].Visible          = false;
                StudentDataGrid.Columns["Gender"].Visible      = false;
                StudentDataGrid.Columns["Contact"].Visible     = false;
                StudentDataGrid.Columns["Email"].Visible       = false;
                StudentDataGrid.Columns["FirstName"].Visible   = false;
                StudentDataGrid.Columns["LastName"].Visible    = false;
                StudentDataGrid.Columns["DateOfBirth"].Visible = false;
                StudentDataGrid.Columns["Genders"].Visible     = false;
                StudentDataGrid.Columns["GroupId"].Visible     = false;
                cmd    = "Select RegistrationNo, Status As Statuses from (Person JOIN Student ON Person.Id = Student.Id) JOIN GroupStudent ON Student.Id = StudentId";
                reader = DatabaseConnection.getInstance().getData(cmd);
                int i = 0;
                while (reader.FieldCount > i)
                {
                    if (!SearchCategoryS.Items.Contains(reader.GetName(i)))
                    {
                        SearchCategoryS.Items.Add(reader.GetName(i));
                    }
                    i++;
                }
                SearchCategoryS.SelectedIndex = 0;
                DataGridViewCheckBoxColumn checkColumn = new DataGridViewCheckBoxColumn();
                checkColumn.Name         = "Select";
                checkColumn.HeaderText   = "";
                checkColumn.TrueValue    = true;
                checkColumn.FalseValue   = false;
                checkColumn.Width        = 20;
                checkColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                checkColumn.ReadOnly     = false; //if the datagridview is resized (on form resize) the checkbox won't take up too much; value is relative to the other columns' fill values
                ProjectDataGrid.Columns.Add(checkColumn);
                cmd    = "Select Id, Title, Description, AssignmentDate from Project JOIN GroupProject ON Id = ProjectId WHERE GroupId = " + id.ToString();
                reader = DatabaseConnection.getInstance().getData(cmd);
                List <ProjectClass> project = new List <ProjectClass>();
                while (reader.Read())
                {
                    ProjectClass stu = new ProjectClass();
                    stu.Id             = (int)reader.GetValue(0);
                    stu.Titlle         = reader.GetString(1);
                    stu.Description    = reader.GetString(2);
                    stu.AssignmentDate = (DateTime)reader.GetValue(3);
                    project.Add(stu);
                }
                ProjectDataGrid.DataSource                     = project;
                ProjectDataGrid.Columns["Id"].Visible          = false;
                ProjectDataGrid.Columns["Description"].Visible = false;
                for (int j = 0; j < ProjectDataGrid.RowCount; j++)
                {
                    ProjectDataGrid.Rows[j].Cells[ProjectDataGrid.Columns["Select"].Index].Value = false;
                }
                cmd    = "Select Title from Project JOIN GroupProject ON Id = ProjectId";
                reader = DatabaseConnection.getInstance().getData(cmd);
                i      = 0;
                while (reader.FieldCount > i)
                {
                    if (!SearchCategoryP.Items.Contains(reader.GetName(i)))
                    {
                        SearchCategoryP.Items.Add(reader.GetName(i));
                    }
                    i++;
                }
                SearchCategoryP.SelectedIndex = 0;
                cmd    = "Select Id, Name, TotalMarks, TotalWeightage, ObtainedMarks, EvaluationDate from Evaluation JOIN GroupEvaluation ON Id = EvaluationId WHERE GroupId = " + id.ToString();
                reader = DatabaseConnection.getInstance().getData(cmd);
                DataGridViewCheckBoxColumn checkColumn2 = new DataGridViewCheckBoxColumn();
                checkColumn2.Name         = "Select";
                checkColumn2.HeaderText   = "";
                checkColumn2.TrueValue    = true;
                checkColumn2.FalseValue   = false;
                checkColumn2.Width        = 20;
                checkColumn2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                checkColumn2.ReadOnly     = false; //if the datagridview is resized (on form resize) the checkbox won't take up too much; value is relative to the other columns' fill values
                EvaluationDataGrid.Columns.Add(checkColumn2);
                List <EvaluationClass> evaluation = new List <EvaluationClass>();
                while (reader.Read())
                {
                    EvaluationClass stu = new EvaluationClass();
                    stu.Id             = (int)reader.GetValue(0);
                    stu.Name           = reader.GetString(1);
                    stu.TotalMarks     = (int)reader.GetValue(2);
                    stu.TotalWeightage = (int)reader.GetValue(3);
                    stu.ObtainedMarks  = (int)reader.GetValue(4);
                    stu.EvaluationDate = (DateTime)reader.GetValue(5);
                    evaluation.Add(stu);
                }
                EvaluationDataGrid.DataSource            = evaluation;
                EvaluationDataGrid.Columns["Id"].Visible = false;
                for (int j = 0; j < EvaluationDataGrid.RowCount; j++)
                {
                    EvaluationDataGrid.Rows[j].Cells[EvaluationDataGrid.Columns["Select"].Index].Value = false;
                }
                cmd    = "Select Name, TotalMarks, TotalWeightage from Evaluation JOIN GroupEvaluation ON Id = EvaluationId";
                reader = DatabaseConnection.getInstance().getData(cmd);
                i      = 0;
                while (reader.FieldCount > i)
                {
                    if (!SearchCategoryE.Items.Contains(reader.GetName(i)))
                    {
                        SearchCategoryE.Items.Add(reader.GetName(i));
                    }
                    i++;
                }
                SearchCategoryE.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #10
0
        private void Save_Click(object sender, EventArgs e)
        {
            int flag = 0;

            try
            {
                EvaluationClass stu = new EvaluationClass();
                if ((string.IsNullOrEmpty(NameTextBox.Text)))
                {
                    flag++;
                }
                else if (Regexp("^[a-zA-Z]{1,100}", NameTextBox, NError, "Only alphabets are allowed.", 100))
                {
                    stu.Name = NameTextBox.Text;
                    flag++;
                }
                if ((string.IsNullOrEmpty(TMTextBox.Text)))
                {
                    flag++;
                    string cmd    = "SELECT COUNT(*) FROM Evaluation JOIN GroupEvaluation ON Id = EvaluationId WHERE ObtainedMarks > " + TMTextBox.Text;
                    var    reader = DatabaseConnection.getInstance().getData(cmd);
                    while (reader.Read())
                    {
                        if ((int)reader.GetValue(0) > 0)
                        {
                            flag--;
                            TMError.ForeColor = System.Drawing.Color.Red;
                            TMError.Text      = "Some data have obtained marks so it can't be null.";
                        }
                    }
                }
                else if (Regexp("^[0-9]{1,3}", TMTextBox, TMError, "Only valid numbers are allowed.", 3))
                {
                    stu.TotalMarks = Convert.ToInt32(TMTextBox.Text);
                    string cmd    = "SELECT COUNT(*) FROM Evaluation JOIN GroupEvaluation ON Id = EvaluationId WHERE ObtainedMarks > " + TMTextBox.Text;
                    var    reader = DatabaseConnection.getInstance().getData(cmd);
                    while (reader.Read())
                    {
                        if ((int)reader.GetValue(0) > 0)
                        {
                            flag--;
                            TMError.ForeColor = System.Drawing.Color.Red;
                            TMError.Text      = "Some data have obtained marks greater then current value.";
                        }
                    }
                    flag++;
                }
                if ((string.IsNullOrEmpty(TWTextBox.Text)))
                {
                    flag++;
                }
                else if (Regexp("^[0-9]{1,3}", TWTextBox, TWError, "Only valid numbers are allowed.", 3))
                {
                    if (Convert.ToInt32(TWTextBox.Text) > 100)
                    {
                        Regexp("^[?]{1,3}", TWTextBox, TWError, "Weightage cannot exceed 100%", 3);
                        flag--;
                    }
                    stu.TotalWeightage = Convert.ToInt32(TWTextBox.Text);
                    flag++;
                }
                if (flag == 3)
                {
                    if (stuold.Id != null)
                    {
                        string cmd = String.Format("Update Evaluation SET Name = '{0}', TotalMarks = '{1}', TotalWeightage = '{2}' WHERE Id = '{3}'", stu.Name, stu.TotalMarks, stu.TotalWeightage, stuold.Id);
                        DatabaseConnection.getInstance().exectuteQuery(cmd);
                    }
                    par.Refresh();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }