Example #1
0
        public Prod getBd(Infos obj)
        {
            if (obj == null)
            {
                return(null);
            }
            var item = new Prod();

            String sql = $"select prod_descrpdv, prod_codbarras from produtos where prod_codigo = {obj.codProd} ";

            NpgsqlConnection connBd = new NpgsqlConnection("Server = 192.168.1.100; Port = 5432; " +
                                                           "Database = interativo; User Id = postgres;" +
                                                           " Password = 123456");

            var cmd = new NpgsqlCommand(sql, connBd);

            try
            {
                connBd.Open();
            }
            catch (Exception e)
            {
                MessageBox.Show($"Erro: {e}", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            var dr = cmd.ExecuteReader();



            if (dr.Read())
            {
                item.codDesc = dr.GetSafeValue <String>("prod_descrpdv");
                item.codBar  = dr.GetSafeValue <String>("prod_codbarras");

                return(item);
            }

            else
            {
                return(item);
            }
        }
Example #2
0
        public Infos getInformations()
        {
            var objInf = new Infos();

            if (!String.IsNullOrEmpty(txtCod.Text))
            {
                objInf.codProd = txtCod.Text;
            }
            else
            {
                MessageBox.Show("Campo código do produto obrigatório", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(null);
            }

            if (!String.IsNullOrEmpty(txtTara.Text))
            {
                if (Convert.ToDouble(txtTara.Text) > 0)
                {
                    objInf.pesoTara = Convert.ToDouble(txtTara.Text);
                }
            }

            else
            {
                objInf.pesoTara = 0;
            }


            if (Convert.ToDouble(txtQtd.Value) > 0)
            {
                objInf.qtdeCaixa = Convert.ToInt32(txtQtd.Value);
                objInf.pesoTara  = objInf.pesoTara * objInf.qtdeCaixa;
            }
            else
            {
                objInf.qtdeCaixa = 0;
            }


            return(objInf);
        }