public void loadDataGridView() { dt_student = Student_Methods.loadStudent(); Student_Detail_dataGridView.DataSource = null; Student_Detail_dataGridView.DataSource = dt_student; Student_Detail_dataGridView.Columns["Profile"].Visible = false; }
private void save_button_Click(object sender, EventArgs e) { if (!isPersonalDet_Validated) { AlertBox.ShowDialog("Please fill up Personal Detail", AlertBox.AlertType.error, false); studentadmission_tabControl.SelectedIndex = 0; } else if (educational_details_validation() /* && isPersonalDet_Validated*/) { #region entity StudentEntity se = new StudentEntity(); se.grno = int.Parse(grno_textBox.Text); se.AdmissionDate = admission_dateTimePicker.Value; se.ProfilePhoto = ImagePath; se.candidate_FirstName = candidatefnm_TextBox.Text; se.candidate_MiddleName = candidatemnm_TextBox.Text; se.candidate_LastName = candidatelnm_TextBox.Text; se.gender = (male_radioButton.Checked) ? male_radioButton.Text : female_radioButton.Text; se.CastId = int.Parse(cast_comboBox.SelectedValue.ToString()); se.CountryId = int.Parse(country_comboBox.SelectedValue.ToString()); se.StateId = int.Parse(state_comboBox.SelectedValue.ToString()); se.CityId = int.Parse(city_comboBox.SelectedValue.ToString()); se.CurrentAddress = currentaddress_textbox.Text; se.PermanentAddress = permanentaddress_textbox.Text; se.Pincode = (pincode_TextBox.Text == string.Empty) ? (int?)null : int.Parse(pincode_TextBox.Text); se.BirthPlace = birthplace_TextBox.Text; se.DOB = dob_dateTimePicker.Value; se.MobileNo = Int64.Parse(candidate_mno_textbox.Text); se.TelephoneNo = (telephone_textbox.Text == string.Empty) ? (Int64?)null : Int64.Parse(telephone_textbox.Text); se.Email = email_textbox.Text; se.CourseId = int.Parse(admission_stream_combobox.SelectedValue.ToString()); se.Coursenm = admission_stream_combobox.Text; se.AdmissionSem = int.Parse(admission_sem_numericUpDown.Value.ToString()); se.CurrentSem = int.Parse(admission_sem_numericUpDown.Value.ToString()); se.Discount = int.Parse(discount_numericUpDown.Value.ToString()); se.Fees = int.Parse(fees_to_pay_textbox.Text); se.Remark = remark_textBox.Text; se.CurrentStatus = 'C'; if (Convert.ToInt32(admission_sem_numericUpDown.Maximum) > 1) { se.LeavingYear = admission_dateTimePicker.Value.Year + Convert.ToInt32(admission_sem_numericUpDown.Maximum / 2); } else { int Mymonth = 0; if ((admission_dateTimePicker.Value.Month + 6) > 12) { int InCurrentYear = 12 - admission_dateTimePicker.Value.Month; int InNextYear = 6 - InCurrentYear; Mymonth = InNextYear; } else { Mymonth = admission_dateTimePicker.Value.Month + 6; } DateTime dt = new DateTime(admission_dateTimePicker.Value.Year, Mymonth, admission_dateTimePicker.Value.Day); se.LeavingYear = dt.Year; } se.father_FirstName = fatherfnm_TextBox.Text; se.father_MiddleName = fathermnm_TextBox.Text; se.father_LastName = fatherlnm_TextBox.Text; se.mother_FirstName = motherfnm_TextBox.Text; se.mother_MiddleName = mothermnm_TextBox.Text; se.mother_LastName = motherlnm_TextBox.Text; se.ParentsOccupation = father_mother_occupation_textbox.Text; se.OfficeAddress = office_address_textBox.Text; se.ContactNo = Int64.Parse(parents_contact_TextBox.Text); se.SchoolName = schoolnm_textbox.Text; se.SchoolStream = school_stream_textbox.Text; se.LastYear = int.Parse(school_year_textbox.Text); se.LastYear_Percentage = int.Parse(school_percent_textbox.Text); se.marksheet_12 = school_marksheet_CheckBox.Checked; se.lc_12 = school_LC_checkBox.Checked; se.TC = college_tc_checkBox.Checked; se.previous_marksheet = college_previous_marksheet_checkBox.Checked; se.NOC = college_NOC_checkBox.Checked; if (college_checkBox.Checked) { se.checkCollege = true; se.CollegeName = collegenm_textbox.Text; se.CollegeStream = college_stream_textbox.Text; se.CollegeYear = int.Parse(college_year_textbox.Text); se.LastSem = int.Parse(college_last_sem_numericUpDown.Value.ToString()); se.LastSem_Percentage = int.Parse(college_percent_textbox.Text); } #endregion if (this.isUpdate) { Student_Methods.deleteStudent_for_Update(int.Parse(grno_textBox.Text)); } if (Student_Methods.insertStudent(se) > 0) { if (isStore) { File.Copy(openphoto.FileName, ImagePath, true); if (this.isUpdate) { student_pictureBox.Enabled = false; } } if (!isUpdate) { AlertBox.ShowDialog("Successfull registered", AlertBox.AlertType.success, true); clearAll(sender, e); loadGrno(); admission_stream_combobox_SelectedIndexChanged(sender, e); } else { AlertBox.ShowDialog("Successfully updated", AlertBox.AlertType.success, true); DataTable dt_student = Student_Methods.loadStudent(); } studentadmission_tabControl.SelectedIndex = 0; } } }