예제 #1
0
        protected void btn_guardar_Click(object sender, EventArgs e)
        {
            UserBusiness ub = new UserBusiness();

            User u = new User(txb_name.Text,txb_email.Text,txb_carne.Text,txb_password.Text);
            ub.Insert(u);
        }
예제 #2
0
파일: UserData.cs 프로젝트: estf/Examen1
        public void Insert(User user)
        {
            try
            {
                SqlConnection con = DataBaseConnection("open");
                SqlCommand sqlcommand;
                string databaseCommand = " INSERT INTO [dbo].[User] (name,email,carne,password)values (" + "'" + user.Name + "'" + "," + "'" + user.Email + "'" + "," + "'" + user.Carne + "'" + "," + "'" + user.Password + "'" + ")";
                sqlcommand = new SqlCommand(databaseCommand, con);
                sqlcommand.ExecuteNonQuery();
                sqlcommand.Dispose();
                DataBaseConnection("close");
            }
            catch (SqlException sqlException)
            {
                Console.WriteLine("Database error:" + sqlException.ToString());

            }
        }
예제 #3
0
 public void Update(User user)
 {
     userData.Update(user);
 }
예제 #4
0
 public void Insert(User user)
 {
     userData.Insert(user);
 }
예제 #5
0
파일: UserData.cs 프로젝트: estf/Examen1
        public void Update(User user)
        {
            SqlConnection con = DataBaseConnection("open");
            try
            {
                SqlCommand cmdIns = new SqlCommand("UPDATE user SET name=@name ,email=@email,carne=@carne,password=@password", con);
                cmdIns.Parameters.Add("@name", user.Name);
                cmdIns.Parameters.Add("@email", user.Email);
                cmdIns.Parameters.Add("@carne", user.Carne);
                cmdIns.Parameters.Add("@password", user.Password);

                cmdIns.ExecuteNonQuery();
                cmdIns.Dispose();
                cmdIns = null;
            }
            catch (SqlException ex)
            {
                throw new Exception(ex.ToString(), ex);
            }
            finally
            {
                DataBaseConnection("close");
            }
        }