Ejemplo n.º 1
0
 public void Add(TypeReklama customer)
 {
     try
     {
         using (var conn = GetConnection())
         {
             conn.Open();
             using (var cmd = conn.CreateCommand())
             {
                 cmd.CommandText = "INSERT INTO TypeReklama(IDCarrier, Cost,  NameReklama, Note, Position) VALUES(@IDCarrier, @Cost, @NameReklama, @Note, @Position)";
                 cmd.Parameters.AddWithValue("@IDCarrier", customer.CarrierForReklama);
                 cmd.Parameters.AddWithValue("@Cost", customer.Cost);
                 //cmd.Parameters.AddWithValue("@IDTypeReklama", customer.IDTypeReklama);
                 cmd.Parameters.AddWithValue("@NameReklama", customer.NameReklama);
                 cmd.Parameters.AddWithValue("@Note", customer.Note);
                 cmd.Parameters.AddWithValue("@Position", customer.Position);
                 cmd.ExecuteNonQuery();
             }
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message, "Ошибка");
     }
 }
Ejemplo n.º 2
0
 public void Update(TypeReklama customer)
 {
     try
     {
         using (var conn = GetConnection())
         {
             conn.Open();
             using (var cmd = conn.CreateCommand())
             {
                 cmd.CommandText = "UPDATE TypeReklama SET IDCarrier = @IDCarrier, Cost = @Cost, NameReklama=@NameReklama, Note=@Note, Position=@Position WHERE IDTypeReklama = @ID1";
                 cmd.Parameters.AddWithValue("@IDCarrier", customer.CarrierForReklama);
                 cmd.Parameters.AddWithValue("@Cost", customer.Cost);
                 cmd.Parameters.AddWithValue("@ID1", customer.IDTypeReklama);
                 cmd.Parameters.AddWithValue("@NameReklama", customer.NameReklama);
                 cmd.Parameters.AddWithValue("@Note", customer.Note);
                 cmd.Parameters.AddWithValue("@Position", customer.Position);
                 cmd.ExecuteNonQuery();
             }
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message, "Ошибка");
     }
 }
Ejemplo n.º 3
0
        private static TypeReklama LoadReklama(SqlDataReader reader)
        {
            TypeReklama reklama = new TypeReklama();

            try
            {
                reklama.CarrierForReklama = reader.GetInt32(reader.GetOrdinal("IDCarrier"));
                reklama.Cost = (float)reader.GetDouble(reader.GetOrdinal("Cost"));
                //???
                reklama.IDTypeReklama = reader.GetInt32(reader.GetOrdinal("IDTypeReklama"));
                ///
                reklama.NameReklama = reader.GetString(reader.GetOrdinal("NameReklama"));
                reklama.Note        = reader.GetString(reader.GetOrdinal("Note"));
                reklama.Position    = reader.GetString(reader.GetOrdinal("Position"));
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Ошибка");
            }

            return(reklama);
        }