示例#1
0
        public static PatInfoTable GetPat(int id)
        {
            PatInfoTable pat = new PatInfoTable();

            try
            {
                NpgsqlConnection myConnection = new NpgsqlConnection(cnStr);
                myConnection.Open();

                string        query   = "SELECT * FROM Patsient where id = @id";
                NpgsqlCommand command = new NpgsqlCommand(query, myConnection);
                command.Parameters.AddWithValue("@id", id);
                using (NpgsqlDataReader dr = command.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        pat = new PatInfoTable {
                            Id    = Int32.Parse(dr["id"].ToString()),
                            FIO   = dr["surname"].ToString() + " " + dr["name"].ToString() + " " + dr["otch"].ToString(),
                            Bdate = DateTime.Parse(dr["birthdate"].ToString()),
                            Pdate = DateTime.Parse(dr["date_post"].ToString()),
                            Diag  = dr["diag"].ToString()
                        };
                    }
                }
                myConnection.Close();
            }
            catch (Exception Ex)
            {
                MessageBox.Show("Ошибка GetPat: " + Ex.Message);
            }
            return(pat);
        }
示例#2
0
 public AddPatForm(PatInfoTable pat)
 {
     InitializeComponent();
     changeFormStatus();
     String[] splitStr = pat.FIO.Trim().Split(' ');
     delButton.Visible  = true;
     editButton.Visible = true;
     button1.Visible    = false;
     nametextbox.Text   = splitStr[1];
     surtextbox.Text    = splitStr[0];
     otchtextbox.Text   = splitStr[2];
     diagtextbox.Text   = pat.Diag;
     bdatepicker.Value  = pat.Bdate;
     pdatepicker.Value  = pat.Pdate;
     patId = pat.Id;
 }