Beispiel #1
0
        public string[] SearchPhoto(Newtonsoft.Json.Linq.JObject idUser)
        {
            string userId = HttpContext.Session.Get("userId").ToString();

            string[] array = WorkWithDb.PathPhoto(userId, Convert.ToInt32(idUser["idAlbum"])).ToArray();
            return(array);
        }
 private void UpdatePat(int id)
 {
     if (profpat.Error == String.Empty)
     {
         string queryaddPat = "UPDATE Patients SET Firstname=@FN, Surname=@SN,Patronymic=@Pat" +
                              ",Snils=@Sni,Telephone=@Tel,Address=@Addr,Policy=@Pol,Birthday=@Birth WHERE Id_Patient=@Id";
         Dictionary <string, object> dictPat = new Dictionary <string, object>()
         {
             { "@FN", profpat.FirstName },
             { "@SN", profpat.SurName },
             { "@Pat", profpat.Patronymic },
             { "@Id", profpat.Id },
             { "@Sni", profpat.Snils },
             { "@Tel", profpat.Telephone },
             { "@Addr", profpat.Address },
             { "@Pol", profpat.Policy },
             { "@Birth", Convert.ToDateTime(profpat.Birthday) }
         };
         WorkWithDb wwd = new WorkWithDb();
         wwd.UpdateDb(queryaddPat, dictPat);
     }
     else
     {
         MessageBox.Show("Исправте поля");
     }
 }
Beispiel #3
0
        public string[] SearchAlbum([FromBody] Newtonsoft.Json.Linq.JObject album)
        {
            string userId = WorkWithDb.getUserId(album["token"].ToString());

            string[] albums = WorkWithDb.SearchAlbum(userId.ToString()).ToArray();
            return(albums);
        }
Beispiel #4
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);
            }
        }
        public ActionResult Index()
        {
            ViewBag.IdEmpty     = true;
            ViewBag.Title       = "Додавання покемона";
            ViewBag.ButtonTitle = "Додати!";
            var i = new Pokemon();

            if (!string.IsNullOrEmpty(Request.Params["Id"]))
            {
                int ind; // for index
                int.TryParse(Request.Params["Id"], out ind);
                ind = new WorkWithDb(db).IsId(ind);
                if (ind >= 0)
                {
                    IEnumerable <Pokemon> pokemons = db.Pokemons;
                    i = pokemons.ToArray()[ind];
                    ViewBag.IdEmpty     = false;
                    ViewBag.Title       = "Редагування покемона"; // change title
                    ViewBag.ButtonTitle = "Перезаписати!";
                    ViewData["Id"]      = i.Id;
                }
            }
            ViewBag.CountOfPok     = db.Pokemons.Count();
            ViewData["Name"]       = i.Name;
            ViewData["Health"]     = i.Health;
            ViewData["Damage"]     = i.Damage;
            ViewData["Armor"]      = i.Armor;
            ViewData["UniqueMove"] = i.UniqueMove;
            return(View());
        }
Beispiel #6
0
        public int AddAlbum([FromBody] Newtonsoft.Json.Linq.JObject album)
        {
            string userId = WorkWithDb.getUserId(album["token"].ToString());
            int    id     = WorkWithDb.AddAlbum(userId, album["nameOfAlbum"].ToString());

            return(id);
        }
Beispiel #7
0
        public string[] SearchPhoto([FromBody] Newtonsoft.Json.Linq.JObject idUser)
        {
            string userId = WorkWithDb.getUserId(idUser["token"].ToString());

            string[] array = WorkWithDb.PathPhoto(userId, Convert.ToInt32(idUser["idAlbum"])).ToArray();
            return(array);
        }
Beispiel #8
0
        public void AddUser(Newtonsoft.Json.Linq.JObject obj)
        {
            Users user = new Users {
                Name = obj["Name"].ToString(), Surname = obj["Surname"].ToString(), Pseudonym = obj["Pseudonym"].ToString(), Email = obj["Email"].ToString(), FieldOfActivity = obj["FieldOfActivity"].ToString(), City = obj["City"].ToString(), Password = obj["Password"].ToString()
            };

            WorkWithDb.AddNewUser(user);
        }
Beispiel #9
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");
            }
        }
        public RedirectToRouteResult DelPokemon(int Id)
        {
            int ind = new WorkWithDb(db).IsId(Id);

            if (ind >= 0)
            {
                db.Pokemons.Remove(db.Pokemons.Find(Id));
                db.SaveChanges();
            }
            return(RedirectToRoute(new { controller = "Pokemon", action = "ListPokemons" }));
        }
        public ActionResult ViewPokemon(int Id = -1)
        {
            int ind = new WorkWithDb(db).IsId(Id);

            if (ind >= 0)
            {
                var pokemon = db.Pokemons.Find(Id);
                ViewBag.Pokemon = pokemon;
                return(View());
            }
            return(RedirectToRoute(new { controller = "Pokemon", action = "ListPokemons" }));
        }
        public RedirectToRouteResult AddPokemon(Pokemon pokemon)
        {
            int ind = new WorkWithDb(db).IsId(pokemon.Id);

            if (ind >= 0)
            {
                db.Pokemons.Remove(db.Pokemons.Find(pokemon.Id));
                db.Pokemons.Add(pokemon);
                db.SaveChanges();
                return(RedirectToRoute(new { controller = "Pokemon", action = "ListPokemons" }));
            }
            db.Pokemons.Add(pokemon);
            db.SaveChanges();
            ViewBag.CountOfPok = db.Pokemons.Count();
            return(RedirectToRoute(new { controller = "Pokemon", action = "Index" }));
        }
Beispiel #13
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("Исправте поля");
     }
 }
Beispiel #14
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("Такой номер полиса не зарегистрирован");
             }
         }
     }
 }
Beispiel #15
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);
        }
Beispiel #16
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);
     }
 }
Beispiel #17
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);
     }
 }
Beispiel #18
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);
     }
 }
Beispiel #19
0
 public void PhotoDelete(Newtonsoft.Json.Linq.JObject photo)
 {
     WorkWithDb.DeletePhoto(photo["nameImg"].ToString(), Convert.ToInt32(photo["idAlbum"]));
 }
Beispiel #20
0
        public string[] PostAktiveUser()
        {
            Users user = WorkWithDb.getInformationActiveUser();

            return(new string[] { user.Name, user.Surname, user.Email, user.FieldOfActivity, user.City });
        }
Beispiel #21
0
        public string serchActiveUserId()
        {
            int id = WorkWithDb.getInformationActiveUser().Id;

            return(id.ToString());
        }
Beispiel #22
0
        public int AddAlbum(Newtonsoft.Json.Linq.JObject album)
        {
            int id = WorkWithDb.AddAlbum(album["userId"].ToString(), album["nameOfAlbum"].ToString());

            return(id);
        }
Beispiel #23
0
 public string[] SearchAlbum(Newtonsoft.Json.Linq.JObject album)
 {
     string[] albums = WorkWithDb.SearchAlbum(album["userId"].ToString()).ToArray();
     return(albums);
 }
Beispiel #24
0
        public void PhotoDelete(Newtonsoft.Json.Linq.JObject photo)
        {
            string userId = HttpContext.Session.Get("userId").ToString();

            WorkWithDb.DeletePhoto(photo["nameImg"].ToString(), Convert.ToInt32(photo["idAlbum"]), userId);
        }
Beispiel #25
0
 public void AddComment(Newtonsoft.Json.Linq.JObject photo)
 {
     WorkWithDb.AddComment(Convert.ToInt32(photo["idPost"]), photo["text"].ToString());
 }
Beispiel #26
0
 public string[] AuthorNameAndImagePath(Newtonsoft.Json.Linq.JObject idPost)
 {
     string[] authorsPaths = WorkWithDb.AuthorNameAndImagePath(Convert.ToInt32(idPost["idPost"])).ToArray();
     return(authorsPaths);
 }
Beispiel #27
0
 public string[] SearchCommentsToPosts(Newtonsoft.Json.Linq.JObject idPost)
 {
     string[] comments = WorkWithDb.SearchComments(Convert.ToInt32(idPost["idPost"])).ToArray();
     return(comments);
 }
Beispiel #28
0
 public string[] searchImagesPosts()
 {
     string[] posts = WorkWithDb.SearchPosts().ToArray();
     return(posts);
 }
Beispiel #29
0
 public string[] SearchPhoto(Newtonsoft.Json.Linq.JObject idUser)
 {
     string[] array = WorkWithDb.PathPhoto(Convert.ToInt32(idUser["idActiveUers"]), Convert.ToInt32(idUser["idAlbum"])).ToArray();
     return(array);
 }
Beispiel #30
0
 public void AddPhoto(Newtonsoft.Json.Linq.JObject photo)
 {
     WorkWithDb.AddNewPhoto(photo["NameImg"].ToString(), photo["Path"].ToString(), Convert.ToInt32(photo["idAlbum"]));
 }