示例#1
0
        public static void InsertShowing()
        {
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                try
                {
                    conn.Open();

                    SqlCommand cmd1 = new SqlCommand("InsertGrKundeInfo", conn);
                    cmd1.CommandType = CommandType.StoredProcedure;

                    Console.WriteLine("Indtast adresse:");
                    cmd1.Parameters.Add(new SqlParameter("@Adresse", Console.ReadLine()));
                    Console.WriteLine("Indtast postnummer:");
                    cmd1.Parameters.Add(new SqlParameter("@Postnr", Console.ReadLine()));
                    cmd1.Parameters.Add(new SqlParameter("@Dato", DateTime.Today));
                    Console.WriteLine("Indtast kundenavn:");
                    cmd1.Parameters.Add(new SqlParameter("@Kunde", Console.ReadLine()));
                    Console.WriteLine("Indtast telefonnummer:");
                    cmd1.Parameters.Add(new SqlParameter("@Telefonnummer", Console.ReadLine()));
                    int days = 2;
                    cmd1.Parameters.Add(new SqlParameter("@Kontaktdato", DateCalc.DateDay(days)));

                    cmd1.ExecuteNonQuery();
                }

                catch (SqlException e)
                {
                    Console.WriteLine("Fejl: " + e.Message);
                }
            }
        }
示例#2
0
        public static void InsertCustomer()
        {
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                try
                {
                    conn.Open();

                    SqlCommand cmd1 = new SqlCommand("InsertGrKundeInfo", conn);
                    cmd1.CommandType = CommandType.StoredProcedure;

                    Console.WriteLine("Indtast adresse:");
                    cmd1.Parameters.Add(new SqlParameter("@Adresse", Console.ReadLine()));
                    Console.WriteLine("Indtast postnummer:");
                    cmd1.Parameters.Add(new SqlParameter("@Postnr", Console.ReadLine()));
                    cmd1.Parameters.Add(new SqlParameter("@Dato", DateTime.Today));
                    Console.WriteLine("Indtast kundenavn:");
                    cmd1.Parameters.Add(new SqlParameter("@Kunde", Console.ReadLine()));
                    Console.WriteLine("Indtast telefonnummer:");
                    cmd1.Parameters.Add(new SqlParameter("@Telefonnummer", Console.ReadLine()));
                    Console.WriteLine("Indtast overtagelsesdato fra 1-12 måneder:");
                    string dato = Console.ReadLine();
                    cmd1.Parameters.Add(new SqlParameter("@Kontaktdato", DateCalc.FindDate(thedate = Convert.ToInt32(dato))));

                    cmd1.ExecuteNonQuery();
                }

                catch (SqlException e)
                {
                    Console.WriteLine("Fejl: " + e.Message);
                }
            }
        }