Exemplo n.º 1
0
        // Delect data from Database
        public bool Delete(LocationClass c)
        {
            bool isSuccess = false;

            SqlConnection conn = new SqlConnection(myconstrng);

            try
            {
                string     sql = "DELETE FROM tbl_Location  WHERE LocationID = @LocationID";
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@LocationID", c.LocationID);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
Exemplo n.º 2
0
        // Update data from Database
        public bool Update(LocationClass c)
        {
            bool isSuccess = false;

            SqlConnection conn = new SqlConnection(myconstrng);

            try
            {
                string     sql = "UPDATE tbl_Location SET BuildingName = @BuildingName , RoomName = @RoomName , RoomType = @RoomType , Capacity = @Capacity WHERE LocationID = @LocationID";
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@BuildingName", c.BuildingName);
                cmd.Parameters.AddWithValue("@RoomName", c.RoomName);
                cmd.Parameters.AddWithValue("@RoomType", c.RoomType);
                cmd.Parameters.AddWithValue("@Capacity", c.Capacity);
                cmd.Parameters.AddWithValue("@LocationID", c.LocationID);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
Exemplo n.º 3
0
        // Inseert data from Database
        public bool Insert(LocationClass c)
        {
            bool isSuccess = false;

            SqlConnection conn = new SqlConnection(myconstrng);

            try
            {
                string     sql = "INSERT INTO tbl_Location(BuildingName,RoomName,RoomType,Capacity)VALUES (@BuildingName,@RoomName,@RoomType,@Capacity)";
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@BuildingName", c.BuildingName);
                cmd.Parameters.AddWithValue("@RoomName", c.RoomName);
                cmd.Parameters.AddWithValue("@RoomType", c.RoomType);
                cmd.Parameters.AddWithValue("@Capacity", c.Capacity);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }

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