Exemplo n.º 1
0
        private void GridRow_DbClick(object sender, DataGridViewRowEventArgs e)
        {
            int    id      = 0;
            string myValue = dataGridstudent[e.Row.Index, 0].Value.ToString();

            Student        obj          = new Student();
            List <Student> listStudents = obj.List();
            Student        student      = listStudents.Where(x => x.Id == id).FirstOrDefault();
        }
Exemplo n.º 2
0
        private void BindGrid()
        {
            Student        obj           = new Student();
            List <Student> listsStudents = obj.List();
            DataTable      dta           = Utility.ConvertToDataTable(listsStudents);

            dataGridstudent.DataSource = dta;
            BindChart(listsStudents);
        }
Exemplo n.º 3
0
        private void dataGridstudent_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            Student obj = new Student();

            if (e.ColumnIndex == 0)
            {
                //get the value of the clicked rows id coloumn
                string value = dataGridstudent[2, e.RowIndex].Value.ToString();
                int    id    = 0;
                if (String.IsNullOrEmpty(value))
                {
                    MessageBox.Show("The data is invalid!");
                }
                else
                {
                    id = int.Parse(value);
                    Student student = obj.List().Where(x => x.Id == id).FirstOrDefault();
                    idTxt.Text               = student.Id.ToString();
                    firstTxt.Text            = student.Name.Split(' ')[0];
                    lastTxt.Text             = student.Name.Split(' ')[1];
                    addressTxt.Text          = student.Address;
                    contactTxt.Text          = student.ContactNo;
                    emailTxt.Text            = student.Email;
                    DPdob.Value              = student.BirthDate;
                    DPregister.Value         = student.RegistrationDate;
                    CBprogramme.SelectedItem = student.Programme;
                    CBgender.SelectedItem    = student.Gender;
                    submitBtn.Visible        = false;
                    updateBtn.Visible        = true;
                }
            }
            else if (e.ColumnIndex == 1)
            {
                string value = dataGridstudent[2, e.RowIndex].Value.ToString();
                if (String.IsNullOrEmpty(value))
                {
                    MessageBox.Show("The data is invalid!");
                }
                else
                {
                    string            message = "Do you want to remove this information?";
                    string            title   = "Deletion Confirmed";
                    MessageBoxButtons buttons = MessageBoxButtons.OKCancel;
                    DialogResult      result  = MessageBox.Show(message, title, buttons);
                    if (result == DialogResult.OK)
                    {
                        //get the value of the clicked rows id column
                        string Id = dataGridstudent[2, e.RowIndex].Value.ToString();
                        obj.Delete(int.Parse(Id));
                        BindGrid();
                        MessageBox.Show("The information has been deleted successfully.");
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void weeklyReport_ValueChanged(object sender, EventArgs e)
        {
            DateTime selected = weeklyReport.Value;
            var      culture  = System.Threading.Thread.CurrentThread.CurrentCulture;
            var      diff     = selected.DayOfWeek - culture.DateTimeFormat.FirstDayOfWeek;

            if (diff < 0)
            {
                diff += 7;
            }
            var first_day_week = selected.AddDays(-diff).Date;
            //startingDateLbl.Text = "Weekly Data shown starting with first day of week:" + first_day_week.ToString("dd/MM/yyyy");
            var last_day_week = selected.AddDays(7);

            stuWeekReport.Rows.Clear();
            Student        obj             = new Student();
            List <Student> listStudents    = obj.List();
            var            convertStudents = listStudents.Where(s => s.RegistrationDate >= first_day_week && s.RegistrationDate < last_day_week);

            int computing  = 0;
            int networking = 0;
            int multimedia = 0;


            foreach (Student stu in convertStudents)
            {
                if (stu.Programme == "Computing")
                {
                    computing += 1;
                }
                else if (stu.Programme == "Multimedia Technologies")
                {
                    multimedia += 1;
                }
                else if (stu.Programme == "Networking and IT Security")
                {
                    networking += 1;
                }
            }

            stuWeekReport.Rows.Add(new Object[] { "Computing", computing });
            stuWeekReport.Rows.Add(new Object[] { "Multimedia", multimedia });
            stuWeekReport.Rows.Add(new Object[] { "Networking", networking });
        }