Exemple #1
0
        /// <summary>
        /// Этот метод делает запрос к базе данных, обновляя информацию о пациентах
        /// в объектной модели пациентов
        /// </summary>
        /// 
        public void RefreshData()
        {
            string connectionStr = "Server=127.0.0.1;Port=5432;User Id="username";Password="******";Database=medex;";
            string commandStr = "select * from patients;";

            try
            {
                mDBConnection = new NpgsqlConnection(connectionStr);
                mDBConnection.Open();
                NpgsqlCommand command = new NpgsqlCommand(commandStr, mDBConnection);
                NpgsqlDataReader dataReader = command.ExecuteReader();

                mPatients.Clear();
                while (dataReader.Read())
                {
                    string idStr = dataReader[0].ToString();
                    string nameStr = dataReader[1].ToString();
                    Patient newPatient = new Patient(
                            Convert.ToInt32(idStr),
                            nameStr);
                    mPatients.Add(newPatient);
                }

                mDBConnection.Close();
            }
            catch (Exception exception)
            {
                 Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
            }
        }
Exemple #2
0
        public List<string> getDiagById(int _thisId)
        {
            NpgsqlCommand selDiDa = new NpgsqlCommand("select diag, trim(name), trim(ds), mid_grp, sub_grp, sel_grp from diags where diag = '" + _thisId + "' ", DBExchange.Inst.connectDb);
            diagNumList = new List<int>();
            List<string> listDiagDescr = new List<string>();

            try
            {
                NpgsqlDataReader readData = selDiDa.ExecuteReader();
                int colNum = readData.FieldCount;
                while (readData.Read())
                {
                    string document = (string)readData[2] + " " + (string)readData[1];
                    listDiagDescr.Add(document);
                    diagNumList.Add((int)readData[0]);

                }

            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
            }
            return listDiagDescr;
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string pass = this.textBox1.Text.Trim();
            try
            {
                if (textBox2.Text == textBox3.Text)
                {

                    if (DBExchange.Inst.checkUserPassword(pass) == true)
                    {
                        string password = textBox3.Text.Trim();
                        DBExchange.Inst.changePass(password);
                        FormChangePassword.ActiveForm.Close();

                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("Старый пароль введён не правильно");
                    }
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Новый пароль не соответствует проверке");
                }
            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

            }
        }
Exemple #4
0
        public List<string> fillDiagTypeList()
        {
            NpgsqlCommand selDiDa = new NpgsqlCommand("select trim(diag) from diag_type order by id ", DBExchange.Inst.connectDb);
            List<string> listDiagDescr = new List<string>();

            try
            {
                NpgsqlDataReader readData = selDiDa.ExecuteReader();
                int colNum = readData.FieldCount;
                while (readData.Read())
                {
                    string document = (string)readData[0] ;
                    listDiagDescr.Add(document);
                }

            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

            }
            return listDiagDescr;
        }
Exemple #5
0
        public List<string> fillSchemeAllDrugs()
        {
            tlFullDrugList = new DataTable();
            NpgsqlDataAdapter selDrugs = new NpgsqlDataAdapter("Select drug_name, drug_id from drug order by drug_name Asc ", DBExchange.Inst.connectDb);
            List<string> listAllDrugs = new List<string>();

            try
            {
                selDrugs.Fill(tlFullDrugList);

                foreach (DataRow row in tlFullDrugList.Rows)
                {
                    listAllDrugs.Add((string)row[0]);
                }

            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

            }
            return listAllDrugs;
        }
Exemple #6
0
        public List<string> fillListSurgeryEtap(int pidn)
        {
            tlPatientEtap = new DataTable();
            NpgsqlDataAdapter selPatEtaps = new NpgsqlDataAdapter("Select line_id, line_start, line_stop, line_name from treatment_step where pat_id = " + pidn + " order by current_date Asc ", DBExchange.Inst.connectDb);
            List<string> listSurgeryEtap = new List<string>();

            try
            {
                selPatEtaps.Fill(tlPatientEtap);

                foreach (DataRow row in tlPatientEtap.Rows)
                {
                    listSurgeryEtap.Add(((DateTime)row[1]).ToShortDateString() + " " + ((DateTime)row[2]).ToShortDateString() + " " + ((string)row[3]));
                }

            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

            }
            return listSurgeryEtap;
        }
Exemple #7
0
        private void setStreet()
        {
            try

            {
               valStreet = Convert.ToInt16(this.StreetBox.SelectedIndex);
            }
            catch
            { }
            if (valStreet == -1)
            {
                String txtStreet = this.StreetBox.Text;
                if (txtStreet != null)
                {
                    try
                    {

                        NpgsqlCommand selStr = new NpgsqlCommand("Select serial from streets where city = '"+valCity+"' and UPPER(addr) = '%" + txtStreet.ToUpper() + "%';", DBExchange.Inst.connectDb);
                        try
                        {
                            Int32 StrAddr = (Int32)selStr.ExecuteScalar();
                        }
                        catch
                        //  if (StrAddr == 0)

                        //  {if (valRayon)

                        {
                            if ((MessageBox.Show("добавить адрес в справочник? " + CityBox.Text + " " + StreetBox.Text , "Улица не найдена", MessageBoxButtons.YesNo)) == DialogResult.Yes)
                            {

                                NpgsqlCommand insStr = new NpgsqlCommand("Insert into streets (addr, city) Values ('" + txtStreet + "','" + lstCiId[this.CityBox.SelectedIndex] + "');", DBExchange.Inst.connectDb);
                            insStr.ExecuteNonQuery();

                            }
                        }
                        finally
                        {

                        }

                        chngCity(Convert.ToInt16(this.CityBox.SelectedIndex));

                        }

                    catch (Exception exception)
                    {
                        Warnings.WarnLog log = new Warnings.WarnLog();
                        log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

                    }
                }
                else
                {
                    valStreet = Convert.ToInt32(lstStId[valStreet]);
                }
               }

            updateAddrText();
        }
Exemple #8
0
        private void createUpdatePatientString()
        {
            try
            {
            string sqlString = "";

            DataTable wrTbl = DBExchange.Inst.writeNewPatient;

            if (wrTbl.Rows[0]["family_name"].ToString().Trim() != tblPatient.Rows[0]["family_name"].ToString().Trim())
            {
                sqlString = " family_name = '" + wrTbl.Rows[0]["family_name"].ToString().Trim() + "' , ";
            }
            else
            {
            }

            if (wrTbl.Rows[0]["first_name"].ToString().Trim() != tblPatient.Rows[0]["first_name"].ToString().Trim())
            {
                sqlString = sqlString + " first_name = '" + wrTbl.Rows[0]["first_name"].ToString().Trim() + "', ";
            }
            else
            {
            }
            if (wrTbl.Rows[0]["last_name"].ToString().Trim() != tblPatient.Rows[0]["last_name"].ToString().Trim())
            {
                sqlString = sqlString + "last_name = '" + wrTbl.Rows[0]["last_name"].ToString().Trim() + "', ";
            }
            else
            {
            }
            if (wrTbl.Rows[0]["comment"].ToString().Trim() != tblPatient.Rows[0]["comment"].ToString().Trim())
            {
                sqlString = sqlString + "comment = '" + wrTbl.Rows[0]["comment"].ToString().Trim() + "', ";
            }
            else
            {
            }
            if (wrTbl.Rows[0]["trust_man"].ToString().Trim() != tblPatient.Rows[0]["trust_man"].ToString().Trim())
            {
                sqlString = sqlString + "trust_man = '" + wrTbl.Rows[0]["trust_man"].ToString().Trim() + "', ";
            }
            else
            {
            }
            if (wrTbl.Rows[0]["trust_phone"].ToString().Trim() != tblPatient.Rows[0]["trust_phone"].ToString().Trim())
            {
                sqlString = sqlString + "trust_phone = '" + wrTbl.Rows[0]["trust_phone"].ToString().Trim() + "', ";
            }
            else
            {
            }
            if (wrTbl.Rows[0]["phone1"].ToString().Trim() != tblPatient.Rows[0]["phone1"].ToString().Trim())
            {
                sqlString = sqlString + "phone1 = '" + wrTbl.Rows[0]["phone1"] + "', ";
            }
            else
            {
            }
            if (wrTbl.Rows[0]["phone2"].ToString().Trim() != tblPatient.Rows[0]["phone2"].ToString().Trim())
            {
                sqlString = sqlString + "phone2 = '" + wrTbl.Rows[0]["phone2"] + "', ";
            }
            else
            {
            }
            if (wrTbl.Rows[0]["phone3"].ToString().Trim() != tblPatient.Rows[0]["phone3"].ToString().Trim())
            {
                sqlString = sqlString + "phone3 = '" + wrTbl.Rows[0]["phone3"] + "', ";
            }
            else
            {
            }
            if (wrTbl.Rows[0]["nib"].ToString().Trim() != tblPatient.Rows[0]["nib"].ToString().Trim())
            {
                sqlString = sqlString + "nib = '" + wrTbl.Rows[0]["nib"] + "', ";
            }
            else
            {
            }
            if (wrTbl.Rows[0]["birth_date"].ToString().Trim() != tblPatient.Rows[0]["birth_date"].ToString().Trim())
            {
                sqlString = sqlString + "birth_date = '" + wrTbl.Rows[0]["birth_date"] + "', ";
            }
            else
            {
            }
            if (wrTbl.Rows[0]["pass"].ToString().Trim() != tblPatient.Rows[0]["pass"].ToString().Trim())
            {
                sqlString = sqlString + "pass = '******', doc_ser ='" + wrTbl.Rows[0]["doc_ser"] +
                    "', doc_num ='" + wrTbl.Rows[0]["doc_num"] + "', doc_org ='" + wrTbl.Rows[0]["doc_org"] + "', doc_date ='" + wrTbl.Rows[0]["doc_date"] + "', ";
            }
            else
            {
            }
            if (wrTbl.Rows[0]["doc_date"].ToString().Trim() != tblPatient.Rows[0]["doc_date"].ToString().Trim())
            {
                sqlString += " doc_date ='" + wrTbl.Rows[0]["doc_date"] + "', ";
            }
            if (wrTbl.Rows[0]["doc_org"].ToString().Trim() != tblPatient.Rows[0]["doc_org"].ToString().Trim())
            {
                sqlString += " doc_org ='" + wrTbl.Rows[0]["doc_org"] + "', ";
            }

            if (wrTbl.Rows[0]["is_man"].ToString().Trim() != tblPatient.Rows[0]["is_man"].ToString().Trim())
            {
                sqlString = sqlString + "is_man = '" + wrTbl.Rows[0]["is_man"] + "', ";
            }
            else
            {
            }
            if (wrTbl.Rows[0]["region1"].ToString().Trim() != tblPatient.Rows[0]["region1"].ToString().Trim())
            {
                sqlString = sqlString + "region1 = '" + wrTbl.Rows[0]["region1"] + "', ";
            }
            else
            {
            }
            if (wrTbl.Rows[0]["state"].ToString().Trim() != tblPatient.Rows[0]["state"].ToString().Trim())
            {
                sqlString = sqlString + "state = '" + wrTbl.Rows[0]["state"] + "', ";
            }

            if (wrTbl.Rows[0]["country"].ToString().Trim() != tblPatient.Rows[0]["country"].ToString().Trim())
            {
                sqlString = sqlString + "country = '" + wrTbl.Rows[0]["country"] + "', ";
            }

            if (wrTbl.Rows[0]["town_id"].ToString().Trim() != tblPatient.Rows[0]["town_id"].ToString().Trim())
            {
                sqlString = sqlString + "town_id = '" + wrTbl.Rows[0]["town_id"] + "', ";
            }

            if (wrTbl.Rows[0]["area"].ToString().Trim() != tblPatient.Rows[0]["area"].ToString().Trim())
            {
                sqlString = sqlString + "area = '" + wrTbl.Rows[0]["area"] + "', ";
            }

            if (wrTbl.Rows[0]["street_n"].ToString().Trim() != tblPatient.Rows[0]["street_n"].ToString().Trim())
            {
                sqlString = sqlString + "street_n = '" + wrTbl.Rows[0]["street_n"] + "', ";
            }

            if (wrTbl.Rows[0]["house"].ToString().Trim() != tblPatient.Rows[0]["house"].ToString().Trim())
            {
                sqlString = sqlString + "house = '" + wrTbl.Rows[0]["house"] + "', ";
            }

            if (wrTbl.Rows[0]["building"].ToString().Trim() != tblPatient.Rows[0]["building"].ToString().Trim())
            {
                sqlString = sqlString + "building = '" + wrTbl.Rows[0]["building"] + "', ";
            }

            if (wrTbl.Rows[0]["flat"].ToString().Trim() != tblPatient.Rows[0]["flat"].ToString().Trim())
            {
                sqlString = sqlString + "flat = '" + wrTbl.Rows[0]["flat"] + "', ";
            }

            if (wrTbl.Rows[0]["address"].ToString().Trim() != tblPatient.Rows[0]["address"].ToString().Trim())
            {
                sqlString = sqlString + "address = '" + wrTbl.Rows[0]["address"].ToString().Trim() + "' ,";
            }
            if (wrTbl.Rows[0]["snils"].ToString().Trim() != tblPatient.Rows[0]["snils"].ToString().Trim())
            {
                sqlString = sqlString + "snils = '" + wrTbl.Rows[0]["snils"].ToString().Trim() + "' ,";
            }

                sqlString = sqlString + " creator_id = '" + DBExchange.Inst.dbUsrId + "' ";

                sqlString = "UPDATE patient_list SET " + sqlString + " where pat_id = '" + gotPatientId + "'";

                DBExchange.Inst.execSqlCommand(sqlString);
            }
            catch (Exception exception)
            {
                 Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
            }
            finally
            {

            }
        }
Exemple #9
0
        private void changeRegion(Int16 regionItem)
        {
            Int16 reId = Convert.ToInt16(lstReId[regionItem]);
            valRegion = reId;
            List<string> lstCity = new List<string>();
            lstCiId = new List<string>();
            try
            {

                foreach (DataRow row in DBExchange.Inst.tblCities.Select("c_id='"+reId+"'"))
                {
                    lstCity.Add(((string)row["text_value"]).Trim());
                    lstCiId.Add(Convert.ToString(row["int_value"]));

                }
                this.CityBox.DataSource = lstCity;
            }
            catch (Exception exception)
            {
                 Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
            }

            this.CityBox.Invalidate();
            chngRayon(0);
              //       chngCity(0);
        }
Exemple #10
0
        //формирует запрос в баззу данных
        private void insCytZ()
        {
            int PatientId = this.searchPatientBox1.pIdN;
            DateTime aDate = DateTime.Now;

            try
            {
                string nomer = this.textBox1.Text.Trim();

                string textZakl = this.richTextBox1.Text.Trim();
                string hheader = this.textBox2.Text.Trim();

                try
                {

                NpgsqlCommand insRow = new NpgsqlCommand("Insert into diag_data_rg (doc_out, date_out, descr, pat_id, nomer, header) VALUES ('"
                    + Convert.ToInt16(DBExchange.Inst.dbUsrId) + "','" + aDate.ToShortDateString() + "', :zakl ,'" + PatientId + "','" + nomer + "', :head );", cdbo);

                using (insRow)
                {
                    insRow.Parameters.Add(new NpgsqlParameter("zakl", NpgsqlDbType.Text));
                    insRow.Parameters[0].Direction = ParameterDirection.Input;
                    insRow.Parameters[0].Value = textZakl;
                    insRow.Parameters.Add(new NpgsqlParameter("head", NpgsqlDbType.Varchar, 100));
                    insRow.Parameters[1].Direction = ParameterDirection.Input;
                    insRow.Parameters[1].Value = hheader;
                }

                    insRow.ExecuteNonQuery();
                    documWritten = true;
                    clearForm();
                }
                catch (Exception exception)
                {
                     Warnings.WarnLog log = new Warnings.WarnLog();
                    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

                }

            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("В поле номер допустимы только цифры");
            }
        }
Exemple #11
0
        /// <summary>
        /// Получает список всех документов по выбранному пациенту для передачи их в карту пациента - все записи.
        /// из полученной таблицы затем выбираются данные для вкладок обследования, исследования и назначения
        /// </summary>
        public void loadPatientDocuments()
        {
            try{

               NpgsqlDataAdapter dbKL = new NpgsqlDataAdapter("SELECT * FROM documents WHERE patient_id = '" + selectedPatientId + "' order by document_id DESC;", connectDb);

               DataSet dsOnk = new DataSet();
               tblPatientDocs = dsOnk.Tables.Add("db_patient_documents");
               dbKL.Fill(tblPatientDocs);

               }
               catch (Exception exception)
               {
                Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
               }
        }
Exemple #12
0
        /// <summary>
        /// Заполнение журнала пользователя последними, созданными им, документами.
        /// </summary>
        //public void FillJournalList()
        //{
        //    try
        //    {
        //        NpgsqlDataAdapter dbJour = new NpgsqlDataAdapter("SELECT document_date, (Select descr from docum_type where did = documents.document_type) as document,"
        //          + "(Select family_name From patient_list Where patient_list.pat_id = documents.pat_id) as pat_name, "
        //        + "document_number FROM documents WHERE doc_id= '" + dbUsrId + "'ORDER BY document_date DESC LIMIT 50;", connectDb);
        //        tblJournal = dsOnk.Tables.Add("db_journal");
        //        dbJour.Fill(tblJournal);
        //        //   dsOnk.WriteXml("data/journal.xml");
        //    }
        //    catch (Exception exception)
        //    {
        //         Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
        //    }
        //}
        //Заполнение журнала пользователя
        public void getUsrJournal(Int32 _usrId)
        {
            DataSet dsOnk = new DataSet();
               try
               {
               NpgsqlDataAdapter dbJour = new NpgsqlDataAdapter("SELECT document_date, trim(dt.descr) as document,"
                  + "trim(pt.family_name) as pat_name, document_number , document_type FROM documents doc, docum_type dt, patient_list pt WHERE doc_id= '"
                  + _usrId + "' AND delete = false and dt.did = doc.document_type "
                  + " and pt.pat_id = doc.pat_id ORDER BY document_date DESC LIMIT 30;", connectDb);

               tblJournal = dsOnk.Tables.Add("db_journal");
               tblWorkJournal = dsOnk.Tables.Add("db_work_journal");
               dbJour.Fill(tblWorkJournal);
               tblJournal = tblWorkJournal.Copy();
               tblJournal.Columns.Remove("document_number");
               tblJournal.Columns.Remove("document_type");
               }
               catch (Exception exception)
               {
                Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
               }
        }
Exemple #13
0
        public void chkStreetAddr()
        {
            DataSet dsOnk = new DataSet();
               try
               {

               dsOnk.ReadXml("data/street.xml");
               Int32 dsOnkStreetCount = dsOnk.Tables["street"].Rows.Count;
               DataTable countStreet = dsOnk.Tables.Add("count_street");
               try
               {

                   NpgsqlDataAdapter selCountStreet = new NpgsqlDataAdapter("SELECT count(*) FROM streets;", connectDb);

                   selCountStreet.Fill(countStreet);
               }
               catch (Exception exception)
               {
                    Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
               }

               Int32 streetCount = Convert.ToInt32(countStreet.Rows[0]["count"]);
               if (streetCount != dsOnkStreetCount)
               {
                   chkStreetAddr();
               }

               }
               catch
               {
               chkStreetAddr();
               }
               finally
               {
               tblStreet = dsOnk.Tables["street"];
               }
        }
Exemple #14
0
        /// <summary>
        /// Загрузка регионов
        /// </summary>
        public void chkRegion()
        {
            DataSet dsOnk = new DataSet();
               try
               {

               NpgsqlDataAdapter gRe = new NpgsqlDataAdapter("SELECT * FROM region order by int_value asc;", connectDb);
               tblRegion = dsOnk.Tables.Add("region");
               gRe.Fill(tblRegion);

               NpgsqlDataAdapter gOk = new NpgsqlDataAdapter("SELECT * FROM state order by int_value;", connectDb);
               tblState = dsOnk.Tables.Add("state");
               gOk.Fill(tblState);

               NpgsqlDataAdapter gCo = new NpgsqlDataAdapter("SELECT * FROM country order by int_value asc ;", connectDb);
               tblCountry = dsOnk.Tables.Add("country");
               gCo.Fill(tblCountry);

               NpgsqlDataAdapter gCi = new NpgsqlDataAdapter("SELECT text_value,c_id,int_value FROM towns order by text_value ASC;", connectDb);
               tblCities = dsOnk.Tables.Add("city");
               gCi.Fill(tblCities);

               NpgsqlDataAdapter gRa = new NpgsqlDataAdapter("SELECT text_value,int_value,c_id FROM area WHERE c_id = 7801 order by int_value;", connectDb);
               tblArea = dsOnk.Tables.Add("area");
               gRa.Fill(tblArea);
               }
               catch (Exception exception)
               {
                Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
               }

               ///dsOnk.WriteXml("data/livin.xml");
        }
Exemple #15
0
        //проверка пациента по имени и году
        public void chkPatByYearName(DateTime birthdate, String family, String name, String surname, Int16 city)
        {
            chkPassport = false;

               NpgsqlCommand chkNamePat = new NpgsqlCommand("Select pat_id FROM patient_list WHERE family_name = '" + family + "' AND birth_date = '" + birthdate + "' AND gorod_n = '" + city + "' AND first_name = '" + name + "' AND last_name = '"+surname+"';",connectDb);
               Int32 passport;
               try
               {
                   passport = (Int32)chkNamePat.ExecuteScalar();
                   if (passport > 0)
                   {
                       chkPassport = true;
                   }
               }
               catch (Exception exception)
               {
                    Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
               }
               finally
               {

               }
        }
Exemple #16
0
        /// <summary>
        /// получает список улиц для выбранного города, выгружает в хмл, нужно сделать проверку на последнюю запись
        /// </summary>
        /// <param name="city"></param>
        /// 
        public void getStreetAddr(Int16 City)
        {
            DataSet dsOnk = new DataSet();
               tblStreet = dsOnk.Tables.Add("street");
               tblArea = dsOnk.Tables.Add("area");
               try
               {

               NpgsqlDataAdapter gSt = new NpgsqlDataAdapter("SELECT addr,area,serial FROM streets WHERE city ='" + City + "' order by addr ASC;", connectDb);

               gSt.Fill(tblStreet);

               NpgsqlDataAdapter gAr = new NpgsqlDataAdapter("SELECT int_value,text_value,c_id FROM area WHERE c_id ='" + City + "' order by text_value ASC;", connectDb);

               gAr.Fill(tblArea);

               }
               catch (Exception exception)
               {
                Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
               }
        }
Exemple #17
0
        //Получает данные о пользователе
        ///
        public void getUsrData()
        {
            DataSet dsOnk = new DataSet();
               try
               {

                 NpgsqlDataAdapter dbUsrDat = new NpgsqlDataAdapter("SELECT * FROM doctors WHERE user_name = '"+dBUserName+"';", connectDb);

                 tblUsrData = dsOnk.Tables.Add("db_usrdata");

                    dbUsrDat.Fill(tblUsrData);
                    dbUsrId = Convert.ToInt32(tblUsrData.Rows[0]["doc_id"]);
                    uName = (string)tblUsrData.Rows[0]["first_name"];
                    string uSName = (string)tblUsrData.Rows[0]["last_name"];
                    uFName = ((string)tblUsrData.Rows[0]["family_name"]).Trim();
                    UsrSign = (uFName + " " + uName[0] + ". " + uSName[0] + ".");
               }
               catch (Exception exception)
               {
                Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
               }
        }
Exemple #18
0
        ///Создание нового пользователя через меню регистрации
        public void CreateNewDbUser(String new_username, String new_pass, String new_name, String new_familyname, 
            String new_secondname, DateTime new_birthdate, Int16 new_otdel, Int16 new_status, String new_mail, int Role)
        {
            try
              {

                  MD5 md5h = MD5.Create();
                  byte[] PassHash = md5h.ComputeHash(Encoding.Default.GetBytes(new_pass));
                  StringBuilder crHash = new StringBuilder();
                  foreach (byte hashByte in PassHash)
                  {
                      crHash.Append(String.Format("{0:x2}", hashByte));
                  }
                  string dBPassHash = crHash.ToString();
                  string _group = "postgres";
                  switch (Role)
                  {
                      case 0:
                          _group = "doc_group";
                          break;
                      case 1:
                          _group = "audit_group";
                          break;

                      case 2:
                          _group = "adm_group";
                          break;

                  }

                  NpgsqlCommand WriteNewDbUser = new NpgsqlCommand("CREATE USER " + new_username + " WITH PASSWORD '" + dBPassHash + "' IN GROUP "+_group+"", connectDb);
                  WriteNewDbUser.ExecuteNonQuery();

                  NpgsqlCommand WriteNewDbUserInfo = new NpgsqlCommand("INSERT INTO doctors (family_name, first_name, last_name, status, user_name, otdel, u_mail, birth, special) VALUES ('"
                      + new_familyname + "','" + new_name + "','" + new_secondname + "','" + new_status + "','" + new_username + "','" + new_otdel + "','" + new_mail + "','" + new_birthdate + "', '1' );", connectDb);
                  WriteNewDbUserInfo.ExecuteNonQuery();

                  MessageBox.Show("Пользователь создан", "Спасибо за регистрацию",
                       MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                  RegisterForm.ActiveForm.Close();
                  RegisterForm FormRegisterDbUser = new RegisterForm();
                  FormRegisterDbUser.ShowDialog();

              }
              catch (Exception exception)
              {
                   Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
              }
              finally
              {

              }
        }
Exemple #19
0
        ///Загружает список пациентотв из базы и сохраняет в хмл
        public void loadKartListFromBase()
        {
            try
               {
               NpgsqlDataAdapter dbKL = new NpgsqlDataAdapter("SELECT nib, family_name, first_name, last_name, birth_date, pat_id FROM patient_list ;", connectDb);

               DataSet dsOnk = new DataSet();
               tblKartList = dsOnk.Tables.Add("db_kartlist");
               dbKL.Fill(tblKartList);

               }
               catch (Exception exception)
               {
                Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
               }
              // tblKartList.WriteXml("data/p_dat.xml");
        }
Exemple #20
0
        /// <summary>
        /// Создаёт нового пациента
        /// нужно сделать проверку на повторы
        /// </summary>
        /// 
        public void crtNewPatient(bool isComment, bool isTrustMan, bool m1, bool m2, bool m3, bool nnib)
        {
            DataRow wnpRow = writeNewPatient.Rows[0];
              String trustMan;
              String comment;
              String rowTrust;
              String rowComment;
              String rPhone1;
               String iPhone1;
              String rPhone2;
               String iPhone2;
              String rPhone3;
               String iPhone3;
               String rNib;
               String iNib;

              if (chkPassport==true)
              {
              Int64 cPass = (Int64)wnpRow["pass"];
              chkPatInBaseByPass(cPass);
              }
              else
              {
              chkPatByYearName((DateTime)wnpRow["birth_date"],(string)wnpRow["family_name"],(string)wnpRow["first_name"],(string)wnpRow["last_name"],(Int16)wnpRow["town"]);
              }
              if (chkPassport == false)
              {
              if (isComment == true)
                          {
                              comment = ",comment";
                              rowComment = ", '"+wnpRow["comment"]  ;
                          }
                          else { comment = ""; rowComment = "";}
              if (isTrustMan == true)
                          {
                              trustMan = " ,trust_man, trust_phone";
                              rowTrust =  ", '"+wnpRow["trust_man"] + "', '" + wnpRow["trust_phone"] +"'";
                          }
                          else{trustMan = ""; rowTrust = "";}
              if (m1 == true)
              {
                 rPhone1 = ", " +wnpRow["phone1"];
                 iPhone1 = ", phone1";
              }
              else { rPhone1 = ""; iPhone1 = ""; }
              if (m2 == true)
              {
                 rPhone2 = ", " +wnpRow["phone2"];
                 iPhone2 = ", phone2";
              }
              else { rPhone2 = ""; iPhone2 = ""; }
              if (m3 == true)
              {
                 rPhone3 = ", " +wnpRow["phone3"];
                 iPhone3 = ", phone3";
              }
              else { rPhone3 = ""; iPhone3 = ""; }

              if (nnib == true)
              {
                  rNib = wnpRow["nib"] + ", '" + wnpRow["nib_date"] + "', ";
                  iNib = " nib, cardprt,";
              }
              else { rNib = ""; iNib= ""; }

              try
              {

                  //   NpgsqlCommand CreateNewPatient = new NpgsqlCommand("INSERT INTO patient_list "
                  //      + " (family_name, first_name, last_name, birth_date, nib, is_man, doc_id) "
                  //   + " VALUES ('" + wd[0] + "," + wd[1] + "," + wd[2] + "," + wd[3] + "," + wd[4] + "," + wd[5] + "," + wd[6] + "');", connectDb);

                  NpgsqlCommand CreateNewPatient = new NpgsqlCommand("INSERT INTO patient_list "
                                   + " ( family_name, first_name, last_name, birth_date, pass,"+ iNib +" is_man, snils, creator_id, region1,state, "
                                  + "country, town_id, area, street_n, house, building, flat,address "+ iPhone1 + iPhone2 + iPhone3 + comment + trustMan + ")"

                                   + " VALUES ('" +
                                   wnpRow["family_name"] + "', '" +
                                   wnpRow["first_name"] + "', '" +
                                   wnpRow["last_name"] + "', '" +
                                   wnpRow["birth_date"] + "', " +
                                   wnpRow["pass"] + ", " + rNib +

                                   wnpRow["is_man"] + ", " +
                                   wnpRow["snils"] + ", " +
                                   wnpRow["creator_id"] + ", " +
                                   wnpRow["region1"] + ", " +
                                   wnpRow["state"] + ", " +
                                   wnpRow["country"] + ", " +
                                   wnpRow["town_id"] + ", " +
                                   wnpRow["area"] + ", " +
                                   wnpRow["street_n"] + ", " +
                                   wnpRow["house"] + ", " +
                                   wnpRow["building"] + ", " +
                                   wnpRow["flat"] + ", '" +
                                   wnpRow["address"] + "'"+
                                   rPhone1 +
                                   rPhone2 +
                                   rPhone3 +
                                   rowComment +
                                   rowTrust  + ");", connectDb);
                  CreateNewPatient.ExecuteNonQuery();

                  writeNewPatient.Clear();
              }
              catch (Exception exception)
              {
                   Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
              }
              finally
              {

              }

              }
              else
              {
              MessageBox.Show("Проверьте заполнение данных или сделайте поиск в базе пациентов", "Пользователь "+wnpRow["family_name"]+" - существует",
              MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
              }
        }
Exemple #21
0
        /// <summary>
        /// Загружает список пациентов пользователя, который хранится в строке через запятую или ;
        /// и передает его в листбокс пациентлист
        /// </summary>
        public DataTable loadUsrPatientList()
        {
            DataSet dsOnk = new DataSet();
               DataTable user_data = new DataTable();

               try
               {

               NpgsqlDataAdapter dbU = new NpgsqlDataAdapter("SELECT (select trim(family_name) from patient_list where pat_id = user_data.pat_id) as famname,"+
                 "  (select substr(first_name,1,1) from patient_list where pat_id = user_data.pat_id) as firname,(select substr(last_name,1,1) from patient_list where pat_id = user_data.pat_id) as lasname, pat_id "+
                 "FROM user_data WHERE usr_id = '" + dbUsrId + "' and approve = true;", connectDb);
               dbU.Fill(user_data);

               }
               catch (Exception exception)
               {
                Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
               }
               foreach (DataRow row in user_data.Rows)
               {
               if (String.IsNullOrEmpty(user_data.Rows[0].ToString()))
               {
                   user_data.Rows.Remove(row);
               }
               }

               return user_data;
        }
Exemple #22
0
        /// <summary>
        /// проверка номера исследования
        /// Добавление данных из формы цитологии
        /// добавление записи в таблицу документов (лучше сделать в базе)
        /// </summary>
        /// <param name="pat_id"></param>
        /// <param name="date"></param>
        /// <param name="shifr"></param>
        /// <param name="nomer"></param>
        /// <param name="zakluch"></param>
        public void cytoInsertData(String pat_id, DateTime date, Int16 shifr, Int32 nomer, String zakluch)
        {
            try
               {

              ///Проверка номера исследования
               NpgsqlDataAdapter chkCytNumb = new NpgsqlDataAdapter("SELECT nomer FROM cytology WHERE nomer = '" + nomer + "';", connectDb);
               DataSet dsOnk = new DataSet();
               tblCytNumb = dsOnk.Tables.Add("db_cytology_number");
               chkCytNumb.Fill(tblCytNumb);
               if (tblCytNumb.Rows.Count >= 1)
               {

               System.Windows.Forms.MessageBox.Show("Исследование № " + nomer + " уже существует", "Выберите другой номер или проверьте последние записии",
                                System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
               }
               else
               {
               NpgsqlCommand insCytData = new NpgsqlCommand("INSERT INTO cytology (zakluch, pat_id, date, shifr, nomer) VALUES ('" + zakluch + "','" + pat_id + "','" + date + "','" + shifr + "','" + nomer + "');", connectDb);

               insCytData.ExecuteNonQuery();
               }
                      }
               catch (Exception exception)
               {
                Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
               }
        }
Exemple #23
0
        public void createDataForPatient()
        {
            try
            {

                DBExchange.Inst.chkPassport = false;
                if (checkPassport() == false || editFlag == true)
                {

                    String f_name = this.pFamilyNameTextBox1.Text.Trim();
                    String fi_name = this.pNameTextBox2.Text.Trim();
                    String se_name = this.p_s_name_textBox3.Text.Trim();

                    if (birth == false && editFlag == false)
                    {
                        MessageBox.Show("Укажите дату рождения", "Дата рождения указана неверно",
                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        DateTime bi_d = this.pdateTimePicker1.Value;

                        if (this.radioButton1.Checked == false && this.radioButton2.Checked == false)
                        {
                            MessageBox.Show("Укажите половую принадлежность пациента", "Это женщина или мужчина?",
                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        else
                        {
                            is_man = this.radioButton1.Checked;

                            if (f_name.Length < 2 || se_name.Length < 2 || fi_name.Length < 2)
                            {
                                MessageBox.Show("Проверьте ФИО пациента", "Неправильно заполнены данные",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                            else
                            {
                                String korp = this.textBox9.Text;
                                DBExchange.Inst.getRegion();

                                DBExchange.Inst.getPatientStruct();
                                DataRow wnpRow = DBExchange.Inst.writeNewPatient.NewRow();

                                wnpRow["family_name"] = f_name;
                                wnpRow["first_name"] = fi_name;
                                wnpRow["last_name"] = se_name;
                                wnpRow["birth_date"] = bi_d;
                                if (this.PassBox.Text.Length == 12)
                                {
                                    DBExchange.Inst.chkPassport = true;
                                    Int64 pass = Convert.ToInt64(this.PassBox.Text.Remove(8, 1).Remove(4, 1));
                                    wnpRow["pass"] = pass;
                                    wnpRow["doc_ser"] = this.PassBox.Text.Substring(0, 4);
                                    wnpRow["doc_num"] = pass.ToString().Substring(4, 6);
                                    wnpRow["doc_date"] = this.dateTimePicker2.Value;
                                }
                                else
                                {
                                    MessageBox.Show("Проверьте паспортные данные ", "Возникла ошибка",
                                     MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                }
                                if (this.textBox1.Text.Trim().Length > 1)
                                {
                                    wnpRow["doc_org"] = textBox1.Text.Trim();

                                }

                                if (pHistoryNumbertextBox5.Text.Length > 3)
                                {
                                    wnpRow["nib"] = Convert.ToInt32(this.pHistoryNumbertextBox5.Text.Trim());
                                    nnib = true;
                                    wnpRow["nib_date"] = this.dateTimePicker1.Value;
                                }

                                wnpRow["is_man"] = is_man;
                                wnpRow["creator_id"] = DocId;
                                wnpRow["region1"] = valRegion;
                                wnpRow["state"] = valOkrug;
                                wnpRow["country"] = valCountry;
                                wnpRow["town_id"] = valCity;
                                wnpRow["area"] = valRayon;
                                if (this.StreetBox.SelectedIndex >= 0)
                                {
                                    wnpRow["street_n"] = Convert.ToInt32(lstStId[this.StreetBox.SelectedIndex]);
                                }
                                else
                                {
                                    wnpRow["street_n"] = DBNull.Value;

                                }
                                wnpRow["address"] = strPatAddress;
                                wnpRow["snils"] = this.maskedTextBoxSnils.Text.Trim();

                                if (this.textBox10.Text.Length > 0)
                                {

                                    wnpRow["house"] = this.textBox10.Text.Trim();
                                }
                                wnpRow["building"] = textBox9.Text.Trim();
                                if (maskedTextBox1.Text.Length > 0)
                                {
                                    wnpRow["flat"] = this.maskedTextBox1.Text.Trim();
                                }
                                if (m1Box.Text.Trim().Length == 16)
                                {
                                    m1 = true;
                                    Int64 ph1 = Convert.ToInt64(this.m1Box.Text.Remove(11, 1).Remove(6, 2).Remove(2, 1).Remove(0, 1));
                                    wnpRow["phone1"] = ph1;
                                }
                                if (m2Box.Text.Trim().Length == 16)
                                {
                                    Int64 ph2 = Convert.ToInt64(this.m2Box.Text.Remove(11, 1).Remove(6, 2).Remove(2, 1).Remove(0, 1));
                                    m2 = true;
                                    wnpRow["phone2"] = ph2;
                                }
                                if (m3Box.Text.Trim().Length == 16)
                                {
                                    Int64 ph3 = Convert.ToInt64(this.m3Box.Text.Remove(11, 1).Remove(6, 2).Remove(2, 1).Remove(0, 1));
                                    m3 = true;
                                    wnpRow["phone3"] = ph3;
                                }
                                if (textBox15.Text.Trim().Length > 2)
                                {
                                    isComment = true;
                                    wnpRow["comment"] = textBox15.Text.Trim();
                                }
                                if (textBox13.Text.Length > 4)
                                {
                                    isTrustMan = true;
                                    wnpRow["trust_man"] = textBox13.Text.Trim();
                                    wnpRow["trust_phone"] = textBox14.Text.Trim();
                                }
                                DBExchange.Inst.writeNewPatient.Rows.Add(wnpRow);

                                try
                                {
                                    if (editFlag == true)
                                    {
                                        createUpdatePatientString();
                                    }
                                    else
                                    {
                                        DBExchange.Inst.crtNewPatient(isComment, isTrustMan, m1, m2, m3, nnib);
                                    }
                                    clearData();

                                }
                                catch (Exception exception)
                                {
                                    Warnings.WarnLog log = new Warnings.WarnLog();
                                    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

            }
        }
Exemple #24
0
        public void DbInitConnection(String dBServer, String dBLogin, String dBPassword)
        {
            dbServerString = dBServer;

               MD5 md5h = MD5.Create();
               byte[] PassHash = md5h.ComputeHash(Encoding.Default.GetBytes(dBPassword));
               StringBuilder crHash = new StringBuilder();
               foreach (byte hashByte in PassHash)
               {
               crHash.Append(String.Format("{0:x2}", hashByte));
               }

               string dBPassHash = crHash.ToString();

               byte[] UNameHash = md5h.ComputeHash(Encoding.Default.GetBytes(dBLogin));
               StringBuilder crHashN = new StringBuilder();
               foreach (byte hashByte in UNameHash)
               {
               crHashN.Append(String.Format("{0:x2}", hashByte));
               }
               string dBLoginHash = crHashN.ToString();

               string strConnect = "Server=" + dBServer + ";Port=5432;User Id=" + dBLogin + "; Password="******";Database=medex; searchpath=medex;";
               m_dbUserName = dBLogin;
               connectDb = new NpgsqlConnection(strConnect);
               try
               {
               connectDb.Open();
               //  NpgsqlCommand command = new NpgsqlCommand(strConnect, mDBConnection);

               }
               catch (Exception exception)
               {
               if (exception.Message.ToString().Contains("FATAL: 28000: password authentication failed"))
               {
                   System.Windows.Forms.MessageBox.Show("Логин или пароль введены не верно.\nПроверьте введённые данные и повторите попытку.");
               }
               else
               {
                   Warnings.WarnLog log = new Warnings.WarnLog(); log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
               }
               }
               finally
               {

               }
        }
Exemple #25
0
        private void comboBox1_Enter(object sender, EventArgs e)
        {
            tblDoc = new DataTable();
            List<string> lstDoc = new List<string>();
            NpgsqlConnection cdbo = DBExchange.Inst.connectDb;
            try
            {
                NpgsqlDataAdapter getDoc = new NpgsqlDataAdapter("Select family_name, first_name, last_name, doc_id from doctors where status ='' ",cdbo);

                getDoc.Fill(tblDoc);

            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

            }
            //нужно получить лист имен докторов и при выборе в боксе устанавливать DocNum
               // this.comboBox1.DataSource = lstDoc;
        }
Exemple #26
0
        /// <summary>
        // Получение первоначальных данных и типов полей схемы. Сообщения и журнал.
        /// </summary>
        ///  /// GetObjType получает тип поля из хмл документа, который формируется при входе в базу данных 
        /// и сохраняется на диске, затем проверяется только дата последнего изменения таблицы из которой 
        /// получаются данные для списка. Функция затем соотносит полученные данные и отдает тип поля.  
        /// 
        ///   Определение типа данных 
        ///  SELECT table_name, Column_name, data_type, character_maximum_length, column_default 
        ///  FROM information_schema.columns WHERE table_schema = 'public'
        ///  
        public void GetDbObjType()
        {
            try
               {

             //  NpgsqlDataAdapter dbObjType = new NpgsqlDataAdapter("SELECT table_name, Column_name, data_type, character_maximum_length, column_default FROM information_schema.columns WHERE table_schema = 'medex';", connectDb);
               DataSet dsOnk = new DataSet();
               //tblDbObjType = dsOnk.Tables.Add("dbobjtype");
              // dbObjType.Fill(tblDbObjType);
              // dsOnk.WriteXml("data/dbTypes.xml");

               NpgsqlDataAdapter dbMessAll = new NpgsqlDataAdapter("SELECT m_from, m_date, m_body FROM message_center WHERE m_to= 'ALL' ORDER BY m_date ASC LIMIT 60;", connectDb);
               tblMessageAll = dsOnk.Tables.Add("db_message_all");
               dbMessAll.Fill(tblMessageAll);

               NpgsqlDataAdapter dbMessAnn = new NpgsqlDataAdapter("SELECT m_from, m_date, m_body FROM message_center WHERE m_to= 'ANN' ORDER BY m_date DESC LIMIT 60;", connectDb);
               tblMessageAnn = dsOnk.Tables.Add("db_m_announce");
               dbMessAnn.Fill(tblMessageAnn);

               NpgsqlDataAdapter dbDocumTypes = new NpgsqlDataAdapter("SELECT * FROM docum_type;", connectDb);
               tblDocumentTypes = dsOnk.Tables.Add("db_docum_types");
               dbDocumTypes.Fill(tblDocumentTypes);

               //    (Select descr from docum_type where docum_type.did = documents.document_type)

              // dsOnk.WriteXml("data/journal.xml");

               }
               catch (Exception exception)
               {
                Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
               }

               getUsrJournal(dbUsrId);
               getUsrData();
        }
Exemple #27
0
        private void getPatientDataFromBase(int thisId)
        {
            NpgsqlConnection cdbo = DBExchange.Inst.connectDb;
            tblPatient = new DataTable();
            try
            {
                NpgsqlDataAdapter getPatData = new NpgsqlDataAdapter("Select * from patient_list where pat_id ='" + thisId + "' ", cdbo);

                getPatData.Fill(tblPatient);
                gotPatientId = thisId;
                if (Convert.IsDBNull(tblPatient.Rows[0]["pass"]) == false)
                {
                    if ((Int64)tblPatient.Rows[0]["pass"] > 0)
                    {
                        this.PassBox.Text = tblPatient.Rows[0]["pass"].ToString();
                    }
                    else
                    {
                        this.PassBox.Text = tblPatient.Rows[0]["doc_ser"].ToString().Trim() + "" + tblPatient.Rows[0]["doc_num"].ToString().Trim();
                    }
                }
                this.pFamilyNameTextBox1.Text = tblPatient.Rows[0]["family_name"].ToString();
                this.pNameTextBox2.Text = tblPatient.Rows[0]["first_name"].ToString();
                this.p_s_name_textBox3.Text = tblPatient.Rows[0]["last_name"].ToString();
                this.maskedTextBoxSnils.Text = tblPatient.Rows[0]["snils"].ToString().Trim();
                this.dateTimePicker2.Value = (DateTime)tblPatient.Rows[0]["doc_date"];
                this.textBox1.Text = (string)tblPatient.Rows[0]["doc_org"].ToString().Trim();
                if ((bool)tblPatient.Rows[0]["is_man"] == true)
                {
                    this.radioButton1.Checked = true;
                }
                else
                {
                    this.radioButton2.Checked = true;
                }
                pdateTimePicker1.Value = (DateTime)tblPatient.Rows[0]["birth_date"];

                if (Convert.IsDBNull(tblPatient.Rows[0]["nib_date"])==true || ((DateTime)tblPatient.Rows[0]["nib_date"]).Year.ToString() == "1001")
                {
                    dateTimePicker1.Value = DateTime.Today;
                }
                else
                {
                    dateTimePicker1.Value = (DateTime)tblPatient.Rows[0]["nib_date"];
                }

                if ((int)tblPatient.Rows[0]["nib"] > 0)
                {
                    pHistoryNumbertextBox5.Text = ((int)tblPatient.Rows[0]["nib"]).ToString();
                }
                int country_id = 1;
                if (Convert.IsDBNull(tblPatient.Rows[0]["country"]) == false)
                {
                    country_id = (int)tblPatient.Rows[0]["country"];
                }

                if (Convert.IsDBNull(tblPatient.Rows[0]["town_id"]) == false)
                {
                    if ((int)tblPatient.Rows[0]["town_id"] == 210)
                    {
                        this.CountryBox.SelectedIndex = 0;
                        valCountry = 1;

                        changeCountry(0);
                        this.CountryBox.SelectedItem = 0;

                        changeOkrug(1);
                        this.comboBoxOkrug.SelectedIndex = 1;

                        changeRegion(9);
                        this.RegionBox.SelectedIndex = 9;

                        chngCity(9);
                        this.CityBox.SelectedIndex = 9;

                    }
                    else
                    {
                        if (country_id != 1)
                        {
                            changeCountry(Convert.ToInt16(DBExchange.Inst.tblCountry.Select("int_value=" + country_id + "").GetEnumerator().Current));

                        }
                        else
                        {
                            changeCountry(0);
                            this.CountryBox.SelectedItem = 0;
                        }
                        changeOkrug(Convert.ToInt16(lstOkId.IndexOf((tblPatient.Rows[0]["state"]).ToString())));
                        Int16 regId = Convert.ToInt16(lstReId.IndexOf((tblPatient.Rows[0]["region1"]).ToString()));
                        changeRegion(regId);
                        this.RegionBox.SelectedIndex = regId;
                        Int16 cityId = Convert.ToInt16(lstCiId.IndexOf((tblPatient.Rows[0]["town_id"]).ToString()));
                        chngCity(cityId);
                        this.CityBox.SelectedIndex = cityId;

                    }
                }

                if (Convert.IsDBNull(tblPatient.Rows[0]["house"]) == false)
                {
                    textBox10.Text = (string)tblPatient.Rows[0]["house"];
                }

                if (Convert.IsDBNull(tblPatient.Rows[0]["building"]) == false)
                {

                    textBox9.Text = (string)tblPatient.Rows[0]["building"];

                }

                if (Convert.IsDBNull(tblPatient.Rows[0]["flat"]) == false)
                {

                    maskedTextBox1.Text = (string)tblPatient.Rows[0]["flat"];

                }

                if (Convert.IsDBNull(tblPatient.Rows[0]["area"]) == false)
                                {
                                    if (tblPatient.Rows[0]["area"].ToString() != "")
                                    {
                                        Int16 areaId = (Int16)tblPatient.Rows[0]["area"];

                                        if (areaId > 0 & lstRaId.Count > 0)
                                        {
                                            Int16 cri = Convert.ToInt16(lstRaId.IndexOf((areaId).ToString()));
                                            //chngRayon(cri);
                                            RayonBox.SelectedIndex = cri;

                                        }
                                    }
                                }

            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

            }
        }
Exemple #28
0
        ///Получает структуру таблицы пациентов
        public void getPatientStruct()
        {
            DataSet dsOnk = new DataSet();
               try

               {

               NpgsqlDataAdapter selPatStru = new NpgsqlDataAdapter("SELECT * FROM patient_list LIMIT 1;", connectDb);
               writeNewPatient = dsOnk.Tables.Add("new_patient");
               selPatStru.Fill(writeNewPatient);
               writeNewPatient.Clear();
               }
               catch (Exception exception)
               {
                Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
               }
        }
Exemple #29
0
        private void updateAddrText()
        {
            try
            {

                strPatAddress = this.CountryBox.SelectedValue + ", " + this.CityBox.SelectedValue + ", " + this.StreetBox.SelectedValue + " "
                    + this.textBox10.Text.Trim() + " корп." + this.textBox9.Text.Trim() + " кв." + this.maskedTextBox1.Text.Trim();
                if (editFlag == false)
                {

                    this.textBoxAddr.Text = strPatAddress;
                }
                else
                {
                    if (Convert.IsDBNull(tblPatient.Rows[0]["address"]) == false)
                    {
                        if (tblPatient.Rows[0]["address"].ToString().Length > 0 && this.StreetBox.SelectedIndex >= 0)
                        {
                            if (((string)tblPatient.Rows[0]["address"]).Contains((string)this.StreetBox.SelectedValue) == true)
                            {
                                this.textBoxAddr.Text = strPatAddress;
                            }
                            else
                            {
                                this.textBoxAddr.Text = (string)tblPatient.Rows[0]["address"];
                            }
                        }
                    }
                }
                this.textBoxAddr.Invalidate();
            }
            catch (Exception exception)
            {
                Warnings.WarnLog log = new Warnings.WarnLog();
                log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());

            }
        }
Exemple #30
0
        /// <summary>
        /// Получает регион страну город и район для листов в newpatientform из хмл и сверяет их количество с базой
        /// </summary>
        /// 
        public void getRegion()
        {
            DataSet dsOnk = new DataSet();
               try
               {
               dsOnk.ReadXml("data/livin.xml");
               Int32 dsOnkRegionCount = dsOnk.Tables["region"].Rows.Count + dsOnk.Tables["city"].Rows.Count + dsOnk.Tables["country"].Rows.Count + dsOnk.Tables["rayon"].Rows.Count;
               DataTable countAddr = dsOnk.Tables.Add("count_addr");
               try
               {

                   NpgsqlDataAdapter selCountAddr = new NpgsqlDataAdapter("SELECT count(*) FROM addr;", connectDb);

                   selCountAddr.Fill(countAddr);
               }
               catch (Exception exception)
               {
                    Warnings.WarnLog log = new Warnings.WarnLog();    log.writeLog(MethodBase.GetCurrentMethod().Name, exception.Message.ToString(), exception.StackTrace.ToString());
               }

               Int32 addrCount = Convert.ToInt32(countAddr.Rows[0]["count"]);
               if (addrCount != dsOnkRegionCount)
               {
                   chkRegion();
               }

               }
               catch
               {
               chkRegion();

               }
               finally
               {
               tblArea = dsOnk.Tables["rayon"];
               tblCities = dsOnk.Tables["city"];
               tblCountry = dsOnk.Tables["country"];
               tblRegion = dsOnk.Tables["region"];
               }
        }