Esempio n. 1
0
 private void CertDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == CertDataGridView.Columns["ViewStudentImage"].Index && e.RowIndex >= 0)
     {
         int       certId    = int.Parse(CertDataGridView.Rows[e.RowIndex].Cells["Id"].Value.ToString());
         CertModel certModel = managingCertService.GetSingleCertById(certId);
         string    imageName = managingStudentService.GetStudentImage(certModel.StudentId);
         if (string.IsNullOrEmpty(imageName))
         {
             //MessageBox.Show("Không tìm thấy ảnh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             NotificationForm notificationForm = new NotificationForm("Không tìm thấy ảnh", "Cảnh báo", MessageBoxIcon.Warning);
             notificationForm.ShowDialog();
             return;
         }
         string           path             = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
         ShowingImageForm showingImageForm = new ShowingImageForm(Path.Combine(@"C:\JbCert_Resource\StudentImages\", imageName));
         showingImageForm.ShowDialog();
     }
     else if (e.ColumnIndex == CertDataGridView.Columns["ViewBlankCertImage"].Index && e.RowIndex >= 0)
     {
         int       certId    = int.Parse(CertDataGridView.Rows[e.RowIndex].Cells["Id"].Value.ToString());
         CertModel certModel = managingCertService.GetSingleCertById(certId);
         string    imageName = managingBlankCertService.GetBlankCertImage(certModel.BlankCertId);
         if (string.IsNullOrEmpty(imageName))
         {
             //MessageBox.Show("Không tìm thấy ảnh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             NotificationForm notificationForm = new NotificationForm("Không tìm thấy ảnh", "Cảnh báo", MessageBoxIcon.Warning);
             notificationForm.ShowDialog();
             return;
         }
         string           path             = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
         ShowingImageForm showingImageForm = new ShowingImageForm(Path.Combine(@"C:\JbCert_Resource\Images\", imageName));
         showingImageForm.ShowDialog();
     }
 }
Esempio n. 2
0
 private void ChosenStudentDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == ChosenStudentDataGridView.Columns["ChosenRemove"].Index && e.RowIndex >= 0)
     {
         int studentId = int.Parse(ChosenStudentDataGridView.Rows[e.RowIndex].Cells["ChosenId"].Value.ToString());
         ChangeDataChosenStudents(studentId, false);
     }
     else if (e.ColumnIndex == StudentDataGridView.Columns["ShowImage"].Index && e.RowIndex >= 0)
     {
         int    studentId = int.Parse(ChosenStudentDataGridView.Rows[e.RowIndex].Cells["ChosenId"].Value.ToString());
         string imageName = managingStudentService.GetStudentImage(studentId);
         if (string.IsNullOrEmpty(imageName))
         {
             //MessageBox.Show("Không tìm thấy ảnh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             NotificationForm notificationForm = new NotificationForm("Không tìm thấy ảnh", "Lỗi", MessageBoxIcon.Error);
             notificationForm.ShowDialog();
             return;
         }
         string           path             = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
         ShowingImageForm showingImageForm = new ShowingImageForm(Path.Combine(@"C:\JbCert_Resource\StudentImages", imageName));
         showingImageForm.ShowDialog();
     }
     else if (e.ColumnIndex == StudentDataGridView.Columns["Detail"].Index && e.RowIndex >= 0)
     {
         int studentId = int.Parse(ChosenStudentDataGridView.Rows[e.RowIndex].Cells["ChosenId"].Value.ToString());
         DetailStudentForm detailStudentForm = new DetailStudentForm(studentId);
         detailStudentForm.ShowDialog();
     }
 }
Esempio n. 3
0
        private void BlankCertDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == BlankCertDataGridView.Columns["Select"].Index && e.RowIndex >= 0)
            {
                int blankCertId = int.Parse(BlankCertDataGridView.Rows[e.RowIndex].Cells["Id"].Value.ToString());
                ChangeDataChosenBlankCerts(blankCertId, true);
            }
            else if (e.ColumnIndex == BlankCertDataGridView.Columns["ShowImage"].Index && e.RowIndex >= 0)
            {
                int blankCertId = int.Parse(BlankCertDataGridView.Rows[e.RowIndex].Cells["Id"].Value.ToString());
                string imageName = managingBlankCertService.GetSingleById(blankCertId).Image;
                if (string.IsNullOrEmpty(imageName))
                {
                    //MessageBox.Show("Không tìm thấy ảnh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    NotificationForm notificationForm = new NotificationForm("Không tìm thấy ảnh", "Lỗi", MessageBoxIcon.Error);
                    notificationForm.ShowDialog();
                    return;
                }
                string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
                ShowingImageForm showingImageForm = new ShowingImageForm(Path.Combine(@"C:\JbCert_Resource\Images\", imageName));
                showingImageForm.ShowDialog();

            }
  
        }
Esempio n. 4
0
        private void ViewBlankCertImageButton_Click(object sender, EventArgs e)
        {
            string imageName = managingBlankCertService.GetBlankCertImage(certModel.BlankCertId);

            if (string.IsNullOrEmpty(imageName))
            {
                //MessageBox.Show("Không tìm thấy ảnh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NotificationForm notificationForm = new NotificationForm("Không tìm thấy ảnh", "Lỗi", MessageBoxIcon.Error);
                notificationForm.ShowDialog();
                return;
            }
            string           path             = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
            ShowingImageForm showingImageForm = new ShowingImageForm(Path.Combine(@"C:\JbCert_Resource\Images\", imageName));

            showingImageForm.ShowDialog();
        }
        private void StudentDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == StudentDataGridView.Columns["Edit"].Index && e.RowIndex >= 0)
            {
                int             studentId         = int.Parse(StudentDataGridView.Rows[e.RowIndex].Cells["Id"].Value.ToString());
                EditStudentForm editBlankCertForm = new EditStudentForm(studentId);
                editBlankCertForm.ShowDialog();
            }
            else if (e.ColumnIndex == StudentDataGridView.Columns["Avatar"].Index && e.RowIndex >= 0)
            {
                try
                {
                    int    studentId = int.Parse(StudentDataGridView.Rows[e.RowIndex].Cells["Id"].Value.ToString());
                    string imageName = managingStudentService.GetStudentImage(studentId);
                    if (string.IsNullOrEmpty(imageName))
                    {
                        //MessageBox.Show("Không tìm thấy ảnh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        NotificationForm notificationForm = new NotificationForm("Không tìm thấy ảnh", "Cảnh báo", MessageBoxIcon.Warning);
                        notificationForm.ShowDialog();
                        return;
                    }

                    string           path             = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
                    ShowingImageForm showingImageForm = new ShowingImageForm(Path.Combine(@"C:\JbCert_Resource\StudentImages", imageName));
                    showingImageForm.ShowDialog();
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                    notificationForm.ShowDialog();
                }
            }
            else if (e.ColumnIndex == StudentDataGridView.Columns["Delete"].Index && e.RowIndex >= 0)
            {
                DialogResult dialogResult = MessageBox.Show("Đồng ý xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.Yes)
                {
                    try
                    {
                        int studentId = int.Parse(StudentDataGridView.Rows[e.RowIndex].Cells["Id"].Value.ToString());
                        int result    = managingStudentService.DeleteStudent(studentId);
                        if (result > 0)
                        {
                            //MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            NotificationForm notificationForm = new NotificationForm("Xóa thành công", "Thông báo", MessageBoxIcon.Information);
                            notificationForm.ShowDialog();
                            LoadStudentList();
                        }
                        else
                        {
                            //MessageBox.Show("Xóa không thành công", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            NotificationForm notificationForm = new NotificationForm("Xóa không thành công", "Cảnh báo", MessageBoxIcon.Warning);
                            notificationForm.ShowDialog();
                        }
                    }
                    catch (Exception ex)
                    {
                        //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                        notificationForm.ShowDialog();
                    }
                }
                else if (dialogResult == DialogResult.No)
                {
                    //no delete
                }
            }
        }