private void ButtonDodajBrod_Click(object sender, EventArgs e)
      {
          if (string.IsNullOrWhiteSpace(TextBoxRegOznaka.Text) || TextBoxRegOznaka.Text == "npr. PU-243")
          {
              MetroFramework.MetroMessageBox.Show(this, "Niste unijeli regstracijsku oznaku broda", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Error);
          }

          else if (string.IsNullOrWhiteSpace(TextBoxImeBroda.Text))
          {
              MetroFramework.MetroMessageBox.Show(this, "Niste unijeli ime broda", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Error);
          }

          else if (ComboBoxVrstaBroda.Text == "--odaberi vrstu--")
          {
              MetroFramework.MetroMessageBox.Show(this, "Niste odabrali vrstu broda", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Error);
          }

          else
          {
              Brod novibrod = new Brod(TextBoxImeBroda.Text, TextBoxRegOznaka.Text, ComboBoxVrstaBroda.Text, idKBroda);

              DBBrod.DodajBrod(novibrod);
              MetroFramework.MetroMessageBox.Show(this, "Uspješno ste dodali novi brod", "Informacija", MessageBoxButtons.OK, MessageBoxIcon.Information);

              dgBrodovi.DataSource = null;
              brodPrikaz           = DBBrod.DohvatiBrodove(idKBroda);
              var brodoviPresenter = new ObservableCollection <BrodPresenter>(BrodPresenter.ToPresenter(brodPrikaz));
              dgBrodovi.DataSource = brodoviPresenter;
          }
      }
示例#2
0
        public static List <Brod> DohvatiBrodove(long idKBroda)
        {
            List <Brod>   listBrod = new List <Brod>();
            SQLiteCommand c        = Bazapodataka.con.CreateCommand();

            c.CommandText = string.Format("SELECT Brod.id, Brod.ime, Brod.reg_oznaka, vrsta FROM Brod WHERE Brod.id_kapetan= '{0}'", idKBroda);

            SQLiteDataReader reader = c.ExecuteReader();

            while (reader.Read())
            {
                Brod k = new Brod();
                k.id      = (long)reader["id"];
                k.Ime     = (string)reader["ime"];
                k.Reg_Ozn = (string)reader["reg_oznaka"];
                k.Vrsta   = (string)reader["vrsta"];

                listBrod.Add(k);
            }

            reader.Dispose();
            c.Dispose();

            return(listBrod);
        }
示例#3
0
        public static void DodajBrod(Brod a)
        {
            SQLiteCommand c = Bazapodataka.con.CreateCommand();

            c.CommandText = String.Format(@"INSERT INTO Brod (ime, reg_oznaka, vrsta,id_kapetan)
                    VALUES ('{0}', '{1}', '{2}', '{3}')", a.Ime, a.Reg_Ozn, a.Vrsta, a.IDKBroda);

            c.ExecuteNonQuery();
            c.Dispose();
        }
示例#4
0
        public static List <Brod> DohvatiBrodSRadnicima(long idKBroda)
        {
            List <Brod>   listBrod = new List <Brod>();
            SQLiteCommand c        = Bazapodataka.con.CreateCommand();

            c.CommandText = string.Format(@" SELECT Brod.ime, Brod.id from Brod, Radnik WHERE Brod.id = Radnik.id_brod AND Radnik.id_kapetan = '{0}'
                                              AND Radnik.id_brod IS NOT NULL GROUP by Brod.id", idKBroda);

            SQLiteDataReader reader = c.ExecuteReader();

            while (reader.Read())
            {
                Brod k = new Brod();
                k.id  = (long)reader["id"];
                k.Ime = (string)reader["ime"];
                listBrod.Add(k);
            }
            reader.Dispose();
            c.Dispose();

            return(listBrod);
        }
 public BrodPresenter(Brod stavka)
 {
     this.model = stavka;
 }