Пример #1
0
        public void Atualizar(Convenio c, int CodigoClinica)
        {
            using (FbConnection Con = new FbConnection(Firebird.StringConexao))
            {
                try
                {
                    Con.Open();

                    string TxtSQL = @"  UPDATE  
                                        CONVENIO
                                        SET
                                        C_DESCRICAO =@C_DESCRICAO,
                                        C_STATUS =@C_STATUS
                                        WHERE
                                        C_CODIGO =@C_CODIGO AND
                                        C_CLINICA =@C_CLINICA";

                    using (FbCommand cmdUpdate = new FbCommand(TxtSQL, Con))
                    {
                        cmdUpdate.Parameters.AddWithValue("C_DESCRICAO", c.Descricao);
                        cmdUpdate.Parameters.AddWithValue("C_STATUS", c.Status);
                        cmdUpdate.Parameters.AddWithValue("C_CODIGO", c.Codigo);
                        cmdUpdate.Parameters.AddWithValue("C_CLINICA", CodigoClinica);

                        cmdUpdate.ExecuteNonQuery();
                    }
                }
                finally
                {
                    Con.Close();
                }
            }
        }
Пример #2
0
        public void Cadastrar(Convenio c, int CodigoClinica)
        {
            using (FbConnection Con = new FbConnection(Firebird.StringConexao))
            {
                try
                {
                    Con.Open();

                    string TxtSQL = @"  INSERT
                                        INTO
                                        CONVENIO
                                        (
                                            C_CODIGO,
                                            C_DESCRICAO,
                                            C_STATUS,
                                            C_CLINICA
                                        )
                                        VALUES
                                        (
                                            @C_CODIGO,
                                            @C_DESCRICAO,
                                            @C_STATUS,
                                            @C_CLINICA
                                        )";

                    using (FbCommand cmdInsert = new FbCommand(TxtSQL, Con))
                    {
                        cmdInsert.Parameters.AddWithValue("C_CODIGO", GerarCodigo());
                        cmdInsert.Parameters.AddWithValue("C_CLINICA", CodigoClinica);
                        cmdInsert.Parameters.AddWithValue("C_DESCRICAO", c.Descricao);
                        cmdInsert.Parameters.AddWithValue("C_STATUS", "A");

                        cmdInsert.ExecuteNonQuery();
                    }
                }
                finally
                {
                    Con.Close();
                }
            }
        }