Beispiel #1
0
 private void SearchButtonP_Click(object sender, EventArgs e)
 {
     try
     {
         if (SearchTextBoxP.Text == "")
         {
             Refresh();
             return;
         }
         String cmd    = "Select Id, Title, Description, AssignmentDate from Project JOIN GroupProject ON Id = ProjectId WHERE GroupId = " + id.ToString() + " AND " + SearchCategoryP.Text + " = '" + SearchTextBoxP.Text + "'";
         var    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;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #2
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (SearchTextBox.Text == "")
                {
                    Refresh();
                    return;
                }
                String cmd    = "Select Id, Title, Description from Project Where " + SearchCategory.Text + " = '" + SearchTextBox.Text + "'";
                var    reader = DatabaseConnection.getInstance().getData(cmd);

                List <ProjectClass> students = 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);
                    students.Add(stu);
                }
                ProjectDataGrid.DataSource = students;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #3
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, Title FROM Project WHERE Id NOT IN (Select Id from Project JOIN GroupProject ON Id = ProjectId WHERE GroupId = " + id.ToString() + ")";
         var    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);
             project.Add(stu);
         }
         ProjectDataGrid.DataSource = project;
         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["Description"].Visible    = false;
         ProjectDataGrid.Columns["AssignmentDate"].Visible = false;
         cmd    = "Select Title from Project JOIN GroupProject ON Id = ProjectId";
         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);
     }
 }
Beispiel #4
0
        public ProjectDetails(int id)
        {
            InitializeComponent();
            this.MinimumSize = new Size(this.Width, this.Height);
            String       cmd    = "SELECT Id, Title, Description FROM Project where Id = " + id.ToString();
            var          reader = DatabaseConnection.getInstance().getData(cmd);
            ProjectClass stuold = new ProjectClass();

            while (reader.Read())
            {
                stuold.Id          = (int)reader.GetValue(0);
                stuold.Titlle      = reader.GetString(1);
                stuold.Description = reader.GetString(2);
            }
            TitleLabel1.Text = stuold.Titlle;
            DescLabel.Text   = stuold.Description;
        }
Beispiel #5
0
        public ProjectEdit(int id, MainPage parent)
        {
            par = parent;
            InitializeComponent();
            this.MinimumSize = new Size(this.Width, this.Height);
            TitleError.Text  = "";
            DesError.Text    = "";
            String cmd    = "SELECT Id, Title, Description FROM Project where Id = " + id.ToString();
            var    reader = DatabaseConnection.getInstance().getData(cmd);

            stuold = new ProjectClass();
            while (reader.Read())
            {
                stuold.Id          = (int)reader.GetValue(0);
                stuold.Titlle      = reader.GetString(1);
                stuold.Description = reader.GetString(2);
            }
            TitleTextBox.Text = stuold.Titlle;
            DesTextBox.Text   = stuold.Description;
        }
Beispiel #6
0
        public void Refresh()
        {
            try
            {
                String cmd    = "Select Id, Title, Description from Project";
                var    reader = DatabaseConnection.getInstance().getData(cmd);

                List <ProjectClass> students = 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);
                    students.Add(stu);
                }
                ProjectDataGrid.DataSource = students;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #7
0
        private void Add_Click(object sender, EventArgs e)
        {
            int flag = 0;

            try
            {
                ProjectClass stu = new ProjectClass();
                stu.Titlle      = null;
                stu.Description = null;
                if (Regexp("^[a-zA-Z]{1,100}", TitleTextBox, TitleError, "Only alphabets are allowed.", 100))
                {
                    stu.Titlle = TitleTextBox.Text;
                    flag++;
                }
                if ((string.IsNullOrEmpty(DesTextBox.Text)))
                {
                    flag++;
                }
                else
                {
                    stu.Description = DesTextBox.Text;
                    flag++;
                }
                if (flag == 2)
                {
                    String cmd = String.Format("Update Project SET Title = '{0}', Description = '{1}' WHERE Id = '{2}'", stu.Titlle, stu.Description, stuold.Id);
                    DatabaseConnection.getInstance().exectuteQuery(cmd);
                    par.Refresh();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #8
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);
            }
        }
Beispiel #9
0
        public Project()
        {
            InitializeComponent();
            this.MinimumSize = new Size(this.Width, this.Height);
            try
            {
                String cmd    = "Select Id, Title, Description from Project";
                var    reader = DatabaseConnection.getInstance().getData(cmd);

                List <ProjectClass> students = 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);
                    students.Add(stu);
                }
                ProjectDataGrid.DataSource         = students;
                ProjectDataGrid.Columns[0].Visible = false;
                ProjectDataGrid.Columns[2].Visible = false;
                DataGridViewButtonColumn bcol3 = new DataGridViewButtonColumn();
                bcol3.HeaderText = "";
                bcol3.Text       = "Details";
                bcol3.Name       = "btnDetails";
                bcol3.UseColumnTextForButtonValue = true;
                ProjectDataGrid.Columns.Add(bcol3);
                DataGridViewButtonColumn bcol = new DataGridViewButtonColumn();
                bcol.HeaderText = "";
                bcol.Text       = "Edit";
                bcol.Name       = "btnEdit";
                bcol.UseColumnTextForButtonValue = true;
                ProjectDataGrid.Columns.Add(bcol);
                DataGridViewButtonColumn bcol1 = new DataGridViewButtonColumn();
                bcol1.HeaderText = "";
                bcol1.Text       = "Delete";
                bcol1.Name       = "btnDelete";
                bcol1.UseColumnTextForButtonValue = true;
                ProjectDataGrid.Columns.Add(bcol1);
                DataGridViewButtonColumn bcol2 = new DataGridViewButtonColumn();
                bcol2.HeaderText = "";
                bcol2.Text       = "Group";
                bcol2.Name       = "btnGroup";
                bcol2.UseColumnTextForButtonValue = true;
                ProjectDataGrid.Columns.Add(bcol2);
                cmd    = "Select Title from Project";
                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);
            }
        }