Example #1
0
        private void addDiagnosis(Diagnosis dng)
        {
            if (dng.Title != "" && dng.Description != "")
            {
                WorkWithDb wwd    = new WorkWithDb();
                string     sqlexp = "INSERT INTO Diagnoses(Title,Id_Patient,Id_Doctor,Data,Description) " +
                                    "VALUES(@Title,@Id_p,@Id_d,@Date,@Desc)";
                Dictionary <string, object> values = new Dictionary <string, object>()
                {
                    { "@Title", dng.Title },
                    { "@Id_p", dng.Id_Patient },
                    { "@Id_d", dng.Id_Doctor },
                    { "@Date", DateTime.Now.Date },
                    { "@Desc", dng.Description },
                };
                Queue <SqlDbType> types = new Queue <SqlDbType>();
                types.Enqueue(SqlDbType.NVarChar);
                types.Enqueue(SqlDbType.Int);
                types.Enqueue(SqlDbType.Int);
                types.Enqueue(SqlDbType.Date);
                types.Enqueue(SqlDbType.NVarChar);

                wwd.InsertInDb(sqlexp, values, types);
            }
        }
Example #2
0
        private void markVisit(object items)
        {
            object[] parameters = items as object[];
            Doctor   dc         = parameters[2] as Doctor;
            string   time       = parameters[3].ToString();
            int      mynumb;

            if (time.Length == 4)
            {
                mynumb = Convert.ToInt32(time.Substring(0, 1));
            }
            else
            {
                mynumb = Convert.ToInt32(time.Substring(0, 2));
            }

            if (mynumb <= DateTime.Now.Hour)
            {
                string connectionString = ConfigurationManager.ConnectionStrings["ConnectToDb"].ConnectionString;
                using (SqlConnection connect = new SqlConnection(connectionString))
                {
                    connect.Open();
                    string     sqlexp = "SELECT * FROM Visits WHERE Id_Patient = @Id_p and Date=@Date and Id_Doc=@Id_d ";
                    SqlCommand cmd    = new SqlCommand(sqlexp, connect);
                    cmd.Parameters.AddWithValue("@Id_p", parameters[0]);
                    cmd.Parameters.AddWithValue("@Date", parameters[1]);
                    cmd.Parameters.AddWithValue("@Id_d", dc.Id_Doctor);
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader.HasRows)
                    {
                        MessageBox.Show("Patient was marked");
                    }
                    else
                    {
                        WorkWithDb wwd   = new WorkWithDb();
                        string     query = "INSERT INTO Visits(Date,Health_complaints,Id_Patient,Id_Doc) VALUES(@Date,@H_C,@Id_p,@Id_d)";
                        Dictionary <string, object> mydic = new Dictionary <string, object>()
                        {
                            { "@Date", parameters[1] },
                            { "@H_C", "" },
                            { "Id_p", parameters[0] },
                            { "@Id_d", dc.Id_Doctor }
                        };
                        Queue <SqlDbType> que = new Queue <SqlDbType>();
                        que.Enqueue(SqlDbType.Date);
                        que.Enqueue(SqlDbType.NVarChar);
                        que.Enqueue(SqlDbType.Int);
                        que.Enqueue(SqlDbType.Int);
                        wwd.InsertInDb(query, mydic, que);
                    }
                }
            }
            else
            {
                MessageBox.Show("The time has not come yet");
            }
        }
Example #3
0
 private void addnewpatient()
 {
     if (SelectedPatient.Error == String.Empty)
     {
         Dictionary <string, object> paramval = new Dictionary <string, object>()
         {
             { "@FN", SelectedPatient.FirstName },
             { "@SN", SelectedPatient.SurName },
             { "@Pat", SelectedPatient.Patronymic },
             { "@Sni", SelectedPatient.Snils },
             { "@Tele", SelectedPatient.Telephone },
             { "@Addr", SelectedPatient.Address },
             { "@Poli", SelectedPatient.Policy },
             { "@Birth", Convert.ToDateTime(SelectedPatient.Birthday) },
         };
         string queryaddPat = "INSERT INTO Patients (Firstname,Surname,Patronymic,Snils,Telephone,Address,Policy,Birthday)" +
                              " VALUES(@FN,@SN,@Pat,@Sni,@Tele,@Addr,@Poli,@Birth)";
         Queue <SqlDbType> types = new Queue <SqlDbType>();
         for (int i = 0; i < 7; i++)
         {
             types.Enqueue(SqlDbType.NVarChar);
         }
         types.Enqueue(SqlDbType.Date);
         WorkWithDb insertPat = new WorkWithDb();
         if (insertPat.InsertInDb(queryaddPat, paramval, types))
         {
             CreateMedCard(SelectedPatient.Policy);
             SelectedPatient.FirstName  = String.Empty;
             SelectedPatient.SurName    = String.Empty;
             SelectedPatient.Patronymic = String.Empty;
             SelectedPatient.Snils      = String.Empty;
             SelectedPatient.Telephone  = String.Empty;
             SelectedPatient.Address    = String.Empty;
             SelectedPatient.Policy     = String.Empty;
             SelectedPatient.Birthday   = String.Empty;
         }
     }
     else
     {
         MessageBox.Show("Исправте поля");
     }
 }
Example #4
0
 private void MakeRecord(DateTime currentdate)
 {
     if (pat.Error == String.Empty)
     {
         using (SqlConnection connect = new SqlConnection(connectionString))
         {
             connect.Open();
             string     sqlexp = "SELECT * FROM Patients WHERE Policy=@Pol";
             SqlCommand cmd    = new SqlCommand(sqlexp, connect);
             cmd.Parameters.AddWithValue("@Pol", pat.Policy);
             SqlDataReader reader = cmd.ExecuteReader();
             if (reader.HasRows)
             {
                 reader.Read();
                 Id_Patient = reader.GetInt32(0);
                 if (CheckAppointMent(Id_Patient))
                 {
                     string sqlquery = "INSERT INTO Appointments(Id_Doctor,Date,Time,Id_Patient) VALUES(@Id_Doc,@Date,@Time,@Id_Pat)";
                     Dictionary <string, object> newmAppoint = new Dictionary <string, object>()
                     {
                         { "@Id_Doc", record.Doc.Id_Doctor },
                         { "@Date", currentdate.Date },
                         { "@Time", currentdate.TimeOfDay },
                         { "@Id_Pat", Id_Patient }
                     };
                     var types = new Queue <SqlDbType>();
                     types.Enqueue(SqlDbType.Int);
                     types.Enqueue(SqlDbType.Date);
                     types.Enqueue(SqlDbType.Time);
                     types.Enqueue(SqlDbType.Int);
                     WorkWithDb wwd = new WorkWithDb();
                     wwd.InsertInDb(sqlquery, newmAppoint, types);
                 }
             }
             else
             {
                 MessageBox.Show("Такой номер полиса не зарегистрирован");
             }
         }
     }
 }
Example #5
0
        private void CreateMedCard(string policy)
        {
            int    id_pat           = 0;
            string connectionString = ConfigurationManager.ConnectionStrings["ConnectToDb"].ConnectionString;

            using (SqlConnection connect = new SqlConnection(connectionString))
            {
                connect.Open();
                string     sqlexp = "SELECT * FROM Patients WHERE Policy =@pol";
                SqlCommand cmd    = new SqlCommand(sqlexp, connect);
                cmd.Parameters.AddWithValue("@pol", policy);
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    reader.Read();
                    id_pat = reader.GetInt32(0);
                }
            }
            Dictionary <string, object> newmedcard = new Dictionary <string, object>()
            {
                { "@Id_P", id_pat },
                { "@D_C", DateTime.Now.Date },
                { "@Ins_Co", 666 }
            };
            Dictionary <string, object> mc = new Dictionary <string, object>()
            {
                { "@Id", id_pat }
            };
            var query  = "INSERT INTO Med_Card (Id_Patient, Date_Created, Institution_Code) VALUES (@Id_P, @D_C, @Ins_Co)";
            var query1 = "UPDATE Patients SET Id_Card=(SELECT Id_Card FROM Med_Card WHERE Id_Patient=@Id) WHERE Id_Patient=@Id";
            var types  = new Queue <SqlDbType>();

            types.Enqueue(SqlDbType.Int);
            types.Enqueue(SqlDbType.Date);
            types.Enqueue(SqlDbType.SmallInt);
            WorkWithDb wwd = new WorkWithDb();

            wwd.InsertInDb(query, newmedcard, types);
            wwd.UpdateDb(query1, mc);
        }
Example #6
0
 private void addAnalys(Analysis vacc)
 {
     if (vacc.Type != "" && vacc.Description != "" && vacc.Error == String.Empty)
     {
         WorkWithDb wwd    = new WorkWithDb();
         string     sqlexp = "INSERT INTO Analysis(Id_Patient,Type,DateofDelivery,Description) " +
                             "VALUES(@Id_p,@Type,@DoD,@Desc)";
         Dictionary <string, object> values = new Dictionary <string, object>()
         {
             { "@Type", vacc.Type },
             { "@Id_p", vacc.Id_Patient },
             { "@DoD", Convert.ToDateTime(vacc.Date) },
             { "@Desc", vacc.Description },
         };
         Queue <SqlDbType> types = new Queue <SqlDbType>();
         types.Enqueue(SqlDbType.NVarChar);
         types.Enqueue(SqlDbType.Int);
         types.Enqueue(SqlDbType.Date);
         types.Enqueue(SqlDbType.NVarChar);
         wwd.InsertInDb(sqlexp, values, types);
     }
 }
Example #7
0
 private void addSurvey(Survey vacc)
 {
     if (vacc.Title != "" && vacc.Description != "" && vacc.Error == String.Empty)
     {
         WorkWithDb wwd    = new WorkWithDb();
         string     sqlexp = "INSERT INTO Surveys(Description,Title,Data,Id_Patient) " +
                             "VALUES(@Title,@Desc,@Date,@Id_p)";
         Dictionary <string, object> values = new Dictionary <string, object>()
         {
             { "@Title", vacc.Title },
             { "@Id_p", vacc.Id_Patient },
             { "@Date", Convert.ToDateTime(vacc.Date) },
             { "@Desc", vacc.Description },
         };
         Queue <SqlDbType> types = new Queue <SqlDbType>();
         types.Enqueue(SqlDbType.NVarChar);
         types.Enqueue(SqlDbType.Int);
         types.Enqueue(SqlDbType.Date);
         types.Enqueue(SqlDbType.NVarChar);
         wwd.InsertInDb(sqlexp, values, types);
     }
 }
Example #8
0
 private void AddMark(int id_patient, int id_doctor)
 {
     if (thistext != "" && CheckVisits(id_patient, id_doctor))
     {
         WorkWithDb wwd   = new WorkWithDb();
         string     query = "INSERT INTO Visits(Date,Health_complaints,Id_Patient,Id_Doc)" +
                            "VALUES(@Date,@H_c,@Id_p,@Id_d)";
         Dictionary <string, object> dict = new Dictionary <string, object>()
         {
             { "@Date", DateTime.Now.Date },
             { "@H_c", thistext },
             { "@Id_p", id_patient },
             { "@Id_d", id_doctor }
         };
         Queue <SqlDbType> types = new Queue <SqlDbType>();
         types.Enqueue(SqlDbType.Date);
         types.Enqueue(SqlDbType.NVarChar);
         types.Enqueue(SqlDbType.Int);
         types.Enqueue(SqlDbType.Int);
         wwd.InsertInDb(query, dict, types);
     }
 }