please i need help here. let someone help me to debug this i attach the project bon compressed folder:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
//static SqlConnection conn;
//System.Data.SqlClient.SqlConnection conn;
//string str = ConfigurationManager.ConnectionStrings["TimeDataConnectionString1"].ConnectionString;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("work");
}
private void timer1_Tick(object sender, EventArgs e)
{
lblTime.Text = "Present Time :" + DateTime.Now.ToShortTimeString();
lblTime.Visible = !lblTime.Visible;
label4.Text = "Today Is :";
label4.Visible = !label4.Visible;
int hour = DateTime.Now.Hour;
string day = Convert.ToString(DateTime.Today.DayOfWeek);
string tim = Convert.ToString(DateTime.Now.Minute);
string msgdta = "mon8"; string msgdta2 = "mon10"; string msgdta3 = "mon12"; string msgdta4 = "mon2";
string msgdta5 = "tues8"; string msgdta6 = "tues10"; string msgdta7 = "tues12"; string msgdta8 = "tues2";
string msgdta9 = "wed8"; string msgdta10 = "wed10"; string msgdta11 = "wed12"; string msgdta12 = "wed2";
string msgdta13 = "thus8"; string msgdta14 = "thus10"; string msgdta15 = "thus12"; string msgdta16 = "thus2";
string msgdta17 = "frd8"; string msgdta18 = "frd10"; string msgdta19 = "frd12"; string msgdta20 = "frd2";
if (day == Monday && hour == 8 && tim == 12)
{
MondLectures(msgdta);
}
else if (day == Monday && hour == 10 && tim == 12)
{
MondLectures(msgdta2);
}
else if (day == Monday && hour == 12 && tim == 12)
{
MondLectures(msgdta3);
}
else if (day == Monday && hour == 2 && tim == 12)
{
MondLectures(msgdta4);
}
else if (day == Tuesday && hour == 8 && tim == 12)
{
TuesdayLectures(msgdta5);
}
else if (day == Tuesday && hour == 10 && tim == 12)
{
TuesdayLectures(msgdta6);
}
else if (day == Tuesday && hour == 12 && tim == 12)
{
TuesdayLectures(msgdta7);
}
else if (day == Tuesday && hour == 2 && tim == 12)
{
TuesdayLectures(msgdta8);
}
else if (day == Wednesday && hour == 8 && tim == 12)
{
WednesdayLectures(msgdta9);
}
else if (day == Wednesday && hour == 10 && tim == 12)
{
WednesdayLectures(msgdta10);
}
else if (day == Wednesday && hour == 12 && tim == 12)
{
WednesdayLectures(msgdta11);
}
else if (day == Wednesday && hour == 2 && tim == 12)
{
WednesdayLectures(msgdta12);
}
else if (day == Thursday && hour == 8 && tim == 12)
{
ThursdayLectures(msgdta13);
}
else if (day == Thursday && hour == 10 && tim == 12)
{
ThursdayLectures(msgdta14);
}
else if (day == Thursday && hour == 12 && tim == 12)
{
ThursdayLectures(msgdta15);
}
else if (day == Thursday && hour == 2 && tim == 12)
{
ThursdayLectures(msgdta16);
}
else if (day == Friday && hour == 8 && tim == 12)
{
FridayLectures(msgdta17);
}
else if (day == Friday && hour == 10 && tim == 12)
{
FridayLectures(msgdta18);
}
else if (day == Friday && hour == 12 && tim == 12)
{
FridayLectures(msgdta19);
}
else if (day == Friday && hour == 2 && tim == 12)
{
FridayLectures(msgdta20);
}
else
{
groupBox1.Controls.Clear();
Label lblMsg = new Label();
lblMsg.AutoSize = true;
lblMsg.BackColor = System.Drawing.Color.Brown;
lblMsg.Font = new System.Drawing.Font("Microsoft Sans Serif", 20F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
lblMsg.ForeColor = System.Drawing.SystemColors.Control;
lblMsg.Location = new System.Drawing.Point(144, 109);
lblMsg.Name = "label1";
lblMsg.Size = new System.Drawing.Size(234, 31);
lblMsg.TabIndex = 16;
lblMsg.Text = "Classes are over";
groupBox1.Controls.Add(lblMsg);
}
}
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
label5.Text = "Ongoing Courses at present time:";
label5.Visible = !label5.Visible;
}
private void Form1_Load(object sender, EventArgs e)
{
}
void MondLectures(string daytime)
{
using (SqlConnection conn = new SqlConnection())
{
//System.Data.SqlClient.SqlConnection conn;
//conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\TimeData.mdf;Integrated Security=True;User Instance=True";
const string query = "select hour,400levcos,400levlec, 300levcos,300levlec, 200levcos,200levlec, 100levcos,100levlec from timetable where Daytime = @Daytime";
DataTable timeresult = new DataTable();
conn.Open();
using (SqlCommand cmd = new SqlCommand(query, conn))
{
cmd.Parameters.Add("@daytime", SqlDbType.VarChar).Value = daytime;
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
da.Fill(timeresult);
}
}
string strcos4 = Convert.ToString(timeresult.Rows[0]["400levcos"]);
string strlec4 = Convert.ToString(timeresult.Rows[0]["400levlec"]);
string strcos3 = Convert.ToString(timeresult.Rows[0]["300levcos"]);
string strlec3 = Convert.ToString(timeresult.Rows[0]["300levlec"]);
string strcos2 = Convert.ToString(timeresult.Rows[0]["200levcos"]);
string strlec2 = Convert.ToString(timeresult.Rows[0]["200levlec"]);
string strcos1 = Convert.ToString(timeresult.Rows[0]["100levcos"]);
string strlec1 = Convert.ToString(timeresult.Rows[0]["100levlec"]);
lblLet1.Text = strcos4.ToString();
lblcor1.Text = strlec4.ToString();
lblcor2.Text = strcos3.ToString();
lblLet2.Text = strlec3.ToString();
lblcor3.Text = strcos2.ToString();
lblLet3.Text = strlec2.ToString();
lblcor4.Text = strcos1.ToString();
lblLet4.Text = strlec1.ToString();
}
}
void TuesdayLectures(string daytime)
{
using (SqlConnection conn = new SqlConnection())
{
//System.Data.SqlClient.SqlConnection conn;
//conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\TimeData.mdf;Integrated Security=True;User Instance=True";
const string query = "select hour,400levcos,400levlec, 300levcos,300levlec, 200levcos,200levlec, 100levcos,100levlec from timetable where Daytime = @Daytime";
DataTable timeresult = new DataTable();
conn.Open();
using (SqlCommand cmd = new SqlCommand(query, conn))
{
cmd.Parameters.Add("@daytime", SqlDbType.VarChar).Value = daytime;
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
da.Fill(timeresult);
}
}
string strcos4 = Convert.ToString(timeresult.Rows[0]["400levcos"]);
string strlec4 = Convert.ToString(timeresult.Rows[0]["400levlec"]);
string strcos3 = Convert.ToString(timeresult.Rows[0]["300levcos"]);
string strlec3 = Convert.ToString(timeresult.Rows[0]["300levlec"]);
string strcos2 = Convert.ToString(timeresult.Rows[0]["200levcos"]);
string strlec2 = Convert.ToString(timeresult.Rows[0]["200levlec"]);
string strcos1 = Convert.ToString(timeresult.Rows[0]["100levcos"]);
string strlec1 = Convert.ToString(timeresult.Rows[0]["100levlec"]);
lblLet1.Text = strcos4.ToString();
lblcor1.Text = strlec4.ToString();
lblcor2.Text = strcos3.ToString();
lblLet2.Text = strlec3.ToString();
lblcor3.Text = strcos2.ToString();
lblLet3.Text = strlec2.ToString();
lblcor4.Text = strcos1.ToString();
lblLet4.Text = strlec1.ToString();
}
}
void WednesdayLectures(string daytime)
{
using (SqlConnection conn = new SqlConnection())
{
//System.Data.SqlClient.SqlConnection conn;
//conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\TimeData.mdf;Integrated Security=True;User Instance=True";
const string query = "select hour,400levcos,400levlec, 300levcos,300levlec, 200levcos,200levlec, 100levcos,100levlec from timetable where Daytime = @Daytime";
DataTable timeresult = new DataTable();
conn.Open();
using (SqlCommand cmd = new SqlCommand(query, conn))
{
cmd.Parameters.Add("@daytime", SqlDbType.VarChar).Value = daytime;
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
da.Fill(timeresult);
}
}
string strcos4 = Convert.ToString(timeresult.Rows[0]["400levcos"]);
string strlec4 = Convert.ToString(timeresult.Rows[0]["400levlec"]);
string strcos3 = Convert.ToString(timeresult.Rows[0]["300levcos"]);
string strlec3 = Convert.ToString(timeresult.Rows[0]["300levlec"]);
string strcos2 = Convert.ToString(timeresult.Rows[0]["200levcos"]);
string strlec2 = Convert.ToString(timeresult.Rows[0]["200levlec"]);
string strcos1 = Convert.ToString(timeresult.Rows[0]["100levcos"]);
string strlec1 = Convert.ToString(timeresult.Rows[0]["100levlec"]);
lblLet1.Text = strcos4.ToString();
lblcor1.Text = strlec4.ToString();
lblcor2.Text = strcos3.ToString();
lblLet2.Text = strlec3.ToString();
lblcor3.Text = strcos2.ToString();
lblLet3.Text = strlec2.ToString();
lblcor4.Text = strcos1.ToString();
lblLet4.Text = strlec1.ToString();
}
}
void ThursdayLectures(string daytime)
{
using (SqlConnection conn = new SqlConnection())
{
//System.Data.SqlClient.SqlConnection conn;
//conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\TimeData.mdf;Integrated Security=True;User Instance=True";
const string query = "select hour,400levcos,400levlec, 300levcos,300levlec, 200levcos,200levlec, 100levcos,100levlec from timetable where Daytime = @daytime";
DataTable timeresult = new DataTable();
conn.Open();
using (SqlCommand cmd = new SqlCommand(query, conn))
{
cmd.Parameters.Add("@daytime", SqlDbType.VarChar).Value = daytime;
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
da.Fill(timeresult);
}
}
string strcos4 = Convert.ToString(timeresult.Rows[0]["400levcos"]);
string strlec4 = Convert.ToString(timeresult.Rows[0]["400levlec"]);
string strcos3 = Convert.ToString(timeresult.Rows[0]["300levcos"]);
string strlec3 = Convert.ToString(timeresult.Rows[0]["300levlec"]);
string strcos2 = Convert.ToString(timeresult.Rows[0]["200levcos"]);
string strlec2 = Convert.ToString(timeresult.Rows[0]["200levlec"]);
string strcos1 = Convert.ToString(timeresult.Rows[0]["100levcos"]);
string strlec1 = Convert.ToString(timeresult.Rows[0]["100levlec"]);
lblLet1.Text = strcos4.ToString();
lblcor1.Text = strlec4.ToString();
lblcor2.Text = strcos3.ToString();
lblLet2.Text = strlec3.ToString();
lblcor3.Text = strcos2.ToString();
lblLet3.Text = strlec2.ToString();
lblcor4.Text = strcos1.ToString();
lblLet4.Text = strlec1.ToString();
}
}
void FridayLectures(string daytime)
{
using (SqlConnection conn = new SqlConnection())
{
//System.Data.SqlClient.SqlConnection conn;
//conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\TimeData.mdf;Integrated Security=True;User Instance=True";
const string query = "select hour,400levcos,400levlec, 300levcos,300levlec, 200levcos,200levlec, 100levcos,100levlec from timetable where Daytime = @Daytime";
DataTable timeresult = new DataTable();
conn.Open();
using (SqlCommand cmd = new SqlCommand(query, conn))
{
cmd.Parameters.Add("@daytime", SqlDbType.VarChar).Value = daytime;
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
da.Fill(timeresult);
}
}
string strcos4 = Convert.ToString(timeresult.Rows[0]["400levcos"]);
string strlec4 = Convert.ToString(timeresult.Rows[0]["400levlec"]);
string strcos3 = Convert.ToString(timeresult.Rows[0]["300levcos"]);
string strlec3 = Convert.ToString(timeresult.Rows[0]["300levlec"]);
string strcos2 = Convert.ToString(timeresult.Rows[0]["200levcos"]);
string strlec2 = Convert.ToString(timeresult.Rows[0]["200levlec"]);
string strcos1 = Convert.ToString(timeresult.Rows[0]["100levcos"]);
string strlec1 = Convert.ToString(timeresult.Rows[0]["100levlec"]);
lblLet1.Text = strcos4.ToString();
lblcor1.Text = strlec4.ToString();
lblcor2.Text = strcos3.ToString();
lblLet2.Text = strlec3.ToString();
lblcor3.Text = strcos2.ToString();
lblLet3.Text = strlec2.ToString();
lblcor4.Text = strcos1.ToString();
lblLet4.Text = strlec1.ToString();
}
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
private void dateTimePicker1_ValueChanged_1(object sender, EventArgs e)
{
}
}
}