コード例 #1
0
        protected void BTN_Consultar_Clik(object sender, EventArgs e)
        {
            NGCliente objNegocios = new NGCliente();
            Cliente objCliente = new Cliente();

            try
            {
                objCliente.ID = int.Parse(ID.Text);

                List<Cliente> objRetConsulta = objNegocios.Concultar(objCliente.ID);

                if (objRetConsulta.Count > 0)
                {
                    Nome.Text = objRetConsulta[0].Nome;
                    DataCadastro.Text = objRetConsulta[0].DataCadastro;
                    CNPJ.Text = objRetConsulta[0].CNPJ;
                }
                else {
                    IblMensagem.Text = "Registro não encontrado";
                }

            }
            catch(Exception ex)
            {
                IblMensagem.Text = ex.Message;
            }
        }
コード例 #2
0
ファイル: DBCliente.cs プロジェクト: dopaco/SistemaVenda
        public bool incluir(Cliente p_objCliente)
        {
            bool blnRetorno = false;
            string strSql = "INSERT INTO Cliente (Id ,Nome, DataCadastro ,CNPJ) VALUES(@pID, @pNome, @pDataCadastro, @pCNPJ)";

            List<SqlParameter> objParams = new List<SqlParameter>();
            objParams.Add(new SqlParameter("@pID", p_objCliente.ID));
            objParams.Add(new SqlParameter("@pNome", p_objCliente.Nome));
            objParams.Add(new SqlParameter("@pDataCadastro", p_objCliente.DataCadastro));
            objParams.Add(new SqlParameter("@pCNPJ", p_objCliente.CNPJ));

            blnRetorno = objConnManager.executarComando(strSql, objParams);

            return blnRetorno;
        }
コード例 #3
0
        protected void BTN_Incluir_Click(object sender, EventArgs e)
        {
            try
            {
                NGCliente objNegocios = new NGCliente();
                Cliente objCliente = new Cliente();

                objCliente.ID = int.Parse(ID.Text);
                objCliente.Nome = Nome.Text;
                objCliente.DataCadastro = DataCadastro.Text;
                objCliente.CNPJ = CNPJ.Text;

                IblMensagem.Text = (objNegocios.incluir(objCliente) ? "Registro incluido com sucesso" : "Erro na inclusão");

            }
            catch(Exception ex)
            {
                IblMensagem.Text = ex.Message;
            }
        }
コード例 #4
0
ファイル: DBCliente.cs プロジェクト: dopaco/SistemaVenda
        public List<Cliente> consultar(int p_intID)
        {
            string strSql = "Select id, nome, DataCadastro, CNPJ from Cliente where id= @pID";

            List<SqlParameter> objParams = new List<SqlParameter>();
            objParams.Add(new SqlParameter("@pID", p_intID));

            DataTable objTbCliente = objConnManager.retornarTabela(strSql, objParams, "Cliente");

            List<Cliente> objClientes = new List<Cliente>();
            foreach (DataRow row in objTbCliente.Rows)
            {
                Cliente objCliente = new Cliente();
                objCliente.ID = (int)row["ID"];
                objCliente.Nome = (string)row["Nome"];
                objCliente.DataCadastro = (string)row["DataCadastro"];
                objCliente.CNPJ = (string)row["CNPJ"];

                objClientes.Add(objCliente);
            }

            return objClientes;
        }
コード例 #5
0
ファイル: NGCliente.cs プロジェクト: dopaco/SistemaVenda
        public bool incluir(Cliente p_objCliente)
        {
            #region Validação de campos Obrigatorios
            if (p_objCliente.ID == int.MinValue)
            {
                throw new Exception("O campo ID é obrigatorio");
            }
            if (p_objCliente.Nome == string.Empty)
            {
                throw new Exception("O campo nome é obrigatorio");
            }
            if (p_objCliente.DataCadastro == string.Empty)
            {
                throw new Exception("O campo Data Cadastro é obrigatorio");
            }
            if (p_objCliente.CNPJ == string.Empty)
            {
                throw new Exception("O campo CNPJ é obrigatorio");
            }
            #endregion

            DBCliente objDados = new DBCliente();
            return objDados.incluir(p_objCliente);
        }