private void btnDodajStavke_Click(object sender, EventArgs e)
 {
     OtpremnicaDTO otpremnica = new OtpremnicaDTO();
     fillObject(otpremnica);
     VeleprodajaUtil.getDAOFactory().getOtpremnicaDAO().insert(otpremnica);
     fillOtpremnice();
 }
        public void updateObjectIznos(OtpremnicaDTO otpremnica)
        {
            MySqlConnection connection = ConnectionPool.checkOutConnection();
            MySqlCommand command = new MySqlCommand("iznosOtpremnice", connection);
            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Parameters.AddWithValue("rb", otpremnica.RedniBroj);
            command.Parameters["rb"].Direction = System.Data.ParameterDirection.Input;
            command.Parameters.AddWithValue("@velIznos", otpremnica.VeleprodajniIznos);
            command.Parameters["@velIznos"].Direction = System.Data.ParameterDirection.Output;
            command.Parameters.AddWithValue("@izSaRabatom", otpremnica.IznosSaRabatom);
            command.Parameters["@izSaRabatom"].Direction = System.Data.ParameterDirection.Output;
            command.Parameters.AddWithValue("@iznosRabata", otpremnica.IznosRabata);
            command.Parameters["@iznosRabata"].Direction = System.Data.ParameterDirection.Output;
            command.ExecuteNonQuery();
            try
            {
                otpremnica.IznosRabata = Convert.ToDouble(command.Parameters["@iznosRabata"].Value.ToString());
                otpremnica.IznosSaRabatom = Convert.ToDouble(command.Parameters["@izSaRabatom"].Value.ToString());
                otpremnica.VeleprodajniIznos = Convert.ToDouble(command.Parameters["@velIznos"].Value.ToString());
            }
            catch (Exception)
            {

            }

            ConnectionPool.checkInConnection(connection);
        }
 public StavkaOtpremniceDodajForm(OtpremnicaDTO otpremnica)
 {
     InitializeComponent();
     this.otpremnica = otpremnica;
     fillStavke();
     gbIzabranaRoba.Hide();
     fillOtpremnicaData();
     fillOtpremnicaValues();
 }
 public List<StavkaOtpremniceDTO> getByOtpremnica(OtpremnicaDTO otpremnica)
 {
     MySqlConnection connection = ConnectionPool.checkOutConnection();
     MySqlCommand command = connection.CreateCommand();
     command.CommandText = qGetByKalkulacija;
     command.Parameters.AddWithValue("RedniBroj", otpremnica.RedniBroj);
     MySqlDataReader reader = command.ExecuteReader();
     List<StavkaOtpremniceDTO> lista = new List<StavkaOtpremniceDTO>();
     while (reader.Read())
     {
         StavkaOtpremniceDTO stavka = readerToStavkaOtpremniceDTO(reader);
         stavka.Otpremnica = otpremnica;
         stavka.Roba = MySqlRobaDAO.readerToRobaDTO(reader);
         stavka.Roba.JedinicaMjere = MySqlJedinicaMjereDAO.readerToJedinicaMjereDTO(reader);
         lista.Add(stavka);
     }
     reader.Close();
     ConnectionPool.checkInConnection(connection);
     return lista;
 }
 private void fillObject(OtpremnicaDTO otpremnica)
 {
     otpremnica.Partner =(PartnerDTO) cbKupac.Items[cbKupac.SelectedIndex];
     otpremnica.Datum = dtpDatumOtpremnice.Value;
     otpremnica.PoslovnaGodina = VeleprodajaUtil.PoslovnaGodina;
 }
 private OtpremnicaDTO readerToOtpremnicaDTO(MySqlDataReader reader)
 {
     OtpremnicaDTO otpremnica = new OtpremnicaDTO(MySqlStavkaKnjigeTrgovineNaVeliko.readerToStavkaKnjigeTrgovineNaVeliko(reader));
     return otpremnica;
 }