private void txt_enter_name_SelectedIndexChanged(object sender, EventArgs e) { UC_payments.studno = txt_enter_name.Text.Split('-').GetValue(0).ToString(); UC_payments u = new UC_payments(); metroPanel1.Controls.Clear(); con.Open(); SqlCommand cmd = new SqlCommand("EXECUTE stud_details_for_payments '" + txt_enter_name.Text.Split('-').GetValue(0).ToString() + "'", con); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); u.txt_studno.Text = dr.GetValue(0).ToString(); u.txt_studname.Text = dr.GetValue(1).ToString(); u.txt_course_name.Text = General_methods.get_course_name_from_course_no(dr.GetValue(2).ToString()); u.txt_batch_no.Text = dr.GetValue(3).ToString(); u.txt_course_fee_for_full_payament.Text = u.txt_cfee.Text = u.txt_module_pay_course_fee.Text = dr.GetValue(4).ToString() + "/="; u.txt_nic.Text = dr.GetValue(5).ToString(); u.txt_batch_name.Text = General_methods.get_batch_name_from_batch_ne(dr.GetValue(3).ToString()); General_methods.get_stud_pic(u.pictureBox1, dr.GetValue(0).ToString()); u.txt_amount_payable.Text = General_methods.calc_amount_payable(txt_enter_name.Text.Split('-').GetValue(0).ToString().ToString(), 0, "Diploma").ToString() + "/="; u.txt_reg_fee_of_course.Text = dr.GetValue(6).ToString() + "/="; metroPanel1.Controls.Add(u); dr.Close(); con.Close(); u.label1.TextChanged += handler; }
public void handler2(object sender, EventArgs e) { UC_payements_certif.studno = txt_certif_enter_name.Text.Split('-').GetValue(0).ToString(); UC_payements_certif u = new UC_payements_certif(); metroPanel2.Controls.Clear(); con.Open(); SqlCommand cmd = new SqlCommand("EXECUTE stud_details_for_payments '" + txt_certif_enter_name.Text.Split('-').GetValue(0).ToString() + "'", con); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); u.txt_studno.Text = dr.GetValue(0).ToString(); u.txt_studname.Text = dr.GetValue(1).ToString(); u.txt_course_name.Text = General_methods.get_course_name_from_course_no(dr.GetValue(2).ToString()); u.txt_batch_no.Text = dr.GetValue(3).ToString(); u.txt_reg_fee.Text = u.txt_cfee.Text = u.txt_course_fee.Text = dr.GetValue(4).ToString() + "/="; u.txt_nic.Text = dr.GetValue(5).ToString(); u.txt_batch_name.Text = General_methods.get_batch_name_from_batch_ne(dr.GetValue(3).ToString()); General_methods.get_stud_pic(u.pictureBox1, dr.GetValue(0).ToString()); u.txt_amount_payabme.Text = General_methods.calc_amount_payable(txt_certif_enter_name.Text.Split('-').GetValue(0).ToString().ToString(), 0, "Certificate").ToString() + "/="; u.txt_reg_fee.Text = dr.GetValue(6).ToString() + "/="; metroPanel2.Controls.Add(u); dr.Close(); con.Close(); u.label1.TextChanged += handler2; }
private void cmb_batch_SelectedIndexChanged(object sender, EventArgs e) { txt_batch_no.Text = General_methods.get_batch_no_from_batch_name(cmb_batch.Text); txt_course_namer.Text = General_methods.get_course_name_from_course_no(General_methods.get_course_no_of_batch_from_batch_no(txt_batch_no.Text)); cmb_medium.Text = General_methods.get_medium_from_batch_no(txt_batch_no.Text); stud_no_change(); }
private void Module_selection_Load(object sender, EventArgs e) { if (state == false) { lbl_course_name.Text = General_methods.get_course_name_from_course_no(lbl_course_no.Text); lbl_min_mods.Text = d.singleString("SELECT No_of_modules_to_be_selected FROM Course_details_master WHERE course_no='" + lbl_course_no.Text + "'"); con.Open(); SqlCommand cmd = new SqlCommand("SELECT Module_name,compulsory FROM Dip_module_details_2 WHERE Course_no='" + lbl_course_no.Text + "'", con); SqlDataReader dr = cmd.ExecuteReader(); int i = 0; while (dr.Read()) { checkedListBox1.Items.Add(dr.GetValue(0).ToString()); if (dr.GetBoolean(1) == true) { checkedListBox1.SetItemChecked(i, true); a.Add(i); } else { checkedListBox1.SetItemChecked(i, false); } i++; } con.Close(); } else { lbl_course_name.Text = General_methods.get_course_name_from_course_no(lbl_course_no.Text); lbl_min_mods.Text = d.singleString("SELECT No_of_modules_to_be_selected FROM Course_details_master WHERE course_no='" + lbl_course_no.Text + "'"); con.Open(); SqlCommand cmd = new SqlCommand("SELECT Module_name,compulsory FROM Dip_module_details_2 WHERE Course_no='" + lbl_course_no.Text + "'", con); SqlDataReader dr = cmd.ExecuteReader(); int i = 0; while (dr.Read()) { checkedListBox1.Items.Add(dr.GetValue(0).ToString()); if (dr.GetBoolean(1) == true) { checkedListBox1.SetItemChecked(i, true); a.Add(i); } if (d.singleInt("SELECT COUNT(*) FROM Dip_stud_modules WHERE stud_no='" + lbl_stud_no.Text + "' AND module_no='" + General_methods.get_module_no_from_module_name(dr.GetValue(0).ToString(), lbl_course_no.Text) + "'") != 0) { checkedListBox1.SetItemChecked(i, true); } else { checkedListBox1.SetItemChecked(i, false); } i++; } con.Close(); } }
public static void studcredentials() { SqlConnection con = new SqlConnection(Credentials.connection); con.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM Stud_details WHERE stud_no='" + studno + "'", con); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); courseno = dr.GetValue(17).ToString(); coursename = General_methods.get_course_name_from_course_no(dr.GetValue(17).ToString()); fname = dr.GetValue(1).ToString(); lname = dr.GetValue(2).ToString(); email = dr.GetValue(14).ToString(); dr.Close(); SqlCommand cmd1 = new SqlCommand("SELECT course_name FROM Course_details_master WHERE course_no='" + courseno + "'", con); SqlDataReader dr1 = cmd1.ExecuteReader(); dr1.Read(); coursename = dr1.GetValue(0).ToString(); dr1.Close(); SqlCommand cmd2 = new SqlCommand("SELECT * FROM Folder_ids WHERE course_no='" + courseno + "'", con); SqlDataReader dr2 = cmd2.ExecuteReader(); dr2.Read(); notes_folder = dr2.GetValue(2).ToString(); assignment_folder = dr2.GetValue(3).ToString(); papers_folder = dr2.GetValue(4).ToString(); dr2.Close(); /*SqlCommand cmd3 = new SqlCommand("SELECT f_name FROM Dip_stud_details WHERE stud_no='" + Class_student.studno + "'", con); * SqlDataReader dr3 = cmd3.ExecuteReader(); * dr3.Read(); * fname = dr3.GetValue(0).ToString(); * dr3.Close(); * SqlCommand cmd4 = new SqlCommand("SELECT l_name FROM Dip_stud_details WHERE stud_no='" + Class_student.studno + "'", con); * SqlDataReader dr4 = cmd4.ExecuteReader(); * dr4.Read(); * lname = dr4.GetValue(0).ToString();*/ }
public void handler3(object sender, EventArgs e) { metroPanel3.Controls.Clear(); UC_short_payment.progno = cmb_select_workshops_and_shortprogs.Text.Split('-').GetValue(0).ToString(); UC_short_payment s = new UC_short_payment(); s.txt_progno.Text = cmb_select_workshops_and_shortprogs.Text.Split('-').GetValue(0).ToString(); con.Open(); SqlCommand cmd = new SqlCommand("SELECT s.program_no,s.scheduled_date,s.course_type,s.venue,c.per_head_price,c.Program_title,s.course_no FROM Session_details s INNER JOIN Short_program_details c ON s.program_no=c.Code WHERE s.program_no= '" + cmb_select_workshops_and_shortprogs.Text.Split('-').GetValue(0).ToString() + "'", con); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); s.txt_progno.Text = dr.GetValue(0).ToString(); s.txt_datw.Text = dr.GetValue(1).ToString(); s.txt_progtype.Text = dr.GetValue(2).ToString(); s.txt_venue.Text = dr.GetValue(3).ToString(); if (dr.GetValue(5).ToString() == "None") { s.txt_progtitle.Text = General_methods.get_course_name_from_course_no(dr.GetValue(6).ToString()); } else { s.txt_progtitle.Text = dr.GetValue(5).ToString(); } if (!dr.IsDBNull(4)) { s.txt_priceperhead.Text = dr.GetValue(4).ToString() + "/="; } else { s.txt_priceperhead.Text = "Not yet assigned. To assign price per head, go to manage workshops"; } metroPanel3.Controls.Add(s); con.Close(); s.label1.TextChanged += handler3; }
public void redraw_controls(string data) { invisible(); con.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM Stud_details WHERE stud_no='" + data + "' ", con); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); if (dr.IsDBNull(23)) { txt_no.Text = dr.GetValue(0).ToString(); no = dr.GetValue(0).ToString(); txt_fname.Text = dr.GetValue(1).ToString() + " " + dr.GetValue(2).ToString() + " " + dr.GetValue(3).ToString(); txt_gender.Text = dr.GetValue(4).ToString(); txt_nic.Text = dr.GetValue(5).ToString(); txt_desig.Text = dr.GetValue(7).ToString(); txt_address.Text = dr.GetValue(22).ToString() + " " + d.singleString("SELECT Address_string FROM Place_Details WHERE place_id='" + dr.GetValue(8).ToString() + "'"); txt_resi_tel.Text = dr.GetValue(10).ToString(); txt_mobile.Text = dr.GetValue(9).ToString(); txt_resi_email.Text = dr.GetValue(11).ToString(); contact_p_1_name.Text = dr.GetValue(15).ToString(); contact_p_1_no.Text = dr.GetValue(16).ToString(); contact_p_2_name.Text = dr.GetValue(17).ToString(); contact_p_2_no.Text = dr.GetValue(18).ToString(); txt_batchno.Text = dr.GetValue(21).ToString(); txt_stud_name_with_initials.Text = dr.GetValue(24).ToString(); txt_batch_name.Text = General_methods.get_batch_name_from_batch_ne(dr.GetValue(21).ToString()); txt_course_code.Text = dr.GetValue(12).ToString(); txt_course_name.Text = General_methods.get_course_name_from_course_no(dr.GetValue(12).ToString()); txt_typ.Text = General_methods.get_course_type_from_course_no(dr.GetValue(12).ToString()); txt_medium.Text = dr.GetValue(13).ToString(); txt_bday.Text = Convert.ToDateTime(dr.GetValue(14).ToString()).ToLongDateString(); txt_age.Text = (DateTime.Today.Year - Convert.ToDateTime(txt_bday.Text).Year).ToString(); txt_org_name.Text = General_methods.find_organization_name_from_organization_no(dr.GetValue(6).ToString()); string[] a = General_methods.get_organization_details_from_org_name(txt_org_name.Text); txt_oaddress.Text = a[0]; txt_otel.Text = a[1]; txt_oemail.Text = a[2]; txt_fax.Text = a[3]; if (!dr.IsDBNull(20)) { General_methods.get_stud_pic(pictureBox1, dr.GetValue(0).ToString()); } visible(); con.Close(); dr.Close(); listBox1.Items.Clear(); if (General_methods.get_course_type_from_course_no(txt_course_code.Text) == "Diploma") { con.Open(); SqlCommand cmd3 = new SqlCommand("SELECT module_no FROM Dip_stud_modules WHERE stud_no='" + txt_no.Text + "'", con); SqlDataReader dr3 = cmd3.ExecuteReader(); while (dr3.Read()) { listBox1.Items.Add(General_methods.get_module_name_from_module_no(dr3.GetValue(0).ToString())); } dr3.Close(); con.Close(); } else { groupBox5.Visible = false; } } else { SqlConnection con2 = new SqlConnection(Credentials.connection); SqlCommand cmd2 = new SqlCommand("SELECT * FROM Stud_details WHERE stud_no='" + dr.GetValue(23).ToString() + "' ", con2); con2.Open(); SqlDataReader dr2 = cmd2.ExecuteReader(); dr2.Read(); txt_no.Text = dr2.GetValue(0).ToString(); no = dr2.GetValue(0).ToString(); txt_fname.Text = dr2.GetValue(1).ToString() + " " + dr2.GetValue(2).ToString() + " " + dr2.GetValue(3).ToString(); txt_gender.Text = dr2.GetValue(4).ToString(); txt_nic.Text = dr2.GetValue(5).ToString(); txt_desig.Text = dr2.GetValue(7).ToString(); txt_address.Text = dr2.GetValue(22).ToString() + " " + dr.GetValue(22).ToString() + " " + d.singleString("SELECT Address_string FROM Place_Details WHERE place_id='" + dr2.GetValue(8).ToString() + "'"); txt_resi_tel.Text = dr2.GetValue(10).ToString(); txt_mobile.Text = dr2.GetValue(9).ToString(); txt_resi_email.Text = dr2.GetValue(11).ToString(); contact_p_1_name.Text = dr2.GetValue(15).ToString(); contact_p_1_no.Text = dr2.GetValue(16).ToString(); contact_p_2_name.Text = dr2.GetValue(17).ToString(); contact_p_2_no.Text = dr2.GetValue(18).ToString(); txt_batchno.Text = dr.GetValue(21).ToString(); txt_stud_name_with_initials.Text = dr2.GetValue(24).ToString(); txt_batch_name.Text = General_methods.get_batch_name_from_batch_ne(dr.GetValue(21).ToString()); txt_course_code.Text = dr.GetValue(12).ToString(); txt_course_name.Text = General_methods.get_course_name_from_course_no(dr.GetValue(12).ToString()); txt_typ.Text = General_methods.get_course_type_from_course_no(dr.GetValue(12).ToString()); txt_medium.Text = dr.GetValue(13).ToString(); txt_org_name.Text = General_methods.find_organization_name_from_organization_no(dr2.GetValue(6).ToString()); string[] a = General_methods.get_organization_details_from_org_name(txt_org_name.Text); txt_oaddress.Text = a[0]; txt_otel.Text = a[1]; txt_oemail.Text = a[2]; txt_fax.Text = a[3]; visible(); con.Close(); con2.Close(); dr.Close(); dr2.Close(); listBox1.Items.Clear(); if (General_methods.get_course_type_from_course_no(txt_course_code.Text) == "Diploma") { con.Open(); SqlCommand cmd3 = new SqlCommand("SELECT module_no FROM Dip_stud_modules WHERE stud_no='" + txt_no.Text + "'", con); SqlDataReader dr3 = cmd3.ExecuteReader(); while (dr3.Read()) { listBox1.Items.Add(General_methods.get_module_name_from_module_no(dr3.GetValue(0).ToString())); } dr3.Close(); con.Close(); } else { groupBox5.Visible = false; } } }
private void cmb_batch_SelectedIndexChanged(object sender, EventArgs e) { cmb_name.Text = General_methods.get_course_name_from_course_no(General_methods.get_course_no_of_batch_from_batch_no(General_methods.get_batch_no_from_batch_name(cmb_batch.Text))); }
private void metroGrid1_CellContentClick(object sender, DataGridViewCellEventArgs e) { con.Open(); edit f2 = new edit(); f2.Show(); f2.txt_progno.Text = this.metroGrid1.CurrentRow.Cells[0].Value.ToString(); f2.txt_date.Text = this.metroGrid1.CurrentRow.Cells[1].Value.ToString(); f2.cmb_rp_1.DataSource = General_methods.fill_lecturer_names_combobox(); //f2.cmb_rp_2.DataSource = General_methods.fill_lecturer_names_combobox(); //f2.cmb_rp_3.DataSource = General_methods.fill_lecturer_names_combobox(); if (metroGrid1.CurrentRow.Cells[5].Value.ToString() != "None") { f2.cmb_rp_1.Text = General_methods.get_lec_name_from_lec_no(metroGrid1.CurrentRow.Cells[5].Value.ToString()); } if (metroGrid1.CurrentRow.Cells[6].Value.ToString() != "None") { f2.metroCheckBox1.Checked = true; f2.cmb_rp_2.DataSource = General_methods.fill_lecturer_names_combobox(); f2.cmb_rp_2.Text = General_methods.get_lec_name_from_lec_no(metroGrid1.CurrentRow.Cells[6].Value.ToString()); } else { f2.metroCheckBox1.Checked = false; } if (metroGrid1.CurrentRow.Cells[7].Value.ToString() != "None") { f2.metroCheckBox2.Checked = true; f2.cmb_rp_3.DataSource = General_methods.fill_lecturer_names_combobox(); f2.cmb_rp_3.Text = General_methods.get_lec_name_from_lec_no(metroGrid1.CurrentRow.Cells[7].Value.ToString()); } else { f2.metroCheckBox2.Checked = false; //f2.cmb_rp_3.Enabled = false; } if (this.metroGrid1.CurrentRow.Cells[2].Value.ToString() == "Diploma") { f2.cmb_type_2.SelectedIndex = 0; Array.Clear(name1, 0, 100); f2.cmb_name1.Text = General_methods.get_course_name_from_course_no(this.metroGrid1.CurrentRow.Cells[3].Value.ToString()); f2.course_no.Text = this.metroGrid1.CurrentRow.Cells[3].Value.ToString(); f2.cmb_module_2.Text = this.metroGrid1.CurrentRow.Cells[4].Value.ToString(); f2.txt_progtitle.Enabled = false; } else if (this.metroGrid1.CurrentRow.Cells[2].Value.ToString() == "Certificate") { f2.cmb_type_2.SelectedIndex = 1; f2.cmb_name1.Text = General_methods.get_course_name_from_course_no(this.metroGrid1.CurrentRow.Cells[3].Value.ToString()); f2.txt_progtitle.Enabled = false; } else if (this.metroGrid1.CurrentRow.Cells[2].Value.ToString() == "One-day") { f2.cmb_type_2.SelectedIndex = 2; f2.cmb_name1.Text = General_methods.get_course_name_from_course_no(this.metroGrid1.CurrentRow.Cells[3].Value.ToString()); txt_progtitle.Enabled = false; } else if (this.metroGrid1.CurrentRow.Cells[2].Value.ToString() == "Two-day") { f2.cmb_type_2.SelectedIndex = 3; f2.cmb_name1.Text = General_methods.get_course_name_from_course_no(this.metroGrid1.CurrentRow.Cells[3].Value.ToString()); f2.txt_progtitle.Enabled = false; } else if (this.metroGrid1.CurrentRow.Cells[2].Value.ToString() == "Three-day") { f2.cmb_type_2.SelectedIndex = 4; f2.cmb_name1.Text = General_methods.get_course_name_from_course_no(this.metroGrid1.CurrentRow.Cells[3].Value.ToString()); f2.txt_progtitle.Enabled = false; } else if (metroGrid1.CurrentRow.Cells[2].Value.ToString() == "Workshop") { f2.cmb_type_2.SelectedIndex = 5; f2.cmb_name1.Enabled = false; //2.cmb_name1.Text = General_methods.get_course_name_from_course_no(this.metroGrid1.CurrentRow.Cells[3].Value.ToString()); f2.txt_progtitle.Enabled = true; f2.cmb_type_2.Enabled = false; Database d = new Database(); f2.txt_progtitle.Text = d.singleString("SELECT Program_title FROM Short_program_details WHERE Code='" + metroGrid1.CurrentRow.Cells[0].Value.ToString() + "'"); } f2.txt_venue.Text = this.metroGrid1.CurrentRow.Cells[7].Value.ToString(); if (metroGrid1.CurrentRow.Cells[8].Value.ToString() == "NILS") { f2.rbn_in.Checked = true; } else { f2.rbn_out.Checked = true; f2.txt_venue.Text = metroGrid1.CurrentRow.Cells[8].Value.ToString(); } con.Close(); }
/// <summary> /// FUNCTION FOR EXPORT TO EXCEL /// </summary> /// <param name="dataTable"></param> /// <param name="worksheetName"></param> /// <param name="saveAsLocation"></param> /// <returns></returns> public bool WriteDataTableToExcel(System.Data.DataTable dataTable, string worksheetName, string saveAsLocation, string ReporType, string progtype, string user, int No_of_individual_participants, string type = "program", string courseno = null, bool paymentreport = false) { Microsoft.Office.Interop.Excel.Application excel; Microsoft.Office.Interop.Excel.Workbook excelworkBook; Microsoft.Office.Interop.Excel.Worksheet excelSheet; Microsoft.Office.Interop.Excel.Range excelCellrange; try { // Start Excel and get Application object. excel = new Microsoft.Office.Interop.Excel.Application(); // for making Excel visible excel.Visible = true; excel.DisplayAlerts = true; // Creation a new Workbook excelworkBook = excel.Workbooks.Add(Type.Missing); // Workk sheet excelSheet = (Microsoft.Office.Interop.Excel.Worksheet)excelworkBook.ActiveSheet; excelSheet.Name = worksheetName; excelSheet.Cells[1, 1] = "Report Name - " + ReporType; excelSheet.Cells[2, 1] = "Date of Report Generation : " + General_methods.get_current_date(); excelSheet.Cells[3, 1] = "Time of Report Generation :" + General_methods.get_current_time(); excelSheet.Cells[4, 1] = "Report Created By :" + user; if (type == "program") { excelSheet.Cells[5, 1] = "Program Type :" + progtype; } else if (type == "diploma") { excelSheet.Cells[5, 1] = "Course name :" + General_methods.get_course_name_from_course_no(courseno); } else if (type == "all") { excelSheet.Cells[5, 1] = "For all batches"; } // loop through each row and add values to our sheet int rowcount = 6; foreach (DataRow datarow in dataTable.Rows) { //adding one to rowcount rowcount += 1; for (int i = 1; i <= dataTable.Columns.Count; i++) { // on the first iteration we add the column headers if (rowcount == 7) { excelSheet.Cells[6, i] = dataTable.Columns[i - 1].ColumnName; excelSheet.Cells.Font.Color = System.Drawing.Color.Black; excelSheet.Cells[6, i].Font.Bold = true; } excelSheet.Cells[rowcount, i] = datarow[i - 1].ToString(); //for alternate rows if (rowcount > 7) { if (i == dataTable.Columns.Count) { if (rowcount % 4 == 0) { excelCellrange = excelSheet.Range[excelSheet.Cells[rowcount, 1], excelSheet.Cells[rowcount, dataTable.Columns.Count]]; //FormattingExcelCells(excelCellrange, "#CCCCFF", System.Drawing.Color.Black, false); } } } } } // now we resize the columns excelCellrange = excelSheet.Range[excelSheet.Cells[1, 1], excelSheet.Cells[rowcount, dataTable.Columns.Count]]; excelCellrange.EntireColumn.AutoFit(); Microsoft.Office.Interop.Excel.Borders border = excelCellrange.Borders; border.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; border.Weight = 2d; excelCellrange = excelSheet.Range[excelSheet.Cells[1, 1], excelSheet.Cells[5, dataTable.Columns.Count + 12]]; FormattingExcelCells(excelCellrange, "#000099", System.Drawing.Color.White, true); excelSheet.Cells[1, 1].Font.Size = 20; if (paymentreport == false) { if (type == "program") { Microsoft.Office.Interop.Excel.Range chartRange; Microsoft.Office.Interop.Excel.ChartObjects xlCharts = (Microsoft.Office.Interop.Excel.ChartObjects)excelSheet.ChartObjects(Type.Missing); Microsoft.Office.Interop.Excel.ChartObject myChart = (Microsoft.Office.Interop.Excel.ChartObject)xlCharts.Add(10, 80, 300, 250); Microsoft.Office.Interop.Excel.Chart chartPage = myChart.Chart; chartRange = excelSheet.Range[excelSheet.Cells[7, 1], excelSheet.Cells[rowcount, dataTable.Columns.Count]]; chartPage.SetSourceData(chartRange); chartPage.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlColumnClustered; } else if (type == "diploma") { Microsoft.Office.Interop.Excel.Range chartRange; Microsoft.Office.Interop.Excel.ChartObjects xlCharts = (Microsoft.Office.Interop.Excel.ChartObjects)excelSheet.ChartObjects(Type.Missing); Microsoft.Office.Interop.Excel.ChartObject myChart = (Microsoft.Office.Interop.Excel.ChartObject)xlCharts.Add(10, 80, 300, 250); Microsoft.Office.Interop.Excel.Chart chartPage = myChart.Chart; chartRange = excelSheet.Range[excelSheet.Cells[7, 1], excelSheet.Cells[rowcount, 2]]; chartPage.SetSourceData(chartRange); chartPage.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlColumnClustered; } } else { } return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } finally { excelSheet = null; excelCellrange = null; excelworkBook = null; } }
public void set_items_to_items_list(string type, List <string> k) { if (type == "other") { k.Clear(); con.Open(); SqlCommand cmd = new SqlCommand("SELECT s.program_no,s.scheduled_date,c.Program_title,s.course_type,s.course_no FROM Session_details s INNER JOIN Short_program_details c ON s.program_no=c.Code WHERE s.course_type='Workshop' OR s.course_type='One-day' OR s.course_type='Two-day'OR s.course_type='Three-day' ", con); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { if (dr.GetValue(2).ToString() == "None") { k.Add(dr.GetValue(0).ToString() + " - " + dr.GetDateTime(1).ToString("dd/MM/yyy") + " - " + General_methods.get_course_name_from_course_no(dr.GetValue(4).ToString()) + " - " + dr.GetValue(3).ToString()); } else { k.Add(dr.GetValue(0).ToString() + " - " + dr.GetDateTime(1).ToString("dd/MM/yyy") + " - " + dr.GetValue(2).ToString() + " - " + dr.GetValue(3).ToString()); } } con.Close(); } else { k.Clear(); txt_enter_name.Items.Clear(); txt_enter_name.Text = ""; con.Open(); SqlCommand cmd = new SqlCommand("SELECT stud_no,f_name,m_name,l_name,NIC,ref,course_no FROM Stud_details", con); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { if (General_methods.get_course_type_from_course_no(dr.GetValue(6).ToString()) == type) { if (dr.IsDBNull(5)) { k.Add(dr.GetValue(0).ToString() + " - " + dr.GetValue(1).ToString() + " " + dr.GetValue(2).ToString() + " " + dr.GetValue(3).ToString() + " - " + dr.GetValue(4).ToString()); } else { SqlConnection con2 = new SqlConnection(Credentials.connection); SqlCommand cmd2 = new SqlCommand("SELECT f_name,m_name,l_name,NIC,course_no FROM Stud_details WHERE stud_no='" + dr.GetValue(5).ToString() + "'", con2); con2.Open(); SqlDataReader dr2 = cmd2.ExecuteReader(); dr2.Read(); k.Add(dr.GetValue(0).ToString() + " - " + dr2.GetValue(0).ToString() + " " + dr2.GetValue(1).ToString() + " " + dr2.GetValue(2).ToString() + " - " + dr2.GetValue(3).ToString()); dr2.Close(); con2.Close(); } } } con.Close(); } }