/*Запуск хранимой процедуры по проверке пользователя на существование в БД*/ public bool CheckUserExist(CPatient patient) { conn.Open(); bool init = false; NpgsqlTransaction t = conn.BeginTransaction(); NpgsqlCommand comm = new NpgsqlCommand("\"CheckUser2\"", conn); NpgsqlParameter ini = new NpgsqlParameter("ini", NpgsqlTypes.NpgsqlDbType.Varchar); NpgsqlParameter amb = new NpgsqlParameter("amb", NpgsqlTypes.NpgsqlDbType.Varchar); NpgsqlParameter sex = new NpgsqlParameter("sex", NpgsqlTypes.NpgsqlDbType.Varchar); NpgsqlParameter birth = new NpgsqlParameter("birth", NpgsqlTypes.NpgsqlDbType.Varchar); NpgsqlParameter child = new NpgsqlParameter("child", NpgsqlTypes.NpgsqlDbType.Varchar); NpgsqlParameter pid = new NpgsqlParameter("pid", NpgsqlTypes.NpgsqlDbType.Integer); ini.Direction = ParameterDirection.Input; amb.Direction = ParameterDirection.Input; sex.Direction = ParameterDirection.Input; birth.Direction = ParameterDirection.Input; child.Direction = ParameterDirection.Input; pid.Direction = ParameterDirection.Input; comm.Parameters.Add(ini); comm.Parameters.Add(amb); comm.Parameters.Add(sex); comm.Parameters.Add(birth); comm.Parameters.Add(child); comm.Parameters.Add(pid); comm.Parameters[0].Value = patient.initials.surname; comm.Parameters[1].Value = patient.amb_card; comm.Parameters[2].Value = patient.sex; comm.Parameters[3].Value = patient.birth_date.date; comm.Parameters[4].Value = patient.is_child; comm.Parameters[5].Value = patient.pid; comm.CommandType = CommandType.StoredProcedure; try { var result = comm.ExecuteScalar(); patient.pid = (int)result; if(patient.pid!=0) init=true; } finally { t.Commit(); conn.Close(); } return init; }
public void FillPatient(CPatient patient) { conn.Open(); NpgsqlTransaction t = conn.BeginTransaction(); NpgsqlCommand comm = new NpgsqlCommand("\"FillPatient2\"", conn); NpgsqlParameter pid = new NpgsqlParameter("pid", NpgsqlTypes.NpgsqlDbType.Integer); pid.Direction = ParameterDirection.Input; comm.Parameters.Add(pid); comm.Parameters[0].Value = patient.pid; comm.CommandType = CommandType.StoredProcedure; try { var result = comm.ExecuteScalar(); } finally { t.Commit(); conn.Close(); } }
public CStartForm() { InitializeComponent(); // system function tabed_window.SelectedTab = tabPage2; user = new User(); shadow = new CShadowService(); patient = new CPatient(); study = new CStudy(); protocol = new CProtocol(); patient.initials = new CInitials(); patient.birth_date = new CBirthDate(); shadow.win = new MakeaWindowPrm(); shadow.sql = new SQLDaemon(FileReader(path)); shadow.box = new CStateBox(); shadow.box.locker = new object(); }