Hora el codigo q la part de Pacienres
namespace DoctorPacientesBd{
public partial class ventanapacientes : Form{
static Conexionbd con = new Conexionbd();
public int ds = 0;
public ventanapacientes() {
InitializeComponent();
}
void limpiar(){
textdni.Text = genCodigo();
textname.Text = "";
textap.Text = "";
textdir.Text = "";
textcelu.Text = "";
textfono.Text = "";
}
public Boolean verifivarVAcios() {
if ( textname.Text == "" || textap.Text == "" || textdir.Text == "")
return false;
else
return true;
}
public void ValidarTxt(System.Windows.Forms.KeyPressEventArgs a){
if ((a.KeyChar >= 65 && a.KeyChar = 97 && a.KeyChar = 65 && a.KeyChar = 97 && a.KeyChar <= 122) || (a.KeyChar == 32) || (a.KeyChar == 8))
a.Handled = true;
else
a.Handled = false;
}
private void textname_KeyPress(object sender, KeyPressEventArgs e){
ValidarTxt(e);
}
private void textap_KeyPress(object sender, KeyPressEventArgs e){
ValidarTxt(e);
}
private void textcelu_KeyPress(object sender, KeyPressEventArgs e){
ValidarNumer(e);
}
private void textfono_KeyPress(object sender, KeyPressEventArgs e){
ValidarNumer(e);
}
public void retunDat(String f) {
String sent;
sent = "SELECT * FROM `paciente` WHERE idPaciente='" + f + "';";
object[,]g=con.ExecuteReader(sent);
textdni.Text=g[0,0].ToString();
textname.Text = g[0, 1].ToString();
textap.Text = g[0, 2].ToString();
returFecha(g[0,3].ToString());
textdir.Text = g[0, 4].ToString();
textfono.Text = g[0, 5].ToString();
textcelu.Text = g[0, 6].ToString();
}
void returFecha(String g) {
int dia, ao, mes;
ao = UInt16.Parse(g.Substring(6, 4));
mes = UInt16.Parse(g.Substring(3, 2));
dia = UInt16.Parse(g.Substring(0, 2));
dateTimePicker1.Value = new DateTime(ao, mes, dia);
}
String ObFecha() {
String f,d, m, a, fcha;
f = dateTimePicker1.Value.ToString();
d = f.Substring(0, 2);
m = f.Substring(3, 2);
a = f.Substring(6, 4);
fcha=a+"/"+m+"/"+d;
return fcha;
}
String genCodigo() {
String cod="",codb,consulta;
int co, i;
consulta = "SELECT idPaciente FROM `paciente` ORDER BY idPaciente DESC LIMIT 0,1;";
object[,] f = con.ExecuteReader(consulta);
codb = f[0, 0].ToString().Substring(1, 4);
co = UInt16.Parse(codb);
i = co;
i++;
if (i = 10) {
cod = "P00" + i.ToString();
}
else
if (i >= 100) {
cod = "P0" + i.ToString();
}
else
if (i >= 1000) {
cod = "P0" + i.ToString();
}
return cod;
}
Leer el resto de esta entrada »