private void btnSave_Click(object sender, EventArgs e)
        {
            int i = -1;

            string[]     txt = new string[4];
            ValidTextBox vtb;

            foreach (Control con in Controls)
            {
                vtb = con as ValidTextBox;
                if (vtb != null)
                {
                    if (vtb.Text.Length == 0)
                    {
                        MessageBox.Show("Debes llenar los campos vacíos!");
                        return;
                    }
                    txt[++i] = vtb.Text;
                }
            }

            if (AdmPatient.IsRepeatData("tablePatient", "Cedula", txtCard.Text))
            {
                MessageBox.Show("La cedula " + txtCard.Text + " ya lo tiene un paciente.");
                return;
            }

            if (AdmPatient.Save(txt))
            {
                return;
            }

            ctuGridPatient.DgvPatient.Rows.Add(txtName.Text, txtSurname.Text, txtCard.Text, txtAge.Text);
            ctuGridPatient.SetCountPatient();
            foreach (Control con in Controls)
            {
                vtb = con as ValidTextBox;
                if (vtb != null)
                {
                    vtb.Clear();
                }
            }
        }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtDrug.Text.Length == 0 || ctuDrugs.TxtPrescription.Text.Length == 0)
            {
                MessageBox.Show("Debes llenar los campos vacíos.");
                return;
            }

            if (AdmPatient.IsRepeatData("tableRecipe", "Farmaco", txtDrug.Text))
            {
                MessageBox.Show("Ese farmaco ya lo tiene el paciente.");
                return;
            }

            if (AdmRecipe.Save(txtDrug.Text, ctuDrugs.TxtPrescription.Text, ctuDrugs.DtpDateDest.Value))
            {
                return;
            }
            ctuGridDrugs.DgvDrugs.Rows.Add(txtDrug.Text, ctuDrugs.TxtPrescription.Text, ctuDrugs.DtpDateDest.Value.ToShortDateString(), DateTime.Now.ToShortDateString());
            ctuGridDrugs.LblDrugs.Text = "Total de Farmacos: " + ctuGridDrugs.DgvDrugs.RowCount;
            txtDrug.Clear();
            ctuDrugs.TxtPrescription.Clear();
        }