Ejemplo n.º 1
0
        public bool update_Profile()
        {
            try
            {
                cls_conection obj1         = new cls_conection();
                SqlConnection myConnection = new SqlConnection(obj1.getConnection());
                myConnection.Open();
                if (myConnection.State == ConnectionState.Closed)
                {
                    myConnection.Open();
                }

                SqlCommand oCmd = new SqlCommand("UPDATE Data_Admin SET first_name=@ffirst_name,last_name=@flast_name,number_phone=@fnumber_phone,country=@fcountry,city=@fcity,address=@faddress,zip_code=@fzip_code WHERE FK_ID_admin=@fkame", myConnection);
                oCmd.Parameters.AddWithValue("@fkame", ID1);
                oCmd.Parameters.AddWithValue("@ffirst_name", First_Name);
                oCmd.Parameters.AddWithValue("@flast_name", Last_Name);
                oCmd.Parameters.AddWithValue("@fnumber_phone", Number_Phone);
                oCmd.Parameters.AddWithValue("@fcountry", Country);
                oCmd.Parameters.AddWithValue("@fcity", City);
                oCmd.Parameters.AddWithValue("@faddress", Address);
                oCmd.Parameters.AddWithValue("@fzip_code", Zip_Code);
                oCmd.ExecuteNonQuery();

                myConnection.Close();
                return(true);
            }
            catch (Exception ex)
            {
                msg = ex.ToString();
                return(false);
                //Response.Write("<script>alert('" + ex.Message + "');</script>");
            }
        }
Ejemplo n.º 2
0
        public cls_operations_admin select_Profile(string fName)
        {
            cls_conection        obj1           = new cls_conection();
            cls_operations_admin matchingPerson = new cls_operations_admin(0, "", "", "", "", "", "", "");

            using (SqlConnection myConnection = new SqlConnection(obj1.getConnection()))
            {
                string     oString = "SELECT first_name,last_name,number_phone,country,city,address,zip_code FROM Data_Admin WHERE FK_ID_admin=@fName";
                SqlCommand oCmd    = new SqlCommand(oString, myConnection);
                oCmd.Parameters.AddWithValue("@fname", fName);
                myConnection.Open();
                using (SqlDataReader oReader = oCmd.ExecuteReader())
                {
                    while (oReader.Read())
                    {
                        //I got problem getting the PRIMARY KEY and the FOREIGN KEY
                        //matchingPerson.Fk_id_cat = Int32.Parse(oReader["ID_prod"].ToString());

                        matchingPerson.First_Name   = oReader["first_name"].ToString();
                        matchingPerson.Last_Name    = oReader["last_name"].ToString();
                        matchingPerson.Number_Phone = oReader["number_phone"].ToString();
                        matchingPerson.Country      = oReader["country"].ToString();
                        matchingPerson.City         = oReader["city"].ToString();
                        matchingPerson.Address      = oReader["address"].ToString();
                        matchingPerson.Zip_Code     = oReader["zip_code"].ToString();
                    }

                    myConnection.Close();
                }
            }
            return(matchingPerson);
        }
Ejemplo n.º 3
0
        public bool Delete(string id)
        {
            try
            {
                cls_conection obj1         = new cls_conection();
                SqlConnection myConnection = new SqlConnection(obj1.getConnection());
                myConnection.Open();
                if (myConnection.State == ConnectionState.Closed)
                {
                    myConnection.Open();
                }

                SqlCommand oCmd = new SqlCommand("DELETE FROM Products WHERE ID_prod=@fkame", myConnection);
                oCmd.Parameters.AddWithValue("@fkame", id);
                oCmd.ExecuteNonQuery();

                myConnection.Close();
                return(true);
            }
            catch (Exception ex)
            {
                msg = ex.ToString();
                return(false);
            }
        }
Ejemplo n.º 4
0
        public cls_operations_admin Select(string fName)
        {
            cls_conection        obj1           = new cls_conection();
            cls_operations_admin matchingPerson = new cls_operations_admin();

            using (SqlConnection myConnection = new SqlConnection(obj1.getConnection()))
            {
                string     oString = "Select name,brand,price,description,photo,current_stock from Products where ID_prod=@fName";
                SqlCommand oCmd    = new SqlCommand(oString, myConnection);
                oCmd.Parameters.AddWithValue("@fname", fName);
                myConnection.Open();
                using (SqlDataReader oReader = oCmd.ExecuteReader())
                {
                    while (oReader.Read())
                    {
                        //I got problem getting the PRIMARY KEY and the FOREIGN KEY
                        //matchingPerson.Fk_id_cat = Int32.Parse(oReader["ID_prod"].ToString());

                        matchingPerson.Name          = oReader["name"].ToString();
                        matchingPerson.Brand         = oReader["brand"].ToString();
                        matchingPerson.Price         = float.Parse(oReader["price"].ToString());
                        matchingPerson.Description   = oReader["description"].ToString();
                        matchingPerson.Photo         = oReader["photo"].ToString();
                        matchingPerson.Current_stock = Int32.Parse(oReader["current_stock"].ToString());
                    }

                    myConnection.Close();
                }
            }
            return(matchingPerson);
        }
Ejemplo n.º 5
0
        public cls_operations_user select_Profile1(string fName)
        {
            cls_conection       obj1           = new cls_conection();
            cls_operations_user matchingPerson = new cls_operations_user(0, "", "", "", "");

            using (SqlConnection myConnection = new SqlConnection(obj1.getConnection()))
            {
                string     oString = "SELECT * FROM Billing_user WHERE FK_ID_user=@fName";
                SqlCommand oCmd    = new SqlCommand(oString, myConnection);
                oCmd.Parameters.AddWithValue("@fname", fName);
                myConnection.Open();
                using (SqlDataReader oReader = oCmd.ExecuteReader())
                {
                    while (oReader.Read())
                    {
                        //I got problem getting the PRIMARY KEY and the FOREIGN KEY
                        //matchingPerson.Fk_id_cat = Int32.Parse(oReader["ID_prod"].ToString());

                        matchingPerson.Number        = oReader["number"].ToString();
                        matchingPerson.type          = oReader["type"].ToString();
                        matchingPerson.Date_end      = oReader["date_end"].ToString();
                        matchingPerson.Code_security = oReader["code_security"].ToString();
                    }

                    myConnection.Close();
                }
            }
            return(matchingPerson);
        }
Ejemplo n.º 6
0
        public bool Updatek()
        {
            try
            {
                cls_conection obj1         = new cls_conection();
                SqlConnection myConnection = new SqlConnection(obj1.getConnection());
                myConnection.Open();
                if (myConnection.State == ConnectionState.Closed)
                {
                    myConnection.Open();
                }

                SqlCommand oCmd = new SqlCommand(@"UPDATE Products set name=@fname,brand=@fbrand,price=@fprice,description=@fdescription,photo=@fphoto,current_stock=@fcurrent_stock where ID_prod=@fkame", myConnection);
                oCmd.Parameters.AddWithValue("@fkame", ID);
                oCmd.Parameters.AddWithValue("@fname", Name);
                oCmd.Parameters.AddWithValue("@fbrand", Brand);
                oCmd.Parameters.AddWithValue("@fprice", Price);
                oCmd.Parameters.AddWithValue("@fdescription", Description);
                oCmd.Parameters.AddWithValue("@fphoto", Photo);
                oCmd.Parameters.AddWithValue("@fcurrent_stock", Current_stock);
                oCmd.ExecuteNonQuery();

                myConnection.Close();
                return(true);
            }
            catch (Exception ex)
            {
                //  Console.WriteLine(ex);
                msg = ex.ToString();
                return(false);
                //Response.Write("<script>alert('" + ex.Message + "');</script>");
            }

            /*
             *     conectar(table);
             * DataRow fila;
             * if (Data.Tables[0].Rows.Count > 0)
             * {
             *
             * }else if(Data.Tables[0].Rows.Count == 0)
             * {
             *
             * } */
        }