Пример #1
0
        /// <summary>
        /// Lista os cálculos de IMC realizados para o paciente.
        /// </summary>
        /// <param name="codigoPaciente">Código do paciente.</param>
        /// <returns>Um DataSet tipado contendo os dados dos cálculos.</returns>
        public CalculoIMCDs ListarCalculosIMC(int codigoPaciente)
        {
            SqlConnection conn         = new SqlConnection(this.connectionStr);
            CalculoIMCDs  calculoIMCDs = new CalculoIMCDs();

            try
            {
                SqlDataAdapter adapter = new SqlDataAdapter("ListarCalculosIMC", conn);
                adapter.SelectCommand.CommandType = CommandType.StoredProcedure;

                // parâmetros
                adapter.SelectCommand.Parameters.Add("@CodigoPaciente", SqlDbType.Int).Value = codigoPaciente;

                // preenche dataSet
                adapter.Fill(calculoIMCDs, calculoIMCDs.CalculoIMC.TableName);
            }
            catch
            {
                throw;
            }
            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }

            return(calculoIMCDs);
        }
Пример #2
0
        public override global::System.Data.DataSet Clone()
        {
            CalculoIMCDs cln = ((CalculoIMCDs)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Пример #3
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            CalculoIMCDs ds = new CalculoIMCDs();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
Пример #4
0
        /// <summary>
        /// Busca por um cálculo do IMC.
        /// </summary>
        /// <param name="codigoCalculoIMC">Código do cálculo do IMC.</param>
        /// <returns>Um DataSet tipado contendo os dados do cálculo do IMC.</returns>
        public CalculoIMCDs.CalculoIMCRow BuscarCalculoIMC(int codigoCalculoIMC)
        {
            SqlConnection conn = new SqlConnection(this.connectionStr);

            try
            {
                SqlDataAdapter adapter = new SqlDataAdapter("BuscarCalculoIMC", conn);
                adapter.SelectCommand.CommandType = CommandType.StoredProcedure;

                // parâmetro
                adapter.SelectCommand.Parameters.Add("@CodigoCalculoIMC", SqlDbType.Int).Value = codigoCalculoIMC;

                // cria dataSet
                CalculoIMCDs calculoIMCDs = new CalculoIMCDs();

                // preenche dataSet
                adapter.Fill(calculoIMCDs, calculoIMCDs.CalculoIMC.TableName);

                if (calculoIMCDs.CalculoIMC.Count == 0)
                {
                    throw new Exception("MSG0032");
                }

                // retorna IMC
                return(calculoIMCDs.CalculoIMC[0]);
            }
            catch
            {
                throw;
            }
            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Lista cálculos de IMC do paciente.
        /// </summary>
        /// <param name="codigoPaciente">Código do paciente.</param>
        private void ListarCalculosIMC(int codigoPaciente)
        {
            // modifica cursor
            Cursor.Current = Cursors.WaitCursor;

            // trava busca
            this.travarBusca = true;

            // desabilita botão
            this.btnExcluir.Enabled = false;

            try
            {
                // componente de negócio
                PacienteBc pacienteBc = new PacienteBc();

                // busca pelo paciente
                this.pacienteRow = pacienteBc.BuscarPaciente(codigoPaciente);

                // nome do paciente
                this.txtPaciente.Text = this.pacienteRow.Nome;

                // lista cálculos
                CalculoIMCDs calculoIMCDs = pacienteBc.ListarCalculosIMC(this.pacienteRow.CodigoPaciente);

                // lista cálculos de IMC
                this.lstCalculos.DataSource    = calculoIMCDs.CalculoIMC;
                this.lstCalculos.DisplayMember = "Data";
                this.lstCalculos.ValueMember   = "CodigoCalculoIMC";
            }
            catch (Exception ex)
            {
                string strMessage = this.resourceMgr.GetString(ex.Message);

                if (strMessage == null)
                {
                    FrmErro frmErro = new FrmErro();
                    frmErro.Mensagem = ex.Message;
                    frmErro.ShowDialog(this);
                    frmErro.Dispose();
                }
                else
                {
                    FrmErro frmErro = new FrmErro();
                    frmErro.Mensagem = strMessage;
                    frmErro.ShowDialog(this);
                    frmErro.Dispose();
                }
            }
            finally
            {
                Cursor.Current = Cursors.Default;

                // destrava busca
                this.travarBusca = false;
            }

            // seleciona cálculo
            if (this.lstCalculos.SelectedItems.Count > 0)
            {
                this.lstCalculos_SelectedIndexChanged(this.lstCalculos, new EventArgs());
            }
        }
Пример #6
0
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                CalculoIMCDs ds = new CalculoIMCDs();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "CalculoIMCDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }