Example #1
0
        public bool Insert(WorkTimeHour c)
        {
            bool isSuccess = false;

            //Connection String
            SqlConnection Con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\TimeTableDatabase.mdf;Integrated Security=True");


            try
            {
                string     sql = "INSERT INTO WorkingDays (noworkd,day1,day2,day3,day4,day5,day6,day7,stime,dura,etime,hours)VALUES(@noworkd,@day1,@day2,@day3,@day4,@day5,@day6,@day7,@stime,@dura,@etime,@hours)";
                SqlCommand cmd = new SqlCommand(sql, Con);



                cmd.Parameters.AddWithValue("@noworkd ", c.noworkd);
                cmd.Parameters.AddWithValue("@day1", c.day1);
                cmd.Parameters.AddWithValue("@day2", c.day2);
                cmd.Parameters.AddWithValue("@day3", c.day3);
                cmd.Parameters.AddWithValue("@day4", c.day4);
                cmd.Parameters.AddWithValue("@day5", c.day5);
                cmd.Parameters.AddWithValue("@day6", c.day6);
                cmd.Parameters.AddWithValue("@day7", c.day7);
                cmd.Parameters.AddWithValue("@stime", c.stime);
                cmd.Parameters.AddWithValue("@dura", c.dura);
                cmd.Parameters.AddWithValue("@etime", c.etime);
                cmd.Parameters.AddWithValue("@hours", c.hours);

                Con.Open();

                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    isSuccess = true;
                }

                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
            }

            finally
            {
                Con.Close();
            }
            return(isSuccess);
        }
Example #2
0
        public bool Update(WorkTimeHour c)
        {
            bool isSuccess = false;

            //Connection String
            SqlConnection Con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\TimeTableDatabase.mdf;Integrated Security=True");


            try
            {
                string     sql = "UPDATE  WorkingDays SET noworkd=@noworkd,day1=@day1,day2=@day2,day3=@day3,day4=@day4,day5=@day5,day6=@day6,day7=@day7,stime=@stime,dura=@dura,etime=@etime,hours=@hours WHERE lectureid=@lectureid";
                SqlCommand cmd = new SqlCommand(sql, Con);

                cmd.Parameters.AddWithValue("@noworkd ", c.noworkd);
                cmd.Parameters.AddWithValue("@day1", c.day1);
                cmd.Parameters.AddWithValue("@day2", c.day2);
                cmd.Parameters.AddWithValue("@day3", c.day3);
                cmd.Parameters.AddWithValue("@day4", c.day4);
                cmd.Parameters.AddWithValue("@day5", c.day5);
                cmd.Parameters.AddWithValue("@day6", c.day6);
                cmd.Parameters.AddWithValue("@day7", c.day7);
                cmd.Parameters.AddWithValue("@stime", c.stime);
                cmd.Parameters.AddWithValue("@dura", c.dura);
                cmd.Parameters.AddWithValue("@etime", c.etime);
                cmd.Parameters.AddWithValue("@hours", c.hours);
                cmd.Parameters.AddWithValue("@lectureid", c.lectureid);


                Con.Open();
                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    isSuccess = true;
                }

                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
            }

            finally
            {
                Con.Close();
            }
            return(isSuccess);
        }
Example #3
0
        public bool Delete(WorkTimeHour c)
        {
            bool isSuccess = false;


            //Connection String
            SqlConnection Con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\TimeTableDatabase.mdf;Integrated Security=True");

            try
            {
                string     sql = "DELETE FROM WorkingDays WHERE lectureid=@lectureid";
                SqlCommand cmd = new SqlCommand(sql, Con);
                cmd.Parameters.AddWithValue("@lectureid", c.lectureid);



                Con.Open();
                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    isSuccess = true;
                }

                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
            }

            finally
            {
                Con.Close();
            }
            return(isSuccess);
        }