0% found this document useful (0 votes)
28 views3 pages

Algotmos

This document contains code for a Windows Forms application in C# that manages pharmaceutical records. It includes code to: 1) Clear existing items and open a file dialog to load text records from a selected file into a list. 2) Clear an input text box when a "New" button is clicked. 3) Accept user input of multiple records, split each into fields, and add the fields to separate lists to display the records. Dates are converted and days until expiration/manufacture are calculated.

Uploaded by

judith chura
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views3 pages

Algotmos

This document contains code for a Windows Forms application in C# that manages pharmaceutical records. It includes code to: 1) Clear existing items and open a file dialog to load text records from a selected file into a list. 2) Clear an input text box when a "New" button is clicked. 3) Accept user input of multiple records, split each into fields, and add the fields to separate lists to display the records. Dates are converted and days until expiration/manufacture are calculated.

Uploaded by

judith chura
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.IO;

namespace Py_Farmacia
{
public partial class frmCntlMed : Form
{
public frmCntlMed()
{
InitializeComponent();
}

private void btnLeerArchivo_Click(object sender, EventArgs e)


{
this.lstRegistro.Items.Clear();
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Archivo txt (*.txt)|*.txt|All(*,*)|*,*";
try
{
open.ShowDialog();
StreamReader import = new StreamReader(Convert.ToString(open.FileName));
while (import.Peek() >= 0)
{
lstRegistro.Items.Add(Convert.ToString(import.ReadLine()));
}
}
catch (Exception ex)
{
MessageBox.Show(Convert.ToString(ex.Message));
return;
}

private void button2_Click(object sender, EventArgs e)


{
Close();
}

private void btnNuevo_Click(object sender, EventArgs e)


{
txtCantReg.Clear();
}

private void button3_Click(object sender, EventArgs e)


{
int cantReg, regLong, k;
string[] vRegistro;
string registro, palabra, letra;

cantReg = Int32.Parse(txtCantReg.Text);

vRegistro = new string[cantReg];


for (int i = 1; i <= cantReg; i++)
{
registro = Microsoft.VisualBasic.Interaction.InputBox("Ingrese el registro N :" + i, "Entrada de
registros");

vRegistro[i - 1] = registro;
lstRegistro.Items.Add(vRegistro[i - 1]);

regLong = registro.Length;

k = 1;
palabra = "";
for (int j = 0; j < regLong; j++)
{
letra = registro.Substring(j, 1);
if (letra == "," || k == 5)
{

switch (k)
{
case 1:
lstLaboratorio.Items.Add(palabra);
palabra = "";
k++;
break;
case 2:
lstProducto.Items.Add(palabra);
palabra = "";
k++;
break;
case 3:
lstPresentacin.Items.Add(palabra);
palabra = "";
k++;
break;
case 4:
lstFecFab.Items.Add(palabra);
DateTime fecFab = Convert.ToDateTime(palabra);

int diasFab = (DateTime.Today.Date.Year - fecFab.Year) * 365;


lstDiasFab.Items.Add(Convert.ToString(diasFab));
palabra = "";
k++;
break;
case 5:
palabra = registro.Substring(j, regLong - j);
lstFecVen.Items.Add(palabra);
j = regLong;
// Hallar el tiempo de vencimiento
DateTime fecVen = Convert.ToDateTime(palabra);
int diasVen = (DateTime.Today.Date.Year - fecVen.Year) * 365;
lstDiasVen.Items.Add(Convert.ToString(diasVen));
if (diasVen >= 0)
{
lstVencido.Items.Add("SI");
}
else
{
lstVencido.Items.Add("NO");
}
break;
}
}
else
{
palabra = palabra + letra;
}

}
}
}

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)


{

}
}
}

You might also like