Exemplo n.º 1
0
 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("Исправте поля");
     }
 }
Exemplo n.º 2
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);
        }