private void FillStatusInfo() { conn = DBconnection.GetConnection(); if (conn.State.ToString() == "Closed") { conn.Open(); } var ExOrCurrentDictionary = new Dictionary <int, string>(); ExOrCurrentDictionary.Add(1, "Current"); ExOrCurrentDictionary.Add(0, "Ex"); StdSelectExOrCurrentCmbox.DisplayMember = "Value"; StdSelectExOrCurrentCmbox.ValueMember = "Key"; StdSelectExOrCurrentCmbox.DataSource = new BindingSource(ExOrCurrentDictionary, null); }
private void FillShiftList() { conn = DBconnection.GetConnection(); if (conn.State.ToString() == "Closed") { conn.Open(); } var ShiftDictionary = new Dictionary <string, string>(); ShiftDictionary.Add("Morning", "Morning"); ShiftDictionary.Add("Day", "Day"); ShiftSelectCombo.DisplayMember = "Value"; ShiftSelectCombo.ValueMember = "Key"; ShiftSelectCombo.DataSource = new BindingSource(ShiftDictionary, null); }
private void FillTeacherSelectFromPersonCombox() { try { var dictionary = new Dictionary <int, string>(); conn = DBconnection.GetConnection(); if (conn.State.ToString() == "Closed") { conn.Open(); } SqlCommand findPersonCmd = new SqlCommand("SELECT * FROM [sms].[dbo].[person] pr WHERE pr.id not in (SELECT id FROM [sms].[dbo].[teacher]) AND pr.id not in (SELECT id FROM [sms].[dbo].[student])", conn); SqlDataReader dr = findPersonCmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { int indexFname = dr.GetOrdinal("fname"); int indexLname = dr.GetOrdinal("lname"); int indexId = dr.GetOrdinal("id"); string firstname = dr.GetString(indexFname); string lastname = dr.GetString(indexLname); int personID = dr.GetInt32(indexId); dictionary.Add(personID, firstname + " " + lastname); } } TeachSelectCmbox.DisplayMember = "Value"; TeachSelectCmbox.ValueMember = "Key"; TeachSelectCmbox.DataSource = new BindingSource(dictionary, null); //Measure teacher ID SqlCommand noOfTeach = new SqlCommand("SELECT COUNT(*) FROM [sms].[dbo].[teacher]", conn); noOfTeach.CommandType = CommandType.Text; var Count = (Int32)noOfTeach.ExecuteScalar(); var teachID = "teach" + (Count + 1); TeachlblID.Text = teachID; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void FillTeacherList() { conn = DBconnection.GetConnection(); if (conn.State.ToString() == "Closed") { conn.Open(); } var teacherListDictionary = new Dictionary <int, string>(); SqlCommand teachListCmd = new SqlCommand("SELECT * FROM [sms].[dbo].[teacher]", conn); SqlDataReader dr = teachListCmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { int IndexID = dr.GetOrdinal("id"); int PersonID = dr.GetInt32(IndexID); SqlCommand FindTeachCmd = new SqlCommand("SELECT * FROM [sms].[dbo].[person] WHERE id=" + PersonID, conn); SqlDataReader Tdr = FindTeachCmd.ExecuteReader(); if (Tdr.HasRows) { if (Tdr.Read()) { int IndexFname = Tdr.GetOrdinal("fname"); int IndexLname = Tdr.GetOrdinal("lname"); string Fname = Tdr.GetString(IndexFname); string Lname = Tdr.GetString(IndexLname); teacherListDictionary = teacherListDictionary.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value); teacherListDictionary.Add(PersonID, Fname + " " + Lname); } } } } teachList.DisplayMember = "Value"; teachList.ValueMember = "Key"; teachList.DataSource = new BindingSource(teacherListDictionary, null); }
private void FillEvent() { conn = DBconnection.GetConnection(); if (conn.State.ToString() == "Closed") { conn.Open(); } var Today = DateTime.Now.ToString("d-M-yyyy"); string input = Today; string pattern = "-"; string[] substrings = Regex.Split(input, pattern); var date = Convert.ToInt32(substrings[0]); var month = Convert.ToInt32(substrings[1]); var year = Convert.ToInt32(substrings[2]); calender findBday = new calender(); var BanglaValue = findBday.BanglaDate(month, date); var ArabicValue = findBday.ArabicDate(month, date); //Arabic date, month, year calculation var ArabicMonth = findArabicMonth(ArabicValue); var ArabicDigit = findDate(ArabicValue); int ArabYr = 0; if (ArabicMonth.ToString() == "muh" || ArabicMonth.ToString() == "saf" && month >= 11 || ArabicMonth.ToString() == "raa" && month >= 12) { ArabYr = 1436; } else { ArabYr = 1435; } //Bangla date, month, year calculation var character = findMonth(BanglaValue); var digit = findDate(BanglaValue); var IntDigit = Convert.ToInt32(digit.ToString()); int yr = 0; if (character.ToString() == "মাঘ" || character.ToString() == "ফাল্গুন" || character.ToString() == "চৈত্র" || character.ToString() == "পৌষ" && IntDigit >= 18) { yr = 1420; } else { yr = 1421; } //Convert date into bangla string numOfDate = digit.ToString(); string[] x = new string[numOfDate.Length]; string[] y = new string[numOfDate.Length]; for (int i = 0; i < numOfDate.Length; i++) { x[i] = numOfDate.Substring(i, 1); switch (x[i]) { case "0": y[i] = "০"; break; case "1": y[i] = "১"; break; case "2": y[i] = "২"; break; case "3": y[i] = "৩"; break; case "4": y[i] = "৪"; break; case "5": y[i] = "৫"; break; case "6": y[i] = "৬"; break; case "7": y[i] = "৭"; break; case "8": y[i] = "৮"; break; case "9": y[i] = "৯"; break; default: break; } } String DateOutput = String.Join("", y); //Convert year into bangla string numOfYear = yr.ToString(); string[] m = new string[numOfYear.Length]; string[] n = new string[numOfYear.Length]; for (int i = 0; i < numOfYear.Length; i++) { m[i] = numOfYear.Substring(i, 1); switch (m[i]) { case "0": n[i] = "০"; break; case "1": n[i] = "১"; break; case "2": n[i] = "২"; break; case "3": n[i] = "৩"; break; case "4": n[i] = "৪"; break; case "5": n[i] = "৫"; break; case "6": n[i] = "৬"; break; case "7": n[i] = "৭"; break; case "8": n[i] = "৮"; break; case "9": n[i] = "৯"; break; default: break; } } String YearOutput = String.Join("", n); string MonthName = ""; switch (month) { case 1: MonthName = "January"; break; case 2: MonthName = "February"; break; case 3: MonthName = "March"; break; case 4: MonthName = "April"; break; case 5: MonthName = "May"; break; case 6: MonthName = "June"; break; case 7: MonthName = "July"; break; case 8: MonthName = "August"; break; case 9: MonthName = "September"; break; case 10: MonthName = "October"; break; case 11: MonthName = "November"; break; case 12: MonthName = "December"; break; } BanglaDate.Text = character.ToString() + " " + DateOutput + ", " + YearOutput; EnglishDate.Text = date + " " + MonthName + ", " + year; ArabicDate.Text = ArabicDigit.ToString() + " " + ArabicMonth.ToString() + ", " + ArabYr; //Fill event section conn = DBconnection.GetConnection(); if (conn.State.ToString() == "Closed") { conn.Open(); } SqlCommand ThisWeekCmd = new SqlCommand("SELECT * FROM [sms].[dbo].[event] WHERE day=" + date + " and month=" + month, conn); SqlDataReader twdr = ThisWeekCmd.ExecuteReader(); if (twdr.HasRows) { while (twdr.Read()) { int IndexHoliday = twdr.GetOrdinal("holiday"); string EventHoliday = twdr.GetString(IndexHoliday); HolidayLblTxt.Text = EventHoliday; //AppointLblTxt.Text = ; } } else { HolidayLblTxt.Text = "No holiday today!"; AppointLblTxt.Text = "No appointment today!"; } }
private void FillTeacherList() { conn = DBconnection.GetConnection(); if (conn.State.ToString() == "Closed") { conn.Open(); } var teacherListDictionary = new Dictionary <int, string>(); SqlCommand teachListCmd = new SqlCommand("SELECT * FROM [sms].[dbo].[teacher]", conn); SqlDataReader dr = teachListCmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { int IndexID = dr.GetOrdinal("id"); int PersonID = dr.GetInt32(IndexID); SqlCommand FindTeachCmd = new SqlCommand("SELECT * FROM [sms].[dbo].[person] WHERE id=" + PersonID, conn); SqlDataReader Tdr = FindTeachCmd.ExecuteReader(); if (Tdr.HasRows) { if (Tdr.Read()) { int IndexFname = Tdr.GetOrdinal("fname"); int IndexLname = Tdr.GetOrdinal("lname"); string Fname = Tdr.GetString(IndexFname); string Lname = Tdr.GetString(IndexLname); teacherListDictionary = teacherListDictionary.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value); teacherListDictionary.Add(PersonID, Fname + " " + Lname); } } } } TeachList.DisplayMember = "Value"; TeachList.ValueMember = "Key"; TeachList.DataSource = new BindingSource(teacherListDictionary, null); var DistrictDictionary = new Dictionary <string, string>(); //B DistrictDictionary.Add("Bagerhat", "Bagerhat"); DistrictDictionary.Add("Bandarban", "Bandarban"); DistrictDictionary.Add("Barguna", "Barguna"); DistrictDictionary.Add("Barisal", "Barisal"); DistrictDictionary.Add("Bhola", "Bhola"); DistrictDictionary.Add("Bogra", "Bogra"); DistrictDictionary.Add("Brahmanbaria", "Brahmanbaria"); //C DistrictDictionary.Add("Chandpur", "Chandpur"); DistrictDictionary.Add("Chittagong", "Chittagong"); DistrictDictionary.Add("Chuadanga", "Chuadanga"); DistrictDictionary.Add("Comilla", "Comilla"); DistrictDictionary.Add("Cox's Bazar", "Cox's Bazar"); //D DistrictDictionary.Add("Dhaka", "Dhaka"); DistrictDictionary.Add("Dinajpur", "Dinajpur"); //F DistrictDictionary.Add("Faridpur", "Faridpur"); DistrictDictionary.Add("Feni", "Feni"); //G DistrictDictionary.Add("Gaibandha", "Gaibandha"); DistrictDictionary.Add("Gazipur", "Gazipur"); DistrictDictionary.Add("Gopalganj", "Gopalganj"); //H DistrictDictionary.Add("Habiganj", "Habiganj"); //J DistrictDictionary.Add("Jamalpur", "Jamalpur"); DistrictDictionary.Add("Jaypurhat", "Jaypurhat"); DistrictDictionary.Add("Jessore", "Jessore"); DistrictDictionary.Add("Jhalokati", "Jhalokati"); DistrictDictionary.Add("Jhenaidah", "Jhenaidah"); //K DistrictDictionary.Add("Khagrachhari", "Khagrachhari"); DistrictDictionary.Add("Khulna", "Khulna"); DistrictDictionary.Add("Kishoreganj", "Kishoreganj"); DistrictDictionary.Add("Kurigram", "Kurigram"); DistrictDictionary.Add("Kushtia", "Kushtia"); //L DistrictDictionary.Add("Lakshmipur", "Lakshmipur"); DistrictDictionary.Add("Lalmonirhat", "Lalmonirhat"); //M DistrictDictionary.Add("Madaripur", "Madaripur"); DistrictDictionary.Add("Magura", "Magura"); DistrictDictionary.Add("Manikganj", "Manikganj"); DistrictDictionary.Add("Meherpur", "Meherpur"); DistrictDictionary.Add("Moulvibazar", "Moulvibazar"); DistrictDictionary.Add("Munshiganj", "Munshiganj"); DistrictDictionary.Add("Mymensingh", "Mymensingh"); //N DistrictDictionary.Add("Naogaon", "Naogaon"); DistrictDictionary.Add("Narayanganj", "Narayanganj"); DistrictDictionary.Add("Narail", "Narail"); DistrictDictionary.Add("Narsingdi", "Narsingdi"); DistrictDictionary.Add("Natore", "Natore"); DistrictDictionary.Add("Nawabganj", "Nawabganj"); DistrictDictionary.Add("Netrakona", "Netrakona"); DistrictDictionary.Add("Nilphamari", "Nilphamari"); DistrictDictionary.Add("Noakhali", "Noakhali"); //P DistrictDictionary.Add("Pabna", "Pabna"); DistrictDictionary.Add("Panchagarh", "Panchagarh"); DistrictDictionary.Add("Patuakhali", "Patuakhali"); DistrictDictionary.Add("Pirojpur", "Pirojpur"); //R DistrictDictionary.Add("Rajbari", "Rajbari"); DistrictDictionary.Add("Rajshahi", "Rajshahi"); DistrictDictionary.Add("Rangamati", "Rangamati"); DistrictDictionary.Add("Rangpur", "Rangpur"); //S DistrictDictionary.Add("Satkhira", "Satkhira"); DistrictDictionary.Add("Shariatpur", "Shariatpur"); DistrictDictionary.Add("Sherpur", "Sherpur"); DistrictDictionary.Add("Sirajganj", "Sirajganj"); DistrictDictionary.Add("Sunamganj", "Sunamganj"); DistrictDictionary.Add("Sylhet", "Sylhet"); //T DistrictDictionary.Add("Tangail", "Tangail"); DistrictDictionary.Add("Thakurgaon", "Thakurgaon"); DistrictTxt.DisplayMember = "Value"; DistrictTxt.ValueMember = "Key"; DistrictTxt.DataSource = new BindingSource(DistrictDictionary, null); }
public DBaccess() { conn = DBconnection.GetConnection(); }
private void FillYearSummary() { conn = DBconnection.GetConnection(); if (conn.State.ToString() == "Closed") { conn.Open(); } try { SqlCommand eventListCmd = new SqlCommand("SELECT * FROM [sms].[dbo].[event]", conn); SqlDataReader dr = eventListCmd.ExecuteReader(); if (dr.HasRows) { int x = 0; SqlCommand noOfEvnt = new SqlCommand("SELECT COUNT(*) FROM [sms].[dbo].[event]", conn); noOfEvnt.CommandType = CommandType.Text; var Count = (Int32)noOfEvnt.ExecuteScalar(); while (dr.Read()) { int IndexDay = dr.GetOrdinal("day"); int IndexMonth = dr.GetOrdinal("month"); int IndexHoliday = dr.GetOrdinal("holiday"); int IndexAppoint = dr.GetOrdinal("appointment"); int IndexAppointTime = dr.GetOrdinal("appointment_time"); int Day = dr.GetInt32(IndexDay); int Month = dr.GetInt32(IndexMonth); string Holiday = dr.GetString(IndexHoliday); string Appoint = dr.GetString(IndexAppoint); string AppointTime = dr.GetString(IndexAppointTime); string MonthName = ""; switch (Month) { case 1: MonthName = "January"; break; case 2: MonthName = "February"; break; case 3: MonthName = "March"; break; case 4: MonthName = "April"; break; case 5: MonthName = "May"; break; case 6: MonthName = "June"; break; case 7: MonthName = "July"; break; case 8: MonthName = "August"; break; case 9: MonthName = "September"; break; case 10: MonthName = "October"; break; case 11: MonthName = "November"; break; case 12: MonthName = "December"; break; } Label U_lbl = new Label(); U_lbl.Location = new Point(15, 20 + (x * 60)); U_lbl.Name = "lbl_U" + x; U_lbl.Text = "Date: " + MonthName + " " + Day; U_lbl.AutoSize = true; tabHolidays.Controls.Add(U_lbl); Label L_lbl = new Label(); L_lbl.Location = new Point(15, 20 + (20 + x * 60)); L_lbl.Name = "lbl_L" + x; L_lbl.Text = "Holiday: " + Holiday; L_lbl.AutoSize = true; tabHolidays.Controls.Add(L_lbl); x = x + 1; } } } catch (NullReferenceException) { } }
private void FindToday() { var Today = DateTime.Now.ToString("d-M-yyyy"); string input = Today; string pattern = "-"; string[] substrings = Regex.Split(input, pattern); var date = Convert.ToInt32(substrings[0]); var month = Convert.ToInt32(substrings[1]); var year = Convert.ToInt32(substrings[2]); calender findBday = new calender(); var BanglaValue = findBday.BanglaDate(month, date); var ArabicValue = findBday.ArabicDate(month, date); //Arabic date, month, year calculation var ArabicMonth = findArabicMonth(ArabicValue); var ArabicDigit = findDate(ArabicValue); int ArabYr = 0; if (ArabicMonth.ToString() == "muh" || ArabicMonth.ToString() == "saf" && month >= 11 || ArabicMonth.ToString() == "raa" && month >= 12) { ArabYr = 1436; } else { ArabYr = 1435; } //Bangla date, month, year calculation var character = findMonth(BanglaValue); var digit = findDate(BanglaValue); var IntDigit = Convert.ToInt32(digit.ToString()); int yr = 0; if (character.ToString() == "মাঘ" || character.ToString() == "ফাল্গুন" || character.ToString() == "চৈত্র" || character.ToString() == "পৌষ" && IntDigit >= 18) { yr = 1420; } else { yr = 1421; } //Convert date into bangla string numOfDate = digit.ToString(); string[] x = new string[numOfDate.Length]; string[] y = new string[numOfDate.Length]; for (int i = 0; i < numOfDate.Length; i++) { x[i] = numOfDate.Substring(i, 1); switch (x[i]) { case "0": y[i] = "০"; break; case "1": y[i] = "১"; break; case "2": y[i] = "২"; break; case "3": y[i] = "৩"; break; case "4": y[i] = "৪"; break; case "5": y[i] = "৫"; break; case "6": y[i] = "৬"; break; case "7": y[i] = "৭"; break; case "8": y[i] = "৮"; break; case "9": y[i] = "৯"; break; default: break; } } String DateOutput = String.Join("", y); //Convert year into bangla string numOfYear = yr.ToString(); string[] m = new string[numOfYear.Length]; string[] n = new string[numOfYear.Length]; for (int i = 0; i < numOfYear.Length; i++) { m[i] = numOfYear.Substring(i, 1); switch (m[i]) { case "0": n[i] = "০"; break; case "1": n[i] = "১"; break; case "2": n[i] = "২"; break; case "3": n[i] = "৩"; break; case "4": n[i] = "৪"; break; case "5": n[i] = "৫"; break; case "6": n[i] = "৬"; break; case "7": n[i] = "৭"; break; case "8": n[i] = "৮"; break; case "9": n[i] = "৯"; break; default: break; } } String YearOutput = String.Join("", n); BanglaDate.Text = character.ToString() + " " + DateOutput + ", " + YearOutput; ArabicDate.Text = ArabicDigit.ToString() + " " + ArabicMonth.ToString() + ", " + ArabYr; //Fill this week section conn = DBconnection.GetConnection(); if (conn.State.ToString() == "Closed") { conn.Open(); } SqlCommand ThisWeekCmd = new SqlCommand("SELECT Top 7 * FROM [sms].[dbo].[event] WHERE day>=" + date + " and month>=" + month, conn); SqlDataReader twdr = ThisWeekCmd.ExecuteReader(); if (twdr.HasRows) { int z = 0; while (twdr.Read()) { int IndexDate = twdr.GetOrdinal("day"); int IndexMonth = twdr.GetOrdinal("month"); int IndexHoliday = twdr.GetOrdinal("holiday"); int TopDate = twdr.GetInt32(IndexDate); int TopMonth = twdr.GetInt32(IndexMonth); string TopHoliday = twdr.GetString(IndexHoliday); string MonthName = ""; switch (TopMonth) { case 1: MonthName = "January"; break; case 2: MonthName = "February"; break; case 3: MonthName = "March"; break; case 4: MonthName = "April"; break; case 5: MonthName = "May"; break; case 6: MonthName = "June"; break; case 7: MonthName = "July"; break; case 8: MonthName = "August"; break; case 9: MonthName = "September"; break; case 10: MonthName = "October"; break; case 11: MonthName = "November"; break; case 12: MonthName = "December"; break; } Label TweekU_lbl = new Label(); TweekU_lbl.Location = new Point(14, 12 + (z * 22)); TweekU_lbl.Name = "TweekU_lbl_" + z; TweekU_lbl.Text = MonthName + " " + TopDate; TweekU_lbl.AutoSize = true; thisWeekPanel.Controls.Add(TweekU_lbl); Label TweekL_lbl = new Label(); TweekL_lbl.Location = new Point(89, 12 + (z * 22)); TweekL_lbl.Name = "TweekL_lbl_" + z; TweekL_lbl.Text = " : " + TopHoliday; TweekL_lbl.AutoSize = true; thisWeekPanel.Controls.Add(TweekL_lbl); z = z + 1; } } }
private void FillSthiftList() { conn = DBconnection.GetConnection(); if (conn.State.ToString() == "Closed") { conn.Open(); } var ShiftDictionary = new Dictionary <string, string>(); ShiftDictionary.Add("Morning", "Morning"); ShiftDictionary.Add("Day", "Day"); SelectShiftCombo.DisplayMember = "Value"; SelectShiftCombo.ValueMember = "Key"; SelectShiftCombo.DataSource = new BindingSource(ShiftDictionary, null); selectShift.DisplayMember = "Value"; selectShift.ValueMember = "Key"; selectShift.DataSource = new BindingSource(ShiftDictionary, null); var DistrictDictionary = new Dictionary <string, string>(); //B DistrictDictionary.Add("Bagerhat", "Bagerhat"); DistrictDictionary.Add("Bandarban", "Bandarban"); DistrictDictionary.Add("Barguna", "Barguna"); DistrictDictionary.Add("Barisal", "Barisal"); DistrictDictionary.Add("Bhola", "Bhola"); DistrictDictionary.Add("Bogra", "Bogra"); DistrictDictionary.Add("Brahmanbaria", "Brahmanbaria"); //C DistrictDictionary.Add("Chandpur", "Chandpur"); DistrictDictionary.Add("Chittagong", "Chittagong"); DistrictDictionary.Add("Chuadanga", "Chuadanga"); DistrictDictionary.Add("Comilla", "Comilla"); DistrictDictionary.Add("Cox's Bazar", "Cox's Bazar"); //D DistrictDictionary.Add("Dhaka", "Dhaka"); DistrictDictionary.Add("Dinajpur", "Dinajpur"); //F DistrictDictionary.Add("Faridpur", "Faridpur"); DistrictDictionary.Add("Feni", "Feni"); //G DistrictDictionary.Add("Gaibandha", "Gaibandha"); DistrictDictionary.Add("Gazipur", "Gazipur"); DistrictDictionary.Add("Gopalganj", "Gopalganj"); //H DistrictDictionary.Add("Habiganj", "Habiganj"); //J DistrictDictionary.Add("Jamalpur", "Jamalpur"); DistrictDictionary.Add("Jaypurhat", "Jaypurhat"); DistrictDictionary.Add("Jessore", "Jessore"); DistrictDictionary.Add("Jhalokati", "Jhalokati"); DistrictDictionary.Add("Jhenaidah", "Jhenaidah"); //K DistrictDictionary.Add("Khagrachhari", "Khagrachhari"); DistrictDictionary.Add("Khulna", "Khulna"); DistrictDictionary.Add("Kishoreganj", "Kishoreganj"); DistrictDictionary.Add("Kurigram", "Kurigram"); DistrictDictionary.Add("Kushtia", "Kushtia"); //L DistrictDictionary.Add("Lakshmipur", "Lakshmipur"); DistrictDictionary.Add("Lalmonirhat", "Lalmonirhat"); //M DistrictDictionary.Add("Madaripur", "Madaripur"); DistrictDictionary.Add("Magura", "Magura"); DistrictDictionary.Add("Manikganj", "Manikganj"); DistrictDictionary.Add("Meherpur", "Meherpur"); DistrictDictionary.Add("Moulvibazar", "Moulvibazar"); DistrictDictionary.Add("Munshiganj", "Munshiganj"); DistrictDictionary.Add("Mymensingh", "Mymensingh"); //N DistrictDictionary.Add("Naogaon", "Naogaon"); DistrictDictionary.Add("Narayanganj", "Narayanganj"); DistrictDictionary.Add("Narail", "Narail"); DistrictDictionary.Add("Narsingdi", "Narsingdi"); DistrictDictionary.Add("Natore", "Natore"); DistrictDictionary.Add("Nawabganj", "Nawabganj"); DistrictDictionary.Add("Netrakona", "Netrakona"); DistrictDictionary.Add("Nilphamari", "Nilphamari"); DistrictDictionary.Add("Noakhali", "Noakhali"); //P DistrictDictionary.Add("Pabna", "Pabna"); DistrictDictionary.Add("Panchagarh", "Panchagarh"); DistrictDictionary.Add("Patuakhali", "Patuakhali"); DistrictDictionary.Add("Pirojpur", "Pirojpur"); //R DistrictDictionary.Add("Rajbari", "Rajbari"); DistrictDictionary.Add("Rajshahi", "Rajshahi"); DistrictDictionary.Add("Rangamati", "Rangamati"); DistrictDictionary.Add("Rangpur", "Rangpur"); //S DistrictDictionary.Add("Satkhira", "Satkhira"); DistrictDictionary.Add("Shariatpur", "Shariatpur"); DistrictDictionary.Add("Sherpur", "Sherpur"); DistrictDictionary.Add("Sirajganj", "Sirajganj"); DistrictDictionary.Add("Sunamganj", "Sunamganj"); DistrictDictionary.Add("Sylhet", "Sylhet"); //T DistrictDictionary.Add("Tangail", "Tangail"); DistrictDictionary.Add("Thakurgaon", "Thakurgaon"); districtTxt.DisplayMember = "Value"; districtTxt.ValueMember = "Key"; districtTxt.DataSource = new BindingSource(DistrictDictionary, null); //Select the year var YearDictionary = new Dictionary <int, int>(); DateTime dt = DateTime.Now; YearDictionary.Add(0, 0); for (int i = 1987; i <= dt.Year; i++) { YearDictionary.Add(i, i); } SelectLeaveYearCmbox.DisplayMember = "Value"; SelectLeaveYearCmbox.ValueMember = "Key"; SelectLeaveYearCmbox.DataSource = new BindingSource(YearDictionary, null); }
public void FillChartList() { conn = DBconnection.GetConnection(); if (conn.State.ToString() == "Closed") { conn.Open(); } try { SqlCommand classListCmd = new SqlCommand("SELECT * FROM [sms].[dbo].[class]", conn); SqlDataReader cldr = classListCmd.ExecuteReader(); { if (cldr.HasRows) { while (cldr.Read()) { for (int term = 1; term <= 3; term++) { int IndexClassID = cldr.GetOrdinal("class_id"); string classID = cldr.GetString(IndexClassID); SqlCommand ResultCmd = new SqlCommand("SELECT * FROM [sms].[dbo].[result] as re INNER JOIN [sms].[dbo].[class] as cls ON re.class_id = cls.class_id WHERE re.class_id='" + classID + "' AND re.exam_id=" + term, conn); SqlDataReader rdr = ResultCmd.ExecuteReader(); if (rdr.HasRows) { int TotalPercentage = 0; while (rdr.Read()) { CalculateProgress cp = new CalculateProgress(); var digit = findDigit(classID); string v = digit.ToString(); string c = "Nothing"; if (v == "01" || v == "02" || v == "03" || v == "04" || v == "05" || v == "06" || v == "07" || v == "08" || v == "09") { c = v.Replace("0", " "); } else if (v == "10") { c = v; } int intDigit = Convert.ToInt32(c); SqlCommand noOfSubject = new SqlCommand("SELECT count(subject_id) FROM [sms].[dbo].[subject] WHERE class_id=" + digit, conn); noOfSubject.CommandType = CommandType.Text; int countSubject = (Int32)noOfSubject.ExecuteScalar(); int[] receiveProgressValue = new int[countSubject]; int IndexTotalStudent = rdr.GetOrdinal("total_student"); int totalStd = rdr.GetInt32(IndexTotalStudent); for (int i = 1, j = 0; i <= countSubject; i++, j++) { SqlCommand noOfFirstStd = new SqlCommand("SELECT count(*) FROM [sms].[dbo].[result] WHERE class_id='" + classID + "' AND subject_id='c" + intDigit + "s" + i + "' AND exam_id=" + term + " AND gpa = 5", conn); noOfFirstStd.CommandType = CommandType.Text; int firstStd = (Int32)noOfFirstStd.ExecuteScalar(); SqlCommand noOfSecondStd = new SqlCommand("SELECT count(*) FROM [sms].[dbo].[result] WHERE class_id='" + classID + "' AND subject_id='c" + intDigit + "s" + i + "' AND exam_id=" + term + " AND gpa = 4", conn); noOfSecondStd.CommandType = CommandType.Text; int secondStd = (Int32)noOfSecondStd.ExecuteScalar(); SqlCommand noThirdStd = new SqlCommand("SELECT count(*) FROM [sms].[dbo].[result] WHERE class_id='" + classID + "' AND subject_id='c" + intDigit + "s" + i + "' AND exam_id=" + term + " AND gpa < 4 AND gpa >= 3", conn); noThirdStd.CommandType = CommandType.Text; int thirdStd = (Int32)noThirdStd.ExecuteScalar(); SqlCommand noOtherStd = new SqlCommand("SELECT count(*) FROM [sms].[dbo].[result] WHERE class_id='" + classID + "' AND subject_id='c" + intDigit + "s" + i + "' AND exam_id=" + term + " AND gpa <= 2", conn); noOtherStd.CommandType = CommandType.Text; int otherStd = (Int32)noOtherStd.ExecuteScalar(); var subjectValue = cp.SingleSubjectCalculation(totalStd, firstStd, secondStd, thirdStd, otherStd); receiveProgressValue[j] = subjectValue; } int Tvalue = 0; for (int k = 0; k < receiveProgressValue.Length; k++) { Tvalue = Tvalue + receiveProgressValue[k]; } Array.Clear(receiveProgressValue, 0, receiveProgressValue.Length); TotalPercentage = cp.AllSubjectCalculation(countSubject, Tvalue); //var Class = TeachSelectCmbox.SelectedValue; //var Term = term; //var Progress = TotalPercentage; //SqlCommand insertValueCmd = new SqlCommand("INSERT INTO [sms].[dbo].[progress](class, term, progress) " + // "VALUES (@class, @term, @progress)", conn); //insertValueCmd.Parameters.AddWithValue("@class", Class); //insertValueCmd.Parameters.AddWithValue("@term", Term); //insertValueCmd.Parameters.AddWithValue("@progress", Progress); //insertValueCmd.ExecuteNonQuery(); } } } } } } } catch (NullReferenceException) { } }