Exemplo n.º 1
0
        public bool dbAlterarTipoDocumento(INFOTipoDocumento pObjTipoDocumento)
        {
            StringBuilder strSql = new StringBuilder();
            MySqlConnection objConn = null;
            MySqlCommand objCmd = null;

            try
            {
                strSql.Append(" UPDATE TIPODOCUMENTO SET ");
                strSql.Append(" NM_TIPODOCUMENTO =?nometipodocumento ");
                strSql.Append(" WHERE ID_TIPODOCUMENTO =?idtipodocumento");

                objConn = new MySqlConnection(gConnectionString);
                objConn.Open();
                objCmd = new MySqlCommand(strSql.ToString(), objConn);

                objCmd.Parameters.Add("?nometipodocumento", MySqlDbType.VarChar).Value = pObjTipoDocumento.NomeTipoDocumento.ToUpper();
                objCmd.Parameters.Add("?idtipodocumento", MySqlDbType.Double).Value = pObjTipoDocumento.IdTipoDocumento;

                return (objCmd.ExecuteNonQuery() > 0) ? true : false;

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                strSql = null;
            }
        }
Exemplo n.º 2
0
        public Boolean boInserirTipoDocumento(INFOTipoDocumento pObjTipoDocumento)
        {
            DAOTipoDocumento objDaoTipoDocumento = null;
            objDaoTipoDocumento = new DAOTipoDocumento();
            int i;
            try
            {
                List<INFOTipoDocumento> lstDaoObj = null;
                lstDaoObj = objDaoTipoDocumento.dbObterListaTipoDocumento();

                for (i = 0; i < lstDaoObj.Count; i++ ){

                     string aux = lstDaoObj[i].NomeTipoDocumento.ToUpper();
                     if (aux == pObjTipoDocumento.NomeTipoDocumento.ToUpper())
                     {
                         return false;
                     }

               }

                return objDaoTipoDocumento.dbInserirTipoDocumento(pObjTipoDocumento);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public Boolean boAtualizarTipoDocumento(INFOTipoDocumento pObjTipoDocumento)
        {
            DAOTipoDocumento objDaoTipoDocumento = null;
            objDaoTipoDocumento = new DAOTipoDocumento();
            //int i;
            try
            {
                //List<INFOTipoDocumento> lstDaoObj = null;
                //lstDaoObj = objDaoTipoDocumento.dbObterListaTipoDocumento();

                //for (i = 0; i < lstDaoObj.Count; i++)
                //{

                //    string aux = lstDaoObj[i].NomeTipoDocumento.ToUpper();
                //    if (aux == pObjTipoDocumento.NomeTipoDocumento.ToUpper())
                //    {
                //        return false;
                //    }

                //}

                return objDaoTipoDocumento.dbAlterarTipoDocumento(pObjTipoDocumento);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        //Se tiver algum item da list box selecionado e carregado na txtbox, atualiza o cadastro do cara.
        private void btnAtualizar_Click(object sender, EventArgs e)
        {
            BOTipoDocumento objBoTipoDocumento = null;
            INFOTipoDocumento objInfoTipoDocumento = null;
            try
            {
                if (string.IsNullOrEmpty(txtTipoDocumento.Text))
                {
                    MessageBox.Show("O campo de Cadastro de Tipo de Documentos não pode ser vazio!", Global.CODAPP + " - " + Global.DESCRICAOAPP,                                                   MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtTipoDocumento.Focus();
                }
                else {
                    objBoTipoDocumento = new BOTipoDocumento();
                    objInfoTipoDocumento = new INFOTipoDocumento();

                     objInfoTipoDocumento.NomeTipoDocumento = txtTipoDocumento.Text;
                     objInfoTipoDocumento.IdTipoDocumento = Convert.ToDouble(lbCodigo.Text);

                     if (objBoTipoDocumento.boAtualizarTipoDocumento(objInfoTipoDocumento))
                     {
                         MessageBox.Show("Cadastro alterado com sucesso!", Global.CODAPP + " - " + Global.DESCRICAOAPP, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                         btnAtualizar.Visible = false;
                         btnNovoCadastro.Visible = false;
                         txtTipoDocumento.Clear();
                         lbCodigo.Visible = false;
                         lbtxtcodigo.Visible = false;
                         btnCadastrar.Visible = true;
                         txtTipoDocumento.Focus();
                         ListViewLoad();
                     }
                     else
                     {
                         MessageBox.Show("Cadastro não efetuado, verifique se o item não está préviamente cadastrado", Global.CODAPP + " - " + Global.DESCRICAOAPP, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     }

                }

            }
            catch (Exception ex)
            {

                MessageBox.Show("ERRO: "+ ex.ToString(), Global.CODAPP + " - " + Global.DESCRICAOAPP, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 5
0
        public bool dbInserirTipoDocumento(INFOTipoDocumento objTipoDocumento)
        {
            StringBuilder strSQL = null;
            MySqlConnection objConn = null;
            MySqlCommand objCmd = null;

            try
            {
                strSQL = new StringBuilder();

                strSQL.AppendLine(" INSERT INTO tipodocumento ( NM_TIPODOCUMENTO )").
                       AppendLine(" VALUES ( ?nometipodocumento ) ");

                objConn = new MySqlConnection(gConnectionString);
                objConn.Open();
                objCmd = new MySqlCommand(strSQL.ToString(), objConn);

                objCmd.Parameters.Add("?nometipodocumento", MySqlDbType.VarChar).Value = objTipoDocumento.NomeTipoDocumento;

                return (objCmd.ExecuteNonQuery() > 0) ? true : false;

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (objCmd != null)
                {
                    objCmd.Dispose();
                    objCmd = null;
                }

                if (objConn.State == System.Data.ConnectionState.Open)
                {
                    objConn.Close();
                    objConn.Dispose();
                    objConn = null;
                }

                strSQL = null;
            }
        }
Exemplo n.º 6
0
        //------------ realiza o cadastro
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            BOTipoDocumento objBoTipoDocumento = null;
            INFOTipoDocumento objInfoTipoDocumento = null;
            try
            {
                if (string.IsNullOrEmpty(txtTipoDocumento.Text))
                {
                    MessageBox.Show("O campo de Cadastro de Tipo de Documentos não pode ser vazio!", Global.CODAPP + " - " + Global.DESCRICAOAPP,                                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtTipoDocumento.Focus();
                }
                else {
                    objBoTipoDocumento = new BOTipoDocumento();
                    objInfoTipoDocumento = new INFOTipoDocumento();

                     objInfoTipoDocumento.NomeTipoDocumento = txtTipoDocumento.Text;

                     if (objBoTipoDocumento.boInserirTipoDocumento(objInfoTipoDocumento))
                     {
                         MessageBox.Show("Novo Tipo de Documento alterados com sucesso!", Global.CODAPP + " - " + Global.DESCRICAOAPP, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                         txtTipoDocumento.Clear();
                         txtTipoDocumento.Focus();
                         ListViewLoad();
                     }
                     else
                     {
                         MessageBox.Show("Os cadastros devem ser únicos, verifique se o novo Tipo de Documento está previamente cadastrado no sistema", Global.CODAPP + " - " + Global.DESCRICAOAPP, MessageBoxButtons.OK, MessageBoxIcon.Warning);

                     }
                }

            }
            catch (Exception ex)
            {

                MessageBox.Show("ERRO: "+ ex.ToString(), Global.CODAPP + " - " + Global.DESCRICAOAPP, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 7
0
        public List<INFOTipoDocumento> dbObterListaTipoDocumento()
        {
            StringBuilder strSQL = null;
            MySqlConnection objConn = null;
               // MySqlCommand objCmd = null;
            MySqlDataReader objDr = null;
            INFOTipoDocumento objTipodocumento = null;
            List<INFOTipoDocumento> ListaTipoDocumento = null;
            try
            {
                strSQL = new StringBuilder();

                strSQL.AppendLine("SELECT ID_TIPODOCUMENTO, NM_TIPODOCUMENTO ");
                strSQL.AppendLine(" FROM tipodocumento  ");
                strSQL.AppendLine(" ORDER BY ID_TIPODOCUMENTO ");

                objConn = new MySqlConnection(gConnectionString);
                objDr = dbObterRegistros(objConn, strSQL.ToString(), null);

                if (objDr != null)
                {
                    while (objDr.Read())
                    {
                        objTipodocumento = new INFOTipoDocumento();

                        if (objDr["ID_TIPODOCUMENTO"] != DBNull.Value)
                        {
                            objTipodocumento.IdTipoDocumento = (double) objDr["ID_TIPODOCUMENTO"];
                        }

                        if (objDr["NM_TIPODOCUMENTO"] != DBNull.Value)
                        {
                            objTipodocumento.NomeTipoDocumento = (string)objDr["NM_TIPODOCUMENTO"];
                        }
                        else
                        {
                            objTipodocumento.NomeTipoDocumento = null;
                        }

                        if (ListaTipoDocumento == null) {
                            ListaTipoDocumento = new List<INFOTipoDocumento>();
                        }

                        ListaTipoDocumento.Add(objTipodocumento);
                    }
                }

                return ListaTipoDocumento;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                if (objDr != null)
                {
                    if (objDr.IsClosed == false)
                    {
                        objDr.Close();
                    }
                    objDr = null;
                }

                if (objConn.State == System.Data.ConnectionState.Open)
                {
                    objConn.Close();
                    objConn.Dispose();
                    objConn = null;
                }

                strSQL = null;
            }
        }