Пример #1
0
        public Decimal SumaVentaEfectivoCaja(Int32 codSuc, DateTime fech1, Int32 codigocaja)
        {
            Decimal total = 0;

            try
            {
                con.conectarBD();
                cmd = new MySqlCommand("SumaVentasEfectivoDia", con.conector);
                cmd.Parameters.AddWithValue("codSucur", codSuc);
                cmd.Parameters.AddWithValue("fecha1", fech1);
                cmd.Parameters.AddWithValue("codcaja_ex", codigocaja);
                cmd.CommandType = CommandType.StoredProcedure;
                dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        total = Convert.ToDecimal(dr.GetDecimal(0));
                    }
                }
                return(total);
            }
            catch (MySqlException ex)
            {
                throw ex;
            }
            finally { con.conector.Dispose(); cmd.Dispose(); con.desconectarBD(); }
        }
Пример #2
0
        public Details RetreiveProductDetails(int ProductID)
        {
            Details ProductDetails = new Details();

            using (MySqlConnection connection = new MySqlConnection(ConnectionString))
            {
                MySqlCommand command = new MySqlCommand("SELECT ProductName, Price, ProductDetail FROM products where ProductID = '" + ProductID + "';", connection);
                connection.Open();

                MySqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ProductDetails.Name    = reader.GetString(0);
                        ProductDetails.Price   = reader.GetDecimal(1);
                        ProductDetails.Picture = (byte[])reader[2];
                    }
                }
                reader.Close();

                return(ProductDetails);
            }
        }
Пример #3
0
        public ArrayList RetreiveSaleItems(int SaleID)
        {
            ArrayList ProductsList = new ArrayList();

            using (MySqlConnection connection = new MySqlConnection(ConnectionString))
            {
                MySqlCommand command = new MySqlCommand("SELECT ProductID, Price, Quantity FROM sale_details where SaleID = '" + SaleID + "';", connection);
                connection.Open();

                MySqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        string  ProductID       = reader.GetString(0);
                        decimal ProductPrice    = reader.GetDecimal(1);
                        int     ProductQuantity = reader.GetInt32(2);


                        string ProductName = this.ReturnProductName(ProductID);

                        ProductsList.Add(new Details()
                        {
                            Name = ProductName, Price = ProductPrice, Quantity = ProductQuantity
                        });
                    }
                }
                reader.Close();

                return(ProductsList);
            }
        }
Пример #4
0
        public List <ProdutoVendaDTO> Consultar()
        {
            string script = @"SELECT * FROM tb_produtoVenda";
            List <MySqlParameter> parms = new List <MySqlParameter>();

            Database        db     = new Database();
            MySqlDataReader reader = db.ExecuteSelectScript(script, parms);

            List <ProdutoVendaDTO> produtos = new List <ProdutoVendaDTO>();

            while (reader.Read())
            {
                ProdutoVendaDTO produto = new ProdutoVendaDTO();
                produto.id_produtoVenda        = reader.GetInt32("id_produtoVenda");
                produto.nm_Produto             = reader.GetString("nm_Produto");
                produto.ds_Produto             = reader.GetString("ds_Produto");
                produto.vl_Venda               = reader.GetDecimal("vl_Venda");
                produto.dt_Validade            = reader.GetDateTime("dt_Validade");
                produto.fk_ProdutoVenda_Filial = reader.GetInt32("fk_ProdutoVenda_Filial");

                produtos.Add(produto);
            }

            reader.Close();
            return(produtos);
        }
Пример #5
0
 private void confirmButton_Click(object sender, EventArgs e)
 {
     if (nameText.Text != "" && nativeText.Text != "" && pwdText.Text != "" &&
         (occupText.Text == "receiver" ||
          occupText.Text == "deliver" ||
          occupText.Text == "adminer" ||
          occupText.Text == "warehourser"
         ) && phoneText.Text != ""
         &&
         (genderText.Text == "M" || genderText.Text == "F")
         )
     {
         MySqlCommand com = new MySqlCommand("select count(*) from worker", Login.con);
         com.ExecuteNonQuery();
         MySqlDataReader dataReader = com.ExecuteReader();
         dataReader.Read();
         Decimal workerId = dataReader.GetDecimal(0);
         dataReader.Close();
         string insertStatement =
             "insert into worker values(\"" + workerId.ToString() + "\", \"" +
             pwdText.Text + "\", \"" + nameText.Text + "\", \"" + birthText.Value + "\",\"" +
             nativeText.Text + "\",\"" + genderText.Text + "\",\"" + occupText.Text + "\",\"" +
             phoneText.Text + "\",\"" + adminText.Value + "\")";
         com = new MySqlCommand(insertStatement, Login.con);
         com.ExecuteNonQuery();
         MetroFramework.MetroMessageBox.Show(this, "新建员工的编号为 " + workerId.ToString(), "插入员工成功");
     }
     else
     {
         MetroFramework.MetroMessageBox.Show(this, "选项填写不完整,请填写完整!", "注册失败", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Пример #6
0
        public Product GetProduct(int id)
        {
            MySqlConnection conn = new MySqlConnection(connectionString);
            MySqlCommand    cmd  = conn.CreateCommand();

            cmd.CommandText = "SELECT * FROM Products WHERE ProductID = @id;";
            cmd.Parameters.AddWithValue("id", id);

            using (conn)
            {
                conn.Open();
                MySqlDataReader reader  = cmd.ExecuteReader();
                var             product = new Product();

                while (reader.Read() == true)
                {
                    product.ID         = reader.GetInt32("ProductID");
                    product.Name       = reader.GetString("Name");
                    product.Price      = reader.GetDecimal("Price");
                    product.CategoryID = reader.GetInt32("OnSale");


                    if (reader.IsDBNull(reader.GetOrdinal("StockLevel")))

                    {
                        product.StockLevel = null;
                    }
                    else
                    {
                        product.StockLevel = reader.GetString("StockLevel");
                    }
                }
                return(product);
            }
        }
Пример #7
0
        public List <EventoDTO> Listar()
        {
            string script = @"SELECT * FROM tb_Evento";

            List <MySqlParameter> parms = new List <MySqlParameter>();

            Database        db     = new Database();
            MySqlDataReader reader = db.ExecuteSelectScript(script, parms);

            List <EventoDTO> lista = new List <EventoDTO>();

            while (reader.Read())
            {
                EventoDTO dto = new EventoDTO();
                dto.id          = reader.GetInt32("id_Evento");
                dto.Nome        = reader.GetString("nm_NomeEvento");
                dto.Local       = reader.GetString("nm_Local");
                dto.Data        = reader.GetDateTime("dt_Data");
                dto.Horario     = reader.GetString("dt_Horário");
                dto.Valor       = reader.GetDecimal("vl_Preco");
                dto.Descricao   = reader.GetString("ds_Descricao");
                dto.Quantidade  = reader.GetInt32("ds_Quantidade");
                dto.Estoque     = reader.GetInt32("tb_Estoque_id_Estoque");
                dto.Funcionario = reader.GetInt32("tb_Funcionario_id_Funcionario");
                dto.Cliente     = reader.GetInt32("tb_Cliente_id_Cliente");

                lista.Add(dto);
            }
            reader.Close();

            return(lista);
        }
Пример #8
0
        public static List <ProductoEstado> ObtenerProductosEstado()//sin estado
        {
            List <ProductoEstado> _lista   = new List <ProductoEstado>();
            MySqlConnection       conexion = bdComun.obtenerConexion();

            MySqlCommand _comando = new MySqlCommand(String.Format(
                                                         "SELECT * FROM producto where ESTADO=1"), conexion);

            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                ProductoEstado pProducto = new ProductoEstado();

                pProducto.COD          = _reader.GetString(0);
                pProducto.NOMBRE       = _reader.GetString(1);
                pProducto.DESCRIPCION  = _reader.GetString(2);
                pProducto.CATEGORIA    = _reader.GetString(3);
                pProducto.SUBCATEGORIA = _reader.GetString(4);
                pProducto.EXISTENCIA   = _reader.GetInt32(5);
                pProducto.PRECIO       = _reader.GetDecimal(6);
                //pProducto.ESTADO = _reader.GetInt32(7);

                _lista.Add(pProducto);
            }
            conexion.Close();
            return(_lista);
        }
Пример #9
0
        public ItemDTO ConsultarProTxt(string nome, int fornecedor)
        {
            string script = @"SELECT * FROM tb_item WHERE nm_item LIKE @nm_item AND id_fornecedor LIKE @id_fornecedor";

            List <MySqlParameter> parms = new List <MySqlParameter>();

            parms.Add(new MySqlParameter("nm_item", nome + "%"));
            parms.Add(new MySqlParameter("id_fornecedor", fornecedor + "%"));

            Database        db     = new Database();
            MySqlDataReader reader = db.ExecuteSelectScript(script, parms);

            ItemDTO dto = null;

            while (reader.Read())
            {
                dto              = new ItemDTO();
                dto.Id           = reader.GetInt32("id_item");
                dto.Nome         = reader.GetString("nm_item");
                dto.FornecedorId = reader.GetInt32("id_fornecedor");
                dto.Preco        = reader.GetDecimal("vl_preco");
                dto.Descricao    = reader.GetString("ds_item");
            }
            reader.Close();
            return(dto);
        }
Пример #10
0
        public List <VwConsultarFolhapagamento> Consultarmes(string mes)
        {
            string script =
                @"SELECT * FROM vw_consultar_folhapagamento
                   WHERE ds_mes like @ds_mes";
            List <SqlParameter> parms = new List <SqlParameter>();

            parms.Add(new SqlParameter("ds_mes", "%" + mes + "%"));

            Database        db     = new Database();
            MySqlDataReader reader = db.ExecuteSelectScript(script, parms);

            List <VwConsultarFolhapagamento> folhas = new List <VwConsultarFolhapagamento>();

            while (reader.Read())
            {
                VwConsultarFolhapagamento dto = new VwConsultarFolhapagamento();
                dto.Nome           = reader.GetString("nm_nome");
                dto.Departamento   = reader.GetString("ds_dpto");
                dto.Mês            = reader.GetString("ds_mes");
                dto.SalarioLiquido = reader.GetDecimal("vl_salarioliquido");
                folhas.Add(dto);
            }
            reader.Close();

            return(folhas);
        }
Пример #11
0
        public static List <Producto> ObtenerPorFiltro(string pId, string pNombre, string pDescripcion, string pCategoria,
                                                       string pSubcategoria)
        {
            List <Producto> _lista   = new List <Producto>();
            MySqlConnection conexion = bdComun.obtenerConexion();

            MySqlCommand _comando = new MySqlCommand(String.Format("SELECT * FROM sercordb.producto where ID_PRODUCTO='{0}' or NOMBRE='{1}' or DESCRIPCION='{2}' or CATEGORIA='{3}' or SUBCATEGORIA='{4}'", pId,
                                                                   pNombre, pDescripcion, pCategoria, pSubcategoria), conexion);

            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                Producto pProducto = new Producto();

                pProducto.COD          = _reader.GetString(0);
                pProducto.NOMBRE       = _reader.GetString(1);
                pProducto.DESCRIPCION  = _reader.GetString(2);
                pProducto.CATEGORIA    = _reader.GetString(3);
                pProducto.SUBCATEGORIA = _reader.GetString(4);
                pProducto.EXISTENCIA   = _reader.GetInt32(5);
                pProducto.PRECIO       = _reader.GetDecimal(6);
                pProducto.ESTADO       = _reader.GetInt32(7);

                _lista.Add(pProducto);
            }
            conexion.Close();
            return(_lista);
        }
Пример #12
0
        /// <summary>
        /// 测试用户的合法性
        /// </summary>
        /// <param name="vAIS_Users"></param>
        /// <returns></returns>
        public Model.v_UserInfos TestUser(Model.v_UserInfos vUser)
        {
            Model.v_UserInfos users = null;

            StringBuilder sql = new StringBuilder();

            sql.Append("select UserID,UserAccount,UserName  From UserInfos  ");
            sql.Append(" where UserAccount=@UserAccount and UserPassword=@UserPassword  ");
            MySqlParameter[] paras = new MySqlParameter[]{
                new MySqlParameter("@UserAccount",vUser.UserAccount),
                new MySqlParameter("@UserPassword",vUser.UserPassword)
                };
            using (MySqlDataReader reader = db.getSelectData(sql.ToString(), paras))
            {
                if (reader.Read())
                {
                    users = new Model.v_UserInfos();
                    users.UserID = reader.GetDecimal(0);
                    users.UserAccount = reader.GetString(1);
                    users.UserName = reader.GetString(2);
                }
                reader.Close();
                return users;
            }
        }
Пример #13
0
        /// <summary>
        /// 查询信息
        /// </summary>
        /// <param name="v">查询条件</param>
        /// <param name="pageIndex">页数</param>
        /// <param name="pageSize">页大小</param>
        /// <param name="recordCount">返回记录数</param>
        /// <returns></returns>
        public List<Model.v_UserInfos> querying(Condition.SystemuserCondition v, int pageIndex, int pageSize, out int recordCount)
        {
            StringBuilder sql = new StringBuilder();
            sql.Append("Select UserID,UserAccount,UserPassword,UserName,UserType  From UserInfos ");
            sql.Append("  Where 1=1  ");

            if (!string.IsNullOrEmpty(v.UserName))
            {
                sql.Append(" and UserName Like '%" + v.UserName + "%'");
            }

            using (MySqlDataReader reader = db.Paging(sql.ToString(), pageIndex, pageSize, out recordCount))
            {
                List<Model.v_UserInfos> result = new List<Model.v_UserInfos>();
                while (reader.Read())
                {
                    result.Add(new Model.v_UserInfos()
                    {
                        UserID = reader.GetDecimal(0),
                        UserAccount = reader.GetString(1),
                        UserPassword = reader.GetString(2),
                        UserName = reader.GetString(3),
                        UserType = reader.GetString(4)
                    });
                }
                reader.Close();
                return result;
            }
        }
Пример #14
0
        public Decimal traersaldo()
        {
            Decimal saldo = 0;

            try
            {
                con.conectarBD();
                cmd = new MySqlCommand("traersaldoCajaChica", con.conector);
                //cmd.Parameters.AddWithValue("codAlma", codAlmacen);
                cmd.CommandType = CommandType.StoredProcedure;
                dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        saldo = Convert.ToDecimal(dr.GetDecimal(0));
                    }
                }
                return(saldo);
            }
            catch (MySqlException ex)
            {
                throw ex;
            }
            finally { con.conector.Dispose(); cmd.Dispose(); con.desconectarBD(); }
        }
Пример #15
0
        private Customer GetMoney(MySqlDataReader reader)
        {
            Customer customer = new Customer();

            customer.Money = reader.GetDecimal("Money");
            return(customer);
        }
Пример #16
0
        public List <ItemView> Consultar(string nome, string fornecedor)
        {
            string script = @"SELECT * FROM tb_item WHERE nm_item LIKE @nm_item AND nm_fornecedor LIKE @nm_fornecedor";

            List <MySqlParameter> parms = new List <MySqlParameter>();

            parms.Add(new MySqlParameter("nm_item", nome + "%"));

            Database        db     = new Database();
            MySqlDataReader reader = db.ExecuteSelectScript(script, parms);

            List <ItemView> lista = new List <ItemView>();

            while (reader.Read())
            {
                ItemView dto = new ItemView();
                dto.Id         = reader.GetInt32("id_item");
                dto.Nome       = reader.GetString("nm_item");
                dto.Fornecedor = reader.GetString("nm_fornecedor");
                dto.Preco      = reader.GetDecimal("vl_preco");
                dto.Descricao  = reader.GetString("ds_item");

                lista.Add(dto);
            }
            reader.Close();
            return(lista);
        }
Пример #17
0
        public List <Book> GetAllFilms()
        {
            List <Book> list = new List <Book>();

            using (MySqlConnection conn = GetConnection())
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("SELECT * FROM books", conn);
                using (MySqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        list.Add(new Book()
                        {
                            ID          = reader.GetInt32("ID"),
                            Title       = reader.GetString("title"),
                            Author      = reader.GetString("author"),
                            ReleaseDate = reader.GetDateTime("releasedate"),
                            Price       = reader.GetDecimal("price"),
                            Rating      = reader.GetString("rating")
                        });
                    }
                }
            }

            return(list);
        }
Пример #18
0
        public SFamilhaDTO Consultar(decimal salario)
        {
            string script = @"SELECT * FROM tb_salarioFamilia WHERE ds_salFamilia = @ds_salFamilia";

            Database db = new Database();
            List <MySqlParameter> parms = new List <MySqlParameter>();

            parms.Add(new MySqlParameter("ds_salFamilia", salario));

            MySqlDataReader reader = db.ExecuteSelectScript(script, parms);

            SFamilhaDTO add = null;

            if (reader.Read())
            {
                add            = new SFamilhaDTO();
                add.Id         = reader.GetInt32("id_salFamilia");
                add.SalFamilia = reader.GetDecimal("ds_salFamilia");
                add.Valor      = reader.GetInt32("vl_salFamilia");
            }

            reader.Close();

            return(add);
        }
Пример #19
0
        public List <Product> GetOnSaleProducts()
        {
            MySqlConnection conn = new MySqlConnection(connectionString);
            MySqlCommand    cmd  = conn.CreateCommand();

            cmd.CommandText = "SELECT * FROM Products WHERE OnSale = 1;";


            using (conn)
            {
                conn.Open();
                MySqlDataReader reader = cmd.ExecuteReader();

                List <Product> allProducts = new List <Product>();

                while (reader.Read() == true)
                {
                    var currentProduct = new Product();
                    currentProduct.ID         = reader.GetInt32("ProductID");
                    currentProduct.Name       = reader.GetString("Name");
                    currentProduct.Price      = reader.GetDecimal("Price");
                    currentProduct.OnSale     = reader.GetInt32("OnSale");
                    currentProduct.StockLevel = reader.GetString("OnSale");
                    currentProduct.CategoryID = reader.GetInt32("CategoryID");

                    allProducts.Add(currentProduct);
                }
                return(allProducts);
            }
        }
Пример #20
0
        public List <TratamentoDTO> Listar()
        {
            string script = @"SELECT * FROM tratamentos";

            List <MySqlParameter> parms = new List <MySqlParameter>();

            Database        db     = new Database();
            MySqlDataReader reader = db.ExecuteSelectScript(script, parms);

            List <TratamentoDTO> lista = new List <TratamentoDTO>();

            while (reader.Read())
            {
                TratamentoDTO dto = new TratamentoDTO();
                dto.ID        = reader.GetInt32("id_tratamentos");
                dto.Nome      = reader.GetString("nm_tratamento");
                dto.Valor     = reader.GetDecimal("ds_valor");
                dto.Duracao   = reader.GetInt32("duracao");
                dto.descricao = reader.GetString("tratamentoscol");



                lista.Add(dto);
            }
            reader.Close();

            return(lista);
        }
Пример #21
0
        public List <Product> GetProducts()
        {
            MySqlConnection conn = new MySqlConnection(connString);

            using (conn)
            {
                conn.Open();
                MySqlCommand cmd = conn.CreateCommand();

                cmd.CommandText = "SELECT ProductID, Name, Price, StockLevel FROM products;";
                MySqlDataReader reader = cmd.ExecuteReader();

                var products = new List <Product>();
                while (reader.Read())
                {
                    var row = new Product();
                    row.ProductID  = reader.GetInt32("ProductID");
                    row.Name       = reader.GetString("Name");
                    row.Price      = reader.GetDecimal("Price");
                    row.StockLevel = reader.GetInt32("StockLevel");

                    products.Add(row);
                }
                return(products);
            }
        }
Пример #22
0
        public static List <ClsCmdFournisseur> ResultatSommeCmdFournisseurSql(string _RequeteSql)
        {
            List <ClsCmdFournisseur> cliste = new List <ClsCmdFournisseur>();

            using (MySqlConnection cn = new MySqlConnection(_cs))
            {
                cn.Open();

                using (MySqlCommand cmd = new MySqlCommand(_RequeteSql, cn))
                {
                    MySqlDataReader rd = cmd.ExecuteReader();
                    if (rd.HasRows)
                    {
                        while (rd.Read())
                        {
                            ClsCmdFournisseur lg = new ClsCmdFournisseur();
                            try
                            {
                                lg.Somme = rd.GetDecimal(rd.GetOrdinal("somme"));
                            }
                            catch (Exception)
                            {
                                lg.Somme = 0;
                            }
                            cliste.Add(lg);
                        }
                    }
                    rd.Close();
                }
                cn.Close();
            }
            return(cliste);
        }
Пример #23
0
        public ProdutoVendaDTO ConsultarPorId(int idProduto)
        {
            string script = @"SELECT * FROM tb_produtoVenda WHERE id_produtoVenda = @id_produtoVenda";
            List <MySqlParameter> parms = new List <MySqlParameter>();

            parms.Add(new MySqlParameter("id_produtoVenda", idProduto));


            Database        db     = new Database();
            MySqlDataReader reader = db.ExecuteSelectScript(script, parms);

            ProdutoVendaDTO produto = new ProdutoVendaDTO();

            if (reader.Read())
            {
                produto.id_produtoVenda        = reader.GetInt32("id_produtoVenda");
                produto.nm_Produto             = reader.GetString("nm_Produto");
                produto.ds_Produto             = reader.GetString("ds_Produto");
                produto.vl_Venda               = reader.GetDecimal("vl_Venda");
                produto.dt_Validade            = reader.GetDateTime("dt_Validade");
                produto.fk_ProdutoVenda_Filial = reader.GetInt32("fk_ProdutoVenda_Filial");
            }

            reader.Close();
            return(produto);
        }
        public Product GetProduct(int id)
        {
            MySqlConnection conn = new MySqlConnection();

            conn.ConnectionString = System.IO.File.ReadAllText("ConnectionString.txt");

            MySqlCommand cmd = conn.CreateCommand();

            cmd.CommandText = "SELECT ProductID, Name, Price " +
                              "FROM products " +
                              "WHERE ProductId = @id;";
            cmd.Parameters.AddWithValue("id", id);

            using (conn)
            {
                conn.Open();

                MySqlDataReader reader = cmd.ExecuteReader();

                if (reader.Read())
                {
                    Product product = new Product();

                    product.Id    = reader.GetInt32("ProductID");
                    product.Name  = reader.GetString("Name");
                    product.Price = reader.GetDecimal("Price");

                    return(product);
                }
                else
                {
                    return(null);
                }
            }
        }
Пример #25
0
        public ArrayList RetreiveProductsFromDatabase()
        {
            ArrayList ProductsList = new ArrayList();

            using (MySqlConnection connection = new MySqlConnection(ConnectionString))
            {
                MySqlCommand command = new MySqlCommand("SELECT ProductID, ProductName, Price, ProductDetail FROM products ;", connection);
                connection.Open();

                MySqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        int     ProductID      = reader.GetInt32(0);
                        string  ProductName    = reader.GetString(1);
                        decimal ProductPrice   = reader.GetDecimal(2);
                        byte[]  ProductPicture = (byte[])reader[3];

                        ProductsList.Add(new Details()
                        {
                            ID = ProductID, Name = ProductName, Price = ProductPrice, Picture = ProductPicture
                        });
                    }
                }
                reader.Close();

                return(ProductsList);
            }
        }
Пример #26
0
 public static User convertDBtoUserWithManager(MySqlDataReader readerRow)
 {
     return(new User()
     {
         UserId = readerRow.GetInt32(0),
         UserName = readerRow.GetString(1),
         UserComputer = readerRow.IsDBNull(2) ? "" : readerRow.GetString(2),
         DepartmentId = readerRow.GetInt32(4),
         Email = readerRow.GetString(5),
         NumHoursWork = readerRow.GetDecimal(6),
         ManagerId = readerRow.IsDBNull(7) ? 0 : readerRow.GetInt32(7),
         DepartmentUser = new Models.DepartmentUser()
         {
             Id = readerRow.GetInt32(8),
             Department = readerRow.GetString(9)
         }
         ,
         Manager = new User()
         {
             UserId = readerRow.IsDBNull(10) ? 0 : readerRow.GetInt32(10),
             UserName = readerRow.IsDBNull(11) ? string.Empty : readerRow.GetString(11),
             Email = readerRow.IsDBNull(15) ? string.Empty : readerRow.GetString(15)
         }
     });
 }
Пример #27
0
        public ArrayList RetreiveAllSales()
        {
            ArrayList SalesList = new ArrayList();

            using (MySqlConnection connection = new MySqlConnection(ConnectionString))
            {
                MySqlCommand command = new MySqlCommand("SELECT SaleID, SaleDateTime, StaffID, GrandTotal FROM sales;", connection);
                connection.Open();

                MySqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        int      SaleID       = reader.GetInt32(0);
                        DateTime SaleTime     = reader.GetDateTime(1);
                        int      SalesmanID   = reader.GetInt32(2);
                        string   SalesmanName = ReturnUserName(SalesmanID);
                        decimal  TotalBill    = reader.GetDecimal(3);

                        SalesList.Add(new Details()
                        {
                            SaleID = SaleID, SaleTime = SaleTime, Name = SalesmanName, Total = TotalBill
                        });
                    }
                }
                reader.Close();

                return(SalesList);
            }
        }
        public List <Product> GetAllProducts()
        {
            MySqlConnection conn = new MySqlConnection();

            conn.ConnectionString = System.IO.File.ReadAllText("ConnectionString.txt");

            MySqlCommand cmd = conn.CreateCommand();

            cmd.CommandText = "SELECT ProductID, Name, Price FROM products;";

            using (conn)
            {
                conn.Open();

                MySqlDataReader reader = cmd.ExecuteReader();

                List <Product> products = new List <Product>();

                while (reader.Read())
                {
                    Product nextProduct = new Product();

                    nextProduct.Id    = reader.GetInt32("ProductID");
                    nextProduct.Name  = reader.GetString("Name");
                    nextProduct.Price = reader.GetDecimal("Price");

                    products.Add(nextProduct);
                }

                return(products);
            }
        }
Пример #29
0
        public ArrayList RetreiveAllProducts()
        {
            ArrayList ProductsList = new ArrayList();

            using (MySqlConnection connection = new MySqlConnection(ConnectionString))
            {
                MySqlCommand command = new MySqlCommand("SELECT ProductID, ProductName, ProductPrice, ProductCategoryID, ProductDescription, ProductImage FROM products;", connection);
                connection.Open();

                MySqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        int     ProductID           = reader.GetInt32(0);
                        string  ProductName         = reader.GetString(1);
                        decimal ProductPrice        = reader.GetDecimal(2);
                        int     ProductCategoryID   = reader.GetInt32(3);
                        string  ProductCategoryName = ReturnCategoryName(ProductCategoryID);
                        string  ProductDescription  = reader.GetString(4);
                        byte[]  ProductPicture      = (byte[])reader[5];

                        ProductsList.Add(new Details()
                        {
                            Name = ProductName, Price = ProductPrice, Category = ProductCategoryName, Description = ProductDescription, Picture = ProductPicture, ID = ProductID
                        });
                    }
                }
                reader.Close();

                return(ProductsList);
            }
        }
Пример #30
0
        public clsCaja CargaCierreAnterior(Int32 iCodSucursal, Int32 tipocaja)
        {
            clsCaja aper = null;

            try
            {
                con.conectarBD();
                cmd             = new MySqlCommand("MuestraCierreAnterior", con.conector);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("codsuc", iCodSucursal);
                cmd.Parameters.AddWithValue("tipo_ex", tipocaja);
                dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        aper             = new clsCaja();
                        aper.Montocierre = Convert.ToDecimal(dr.GetDecimal(0));
                    }
                }
                return(aper);
            }
            catch (MySqlException ex)
            {
                throw ex;
            }
            finally { con.conector.Dispose(); cmd.Dispose(); con.desconectarBD(); }
        }