Exemple #1
0
        public bool updateSaleService(SaleServicesModel sale)
        {
            string        query = "UPDATE saleServices SET idService = @idService, idStore = @idStore, idEmploy = @idEmploye,  total = @total  WHERE id = @id";
            SqlConnection conn  = new SqlConnection(cadena);
            SqlCommand    cmd   = new SqlCommand(query, conn);

            try
            {
                conn.Open();
                cmd.Parameters.Add("@id", System.Data.SqlDbType.Int).Value        = sale.id;
                cmd.Parameters.Add("@idService", System.Data.SqlDbType.Int).Value = sale.idService;
                cmd.Parameters.Add("@idStore", System.Data.SqlDbType.Int).Value   = sale.idStore;
                cmd.Parameters.Add("@idEmploye", System.Data.SqlDbType.Int).Value = sale.idEmploye;
                cmd.Parameters.Add("@total", System.Data.SqlDbType.Money).Value   = sale.total;

                int register = cmd.ExecuteNonQuery();

                return(register == 1);
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                conn.Close();
            }
        }
Exemple #2
0
        public SaleServicesModel returnSaleService(int id)
        {
            string            query = "SELECT idService, idStore, idEmploy, discount, total FROM saleServices WHERE id = @id";
            SqlConnection     conn  = new SqlConnection(cadena);
            SqlCommand        cmd   = new SqlCommand(query, conn);
            SaleServicesModel sale  = new SaleServicesModel();


            try
            {
                conn.Open();
                cmd.Parameters.Add("@id", System.Data.SqlDbType.Int).Value = id;
                SqlDataReader dr = cmd.ExecuteReader();


                if (dr.Read())
                {
                    sale.idService = dr.GetInt32(0);
                    sale.idStore   = dr.GetInt32(1);
                    sale.idEmploye = dr.GetInt32(2);
                    sale.discount  = dr.GetDouble(3);
                    sale.total     = dr.GetDecimal(4);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                conn.Close();
            }
            return(sale);
        }
Exemple #3
0
        public bool createSale(SaleServicesModel sale)
        {
            string        query = "INSERT INTO saleServices VALUES(@idService,@idStore,@idEmploye,GETDATE(),@discount,@total)";
            SqlConnection conn  = new SqlConnection(cadena);
            SqlCommand    cmd   = new SqlCommand(query, conn);

            try
            {
                conn.Open();
                cmd.Parameters.Add("@idService", System.Data.SqlDbType.Int).Value  = sale.idService;
                cmd.Parameters.Add("@idStore", System.Data.SqlDbType.Int).Value    = sale.idStore;
                cmd.Parameters.Add("@idEmploye", System.Data.SqlDbType.Int).Value  = sale.idEmploye;
                cmd.Parameters.Add("@discount", System.Data.SqlDbType.Float).Value = sale.discount;
                cmd.Parameters.Add("@total", System.Data.SqlDbType.Money).Value    = sale.total;

                int register = cmd.ExecuteNonQuery();
                return(register == 1);
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                conn.Close();
            }
        }