Wednesday, March 2, 2016

with para

List<DvdUser> result = new List<DvdUser>();
            SqlConnection con = new SqlConnection(DatabaseHelper.dbConnection);
            SqlCommand cmd = new SqlCommand("SelectDUserWithPara",con);
            cmd.CommandType = CommandType.StoredProcedure;
           
            SqlParameter param = new SqlParameter();
            param.ParameterName = "@id";
            param.Value = inPut.Id;

            // 3. add new parameter to command object
            cmd.Parameters.Add(param);

            con.Open();
            SqlDataReader dataReader = cmd.ExecuteReader();

            DvdUser selectU = null;
            if(dataReader.HasRows)
            {
               
                while (dataReader.Read())
                {
                    selectU = new DvdUser();
                    selectU.Id = Convert.ToInt32(dataReader["id"]);
                    selectU.First_Name = dataReader["first_name"].ToString();
                    selectU.Last_Name = dataReader["last_name"].ToString();
                    selectU.Address = dataReader["address"].ToString();
                    selectU.Tele_Number = Convert.ToInt32(dataReader["telephone_number"]);

                    result.Add(selectU);

                   
                }
            }
            con.Close();
           
            return result;

save

 SqlConnection con = new SqlConnection(DatabaseHelper.dbConnection);
            SqlCommand cmd = new SqlCommand("InsertDvdUser", con);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@first_name", dU.First_Name);
            cmd.Parameters.AddWithValue("@last_name", dU.Last_Name);
            cmd.Parameters.AddWithValue("@address", dU.Address);
            cmd.Parameters.AddWithValue("@telephone_number", dU.Tele_Number);
            cmd.Parameters.Add("@id", System.Data.SqlDbType.Int).Direction = System.Data.ParameterDirection.Output;

                     

            con.Open();
            int outPut = cmd.ExecuteNonQuery();

            con.Close();
            cmd.Dispose();

            return outPut;

GetData

List<DvdUser> result = new List<DvdUser>();
            SqlConnection con = new SqlConnection(DatabaseHelper.dbConnection);
            SqlCommand cmd = new SqlCommand("GetDvdU1", con);
            cmd.CommandType = CommandType.StoredProcedure;

            con.Open();

            SqlDataReader dataReader = cmd.ExecuteReader();
            DvdUser dvdUser = null;
            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    dvdUser = new DvdUser();

                    dvdUser.Id = Convert.ToInt32(dataReader["id"]);
                    dvdUser.First_Name = dataReader["first_name"].ToString();
                    dvdUser.Last_Name = dataReader["last_name"].ToString();
                    dvdUser.Address = dataReader["address"].ToString();
                    dvdUser.Tele_Number = Convert.ToInt32(dataReader["telephone_number"]);

                    result.Add(dvdUser);
                }

            }
            con.Close();
            cmd.Dispose();
            dataReader.Close();

            return result;

Tuesday, February 23, 2016

calculator

double total1 = 0;
        double total2 = 0;

        bool plusButtonClicked = false;
        bool minusButtonClicked = false;
        bool multiplyButtonClicked = false;
        bool divideButtonClicked = false;

        private void btnPlus_Click(object sender, EventArgs e)
        {
            total1 += Double.Parse(txtDisplay.Text);
            txtDisplay.Clear();

             plusButtonClicked = true;
             minusButtonClicked = false;
             multiplyButtonClicked = false;
             divideButtonClicked = false;
        }      
     

        private void btnMinus_Click(object sender, EventArgs e)
        {
            total1 += Double.Parse(txtDisplay.Text);
            txtDisplay.Clear();
           
            plusButtonClicked = false;
             minusButtonClicked = true;
             multiplyButtonClicked = false;
             divideButtonClicked = false;
        }

        private void btnMultiply_Click(object sender, EventArgs e)
        {
            total1 += Double.Parse(txtDisplay.Text);
            txtDisplay.Clear();

            plusButtonClicked = false;
            minusButtonClicked = false;
            multiplyButtonClicked = true;
            divideButtonClicked = false;
        }

        private void btnDivide_Click(object sender, EventArgs e)
        {

            total1 += Double.Parse(txtDisplay.Text);
            txtDisplay.Clear();

            plusButtonClicked = false;
            minusButtonClicked = false;
            multiplyButtonClicked = false;
            divideButtonClicked = true;

        }

        private void btnEqual_Click(object sender, EventArgs e)
        {
           
            if (plusButtonClicked == true) {
                total2 = total1 + Double.Parse(txtDisplay.Text);
                txtDisplay.Text = total2.ToString();
                total1 = 0;
            }
            else if (minusButtonClicked == true)
            {
                total2 = total1 - Double.Parse(txtDisplay.Text);
                txtDisplay.Text = total2.ToString();
                total1 = 0;
            }
            else if (multiplyButtonClicked == true)
            {
                total2 = total1 * Double.Parse(txtDisplay.Text);
                txtDisplay.Text = total2.ToString();
                total1 = 0;
            }
            else if (divideButtonClicked == true)
            {
                total2 = total1 / Double.Parse(txtDisplay.Text);
                txtDisplay.Text = total2.ToString();
                total1 = 0;
            }
        }

Insert Update & Delete using LINQ to SQL

DBClassesDataContext db = new DBClassesDataContext();
            Table tblContact = new Table();

            tblContact.FirstName = txtFN.Text;
            tblContact.LastName = txtLN.Text;

            db.Tables.InsertOnSubmit(tblContact);
            db.SubmitChanges();
response.redirect("default.aspx");


====================================

CREATE TABLE Persons
(
ID int NOT NULL AUTO_INCREMENT,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
PRIMARY KEY (ID)
)

===================

https://www.youtube.com/watch?v=B9GEcteOLkg&ebc=ANyPxKpkDV8Zq4bfePA54iWmeVSLuK3OK12F98G78bDI070N2KUpKkHksahXis2BfQKH6RoNuyl7YKr6Koph5FAfbTSykUBbJg

Thursday, January 24, 2008

Semantic Sensor Networks Workshop

A wireless sensor network (WSN) is a wireless network consisting of spatially distributed autonomous devices using sensors to cooperatively monitor physical or environmental conditions, such as temperature, sound, vibration, pressure, motion or pollutants, at different locations.The development of wireless sensor networks was originally motivated by military applications such as battlefield surveillance. However, wireless sensor networks are now used in many civilian application areas, including environment and habitat monitoring, healthcare applications, home automation, and traffic control.

In addition to one or more sensors, each node in a sensor network is typically equipped with a radio transceiver or other wireless communications device, a small microcontroller, and an energy source, usually a battery. The envisaged size of a single sensor node can vary from shoebox-sized nodes down to devices the size of grain of dust, although functioning 'motes' of genuine microscopic dimensions have yet to be created. The cost of sensor nodes is similarly variable, ranging from hundreds of dollars to a few cents, depending on the size of the sensor network and the complexity required of individual sensor nodes.Size and cost constraints on sensor nodes result in corresponding constraints on resources such as energy, memory, computational speed and bandwidth.

A sensor network normally constitutes a Wireless ad-hoc network, meaning that it each sensor supports a multi-hop routing algorithm (several nodes may forward data packets to the base station).

Reactive Sensor Networks(RSN)


To coordinate work in a distributed sensor network, an active network of mobile code is being constructed. The system uses resource bounded optimization to adapt dynamically to a chaotic environment. This 3-year research effort started in July 1999.

Users make demands for information. Placing them at the center of an active network. Sensors are present at multiple locations in the environment. The network forages for information, like ants forage for food.