示例#1
0
        public static int Update(Clients pClient)
        {
            int             counter   = 0;
            MySqlConnection connetion = BD_Connector.GetConnection();

            MySqlCommand comando = new MySqlCommand(string.Format("Update corinsa_clients set client_name='{0}', client_email='{1}', client_cellphone='{2}',client_address='{3}' where idcorinsa_clients={4}",
                                                                  pClient.Name, pClient.Email, pClient.Telephone, pClient.Address, pClient.Id), connetion);

            counter = comando.ExecuteNonQuery();
            connetion.Close();

            return(counter);
        }
示例#2
0
        public static int Delete(Clients pClient)
        {
            int             counter   = 0;
            MySqlConnection connetion = BD_Connector.GetConnection();

            MySqlCommand comando = new MySqlCommand(string.Format("delete from corinsa_clients where idcorinsa_clients={0}",
                                                                  pClient.Id), connetion);

            counter = comando.ExecuteNonQuery();
            connetion.Close();

            return(counter);
        }
示例#3
0
        public static int Update(Product pProduct)
        {
            int             counter   = 0;
            MySqlConnection connetion = BD_Connector.GetConnection();

            MySqlCommand comando = new MySqlCommand(string.Format("Update corinsa_products set product_name='{0}', product_description='{1}', product_price='{2}', product_alias='{3}' where idcorinsa_products={4}",
                                                                  pProduct.Name, pProduct.Description, pProduct.Price, pProduct.Alias, pProduct.Id), connetion);

            counter = comando.ExecuteNonQuery();
            connetion.Close();

            return(counter);
        }
示例#4
0
        public static Clients GetClient(int pId)
        {
            Clients         pClient   = new Clients();
            MySqlConnection connetion = BD_Connector.GetConnection();

            MySqlCommand    _comando = new MySqlCommand(String.Format("select idcorinsa_clients, client_name, client_email, client_cellphone, client_address FROM corinsa_clients  where idcorinsa_clients={0}", pId), connetion);
            MySqlDataReader _reader  = _comando.ExecuteReader();

            while (_reader.Read())
            {
                pClient.Id        = _reader.GetInt32(0);
                pClient.Name      = _reader.GetString(1);
                pClient.Email     = _reader.GetString(2);
                pClient.Telephone = _reader.GetString(3);
                pClient.Address   = _reader.GetString(4);
            }

            connetion.Close();
            return(pClient);
        }
示例#5
0
        public static Product GetProduct(int pId)
        {
            Product         pProduct  = new Product();
            MySqlConnection connetion = BD_Connector.GetConnection();

            MySqlCommand    _comando = new MySqlCommand(String.Format("select idcorinsa_products, product_alias, product_name, product_description, product_price FROM corinsa_products  where idcorinsa_products={0}", pId), connetion);
            MySqlDataReader _reader  = _comando.ExecuteReader();

            while (_reader.Read())
            {
                pProduct.Id          = _reader.GetInt32(0);
                pProduct.Alias       = _reader.GetString(1);
                pProduct.Name        = _reader.GetString(2);
                pProduct.Description = _reader.GetString(3);
                pProduct.Price       = Convert.ToDecimal(_reader.GetString(4));
            }

            connetion.Close();
            return(pProduct);
        }
示例#6
0
        public static List <Clients> Search(string pName)
        {
            List <Clients> _lista = new List <Clients>();

            MySqlCommand _comando = new MySqlCommand(String.Format(
                                                         "select idcorinsa_clients, client_name, client_email, client_cellphone, client_address FROM corinsa_clients  where client_name like'%{0}%'", pName), BD_Connector.GetConnection());
            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                Clients pClients = new Clients();
                pClients.Id        = _reader.GetInt32(0);
                pClients.Name      = _reader.GetString(1);
                pClients.Email     = _reader.GetString(2);
                pClients.Telephone = _reader.GetString(3);
                pClients.Address   = _reader.GetString(4);


                _lista.Add(pClients);
            }

            return(_lista);
        }
示例#7
0
        public static int Add(Clients pClient)
        {
            int count = 0;

            MySqlCommand comando = new MySqlCommand(string.Format("Insert into corinsa_clients (client_name, client_email, client_cellphone, client_address) values ('{0}','{1}','{2}', '{3}')",
                                                                  pClient.Name, pClient.Email, pClient.Telephone, pClient.Address), BD_Connector.GetConnection());

            count = comando.ExecuteNonQuery();
            return(count);
        }
示例#8
0
        public static List <Product> Search(string pName)
        {
            List <Product> _lista = new List <Product>();

            MySqlCommand _comando = new MySqlCommand(String.Format(
                                                         "select idcorinsa_products, product_alias, product_name, product_description, product_price FROM corinsa_products  where product_alias like '{0}%'", pName), BD_Connector.GetConnection());
            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                Product pProduct = new Product();
                pProduct.Id          = _reader.GetInt32(0);
                pProduct.Alias       = _reader.GetString(1);
                pProduct.Name        = _reader.GetString(2);
                pProduct.Description = _reader.GetString(3);
                pProduct.Price       = Convert.ToDecimal(_reader.GetString(4));


                _lista.Add(pProduct);
            }

            return(_lista);
        }
示例#9
0
        public static int Add(Product pProduct)
        {
            int count = 0;

            MySqlCommand comando = new MySqlCommand(string.Format("Insert into corinsa_products (product_name, product_description, product_alias, product_price) values ('{0}','{1}','{2}', '{3}')",
                                                                  pProduct.Name, pProduct.Description, pProduct.Alias, pProduct.Price), BD_Connector.GetConnection());

            count = comando.ExecuteNonQuery();
            return(count);
        }