Example #1
0
        private bool Insert(MySqlTransaction trans)
        {
            if (trans == null)
            {
                return(false);
            }

            try
            {
                MySqlCommand command = new MySqlCommand("sp_Roba_Ins", trans.Connection, trans);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.Add(new MySqlParameter("pID", MySqlDbType.Int32)).Direction           = System.Data.ParameterDirection.Output;
                command.Parameters.Add(new MySqlParameter("pSifra", MySqlDbType.String)).Value           = this.Sifra;
                command.Parameters.Add(new MySqlParameter("pNaziv", MySqlDbType.String)).Value           = this.Naziv;
                command.Parameters.Add(new MySqlParameter("pProizvodjacID", MySqlDbType.Int32)).Value    = this.ProizvodjacID;
                command.Parameters.Add(new MySqlParameter("pFakturnaCijena", MySqlDbType.Decimal)).Value = this.FakturnaCijena;
                command.Parameters.Add(new MySqlParameter("pPDVStopaID", MySqlDbType.Int32)).Value       = this.PDVStopaID;
                //command.Parameters.Add(new MySqlParameter("pPocetnoStanje", MySqlDbType.Decimal)).Value = this.PocetnoStanje;
                //command.Parameters.Add(new MySqlParameter("pUlaz", MySqlDbType.Decimal)).Value = this.Ulaz;
                //command.Parameters.Add(new MySqlParameter("pIzlaz", MySqlDbType.Decimal)).Value = this.Izlaz;
                //command.Parameters.Add(new MySqlParameter("pZaliha", MySqlDbType.Decimal)).Value = this.Zaliha;
                command.Parameters.Add(new MySqlParameter("pATC", MySqlDbType.String)).Value = this.ATC;
                command.Parameters.Add(new MySqlParameter("pReferalnaCijena", MySqlDbType.Decimal)).Value = this.ReferalnaCijena;

                command.Parameters.Add(new MySqlParameter("pParticipacija", MySqlDbType.Int32)).Value = this.Participacija;
                command.Parameters.Add(new MySqlParameter("pOpis", MySqlDbType.String)).Value         = this.Opis;
                command.Parameters.Add(new MySqlParameter("pMPC", MySqlDbType.Decimal)).Value         = this.MPC;
                command.Parameters.Add(new MySqlParameter("pOznaka", MySqlDbType.String)).Value       = this.Oznaka;
                command.Parameters.Add(new MySqlParameter("pMjeraID", MySqlDbType.Int32)).Value       = this.MjeraID;
                command.Parameters.Add(new MySqlParameter("pKreatorID", MySqlDbType.Int32)).Value     = Global.Instance.LoggedKorisnik.ID;
                command.Parameters.Add(new MySqlParameter("pStopaMarze", MySqlDbType.Decimal)).Value  = this.StopaMarze;
                //command.Parameters.Add(new MySqlParameter("pDatumCijene", MySqlDbType.Date)).Value = this.DatumCijene;
                command.Parameters.Add(new MySqlParameter("pVrstaProskripcije", MySqlDbType.Int32)).Value = this.VrstaProskripcije;
                command.Parameters.Add(new MySqlParameter("pPoslovnaJedinica", MySqlDbType.Int32)).Value  = this.PoslovnaJedinica;
                command.Parameters.Add(new MySqlParameter("pTaksa", MySqlDbType.Bit)).Value = this.Taksa;

                command.ExecuteNonQuery();

                int id = (int)command.Parameters["pID"].Value;
                this.ID    = id;
                this.State = ObjectState.Existing;
                CacheSync.Sync <Roba>(this);
                return(true);
            }
            catch (SaveFailedException saveEx)
            {
                Logging.Log.Create("Insert (Transaction) Roba. Neko je vec promjenio podatke.",
                                   Logging.LogEntryLevel.Critical, saveEx);
                //throw saveEx;
            }
            catch (System.Exception ex)
            {
                Logging.Log.Create("Greska prilikom Save (Transaction) Robe.",
                                   Logging.LogEntryLevel.Critical, ex);
                //throw ex;
            }

            return(false);
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            var cachekey = context.Request["cachekey"];

            if (string.IsNullOrEmpty(cachekey))
            {
                AppAdapter.RemoveAllCache();
            }
            else
            {
                CacheSync.Rebuild(cachekey);
            }
        }
Example #3
0
        public static Mjera GetByID(int id)
        {
            if (!Global.Instance.DisableCache)
            {
                Mjera mjeraFromCache = CacheSync.Get <Mjera>(id) as Mjera;
                if (mjeraFromCache != null)
                {
                    return(mjeraFromCache);
                }
            }

            Mjera mjeraFromDb = ApotekeDB.Instance.GetMjera(id);

            if (!Global.Instance.DisableCache)
            {
                CacheSync.Sync <Mjera>(mjeraFromDb);
            }
            return(mjeraFromDb);
        }
Example #4
0
        public static TipRobe GetByID(int id)
        {
            if (!Global.Instance.DisableCache)
            {
                TipRobe tipRobeFromCache = CacheSync.Get <TipRobe>(id) as TipRobe;
                if (tipRobeFromCache != null)
                {
                    return(tipRobeFromCache);
                }
            }

            TipRobe tipRobeFromDb = ApotekeDB.Instance.GetTipRobe(id);

            if (!Global.Instance.DisableCache && tipRobeFromDb != null)
            {
                CacheSync.Sync <TipRobe>(tipRobeFromDb);
            }
            return(tipRobeFromDb);
        }
Example #5
0
        public static Roba GetByID(int id, bool forceFromDb)
        {
            if (!forceFromDb && !Global.Instance.DisableCache)
            {
                Roba robaFromCache = CacheSync.Get <Roba>(id) as Roba;
                if (robaFromCache != null)
                {
                    return(robaFromCache);
                }
            }

            Roba robaFromDb = ApotekeDB.Instance.GetRoba(id);

            if (!Global.Instance.DisableCache)
            {
                CacheSync.Sync <Roba>(robaFromDb);
            }
            return(robaFromDb);
        }
Example #6
0
        public static Komitent GetByID(int id)
        {
            if (!Global.Instance.DisableCache)
            {
                Komitent komitentFromCache = CacheSync.Get <Komitent>(id) as Komitent;
                if (komitentFromCache != null)
                {
                    return(komitentFromCache);
                }
            }

            Komitent komitentFromDb = ApotekeDB.Instance.GetKomitent(id);

            if (!Global.Instance.DisableCache)
            {
                CacheSync.Sync <Komitent>(komitentFromDb);
            }
            return(komitentFromDb);
        }
Example #7
0
        public static Korisnik GetByID(int id)
        {
            if (id == 0)
            {
                return(null);
            }

            if (!Global.Instance.DisableCache)
            {
                Korisnik korisnikFromCache = CacheSync.Get <Korisnik>(id) as Korisnik;
                if (korisnikFromCache != null)
                {
                    return(korisnikFromCache);
                }
            }

            Korisnik korisnikFromDb = ApotekeDB.Instance.GetKorisnik(id);

            if (!Global.Instance.DisableCache)
            {
                CacheSync.Sync <Korisnik>(korisnikFromDb);
            }
            return(korisnikFromDb);
        }
Example #8
0
        public static PDVStopa GetByID(int id)
        {
            if (id == 0)
            {
                return(null);
            }

            if (!Global.Instance.DisableCache)
            {
                PDVStopa pdvStopaFromCache = CacheSync.Get <PDVStopa>(id) as PDVStopa;
                if (pdvStopaFromCache != null)
                {
                    return(pdvStopaFromCache);
                }
            }

            PDVStopa pdvStopaFromDb = ApotekeDB.Instance.GetPDVStopa(id);

            if (!Global.Instance.DisableCache)
            {
                CacheSync.Sync <PDVStopa>(pdvStopaFromDb);
            }
            return(pdvStopaFromDb);
        }
Example #9
0
        public static MagistralaNalog GetByID(int id)
        {
            if (id == 0)
            {
                return(null);
            }

            if (!Global.Instance.DisableCache)
            {
                MagistralaNalog magNalogFromCache = CacheSync.Get <MagistralaNalog>(id) as MagistralaNalog;
                if (magNalogFromCache != null)
                {
                    return(magNalogFromCache);
                }
            }

            MagistralaNalog magNalogFromDb = ApotekeDB.Instance.GetMagistralaNalog(id);

            if (!Global.Instance.DisableCache && magNalogFromDb != null)
            {
                CacheSync.Sync <MagistralaNalog>(magNalogFromDb);
            }
            return(magNalogFromDb);
        }
Example #10
0
        public static Proizvodjac GetByID(int id)
        {
            if (id == 0)
            {
                return(null);
            }

            if (!Global.Instance.DisableCache)
            {
                Proizvodjac proizvodjacFromCache = CacheSync.Get <Proizvodjac>(id) as Proizvodjac;
                if (proizvodjacFromCache != null)
                {
                    return(proizvodjacFromCache);
                }
            }

            Proizvodjac proizvodjacFromDb = ApotekeDB.Instance.GetProizvodjac(id);

            if (!Global.Instance.DisableCache && proizvodjacFromDb != null)
            {
                CacheSync.Sync <Proizvodjac>(proizvodjacFromDb);
            }
            return(proizvodjacFromDb);
        }
Example #11
0
        public static Smjena GetByID(int id)
        {
            if (id == 0)
            {
                return(null);
            }

            if (!Global.Instance.DisableCache)
            {
                Smjena smjenaFromCache = CacheSync.Get <Smjena>(id) as Smjena;
                if (smjenaFromCache != null)
                {
                    return(smjenaFromCache);
                }
            }

            Smjena smjenaFromDb = ApotekeDB.Instance.GetSmjena(id);

            if (!Global.Instance.DisableCache)
            {
                CacheSync.Sync <Smjena>(smjenaFromDb);
            }
            return(smjenaFromDb);
        }
Example #12
0
        private bool Update(MySqlTransaction trans)
        {
            if (trans == null)
            {
                return(false);
            }

            try
            {
                MySqlCommand command = new MySqlCommand("sp_Roba_Upd", trans.Connection, trans);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.Add(new MySqlParameter("pID", MySqlDbType.Int32)).Value                = this.ID;
                command.Parameters.Add(new MySqlParameter("pSifra", MySqlDbType.String)).Value            = this.Sifra;
                command.Parameters.Add(new MySqlParameter("pNaziv", MySqlDbType.String)).Value            = this.Naziv;
                command.Parameters.Add(new MySqlParameter("pProizvodjacID", MySqlDbType.Int32)).Value     = this.ProizvodjacID;
                command.Parameters.Add(new MySqlParameter("pFakturnaCijena", MySqlDbType.Decimal)).Value  = this.FakturnaCijena;
                command.Parameters.Add(new MySqlParameter("pPDVStopaID", MySqlDbType.Int32)).Value        = this.PDVStopaID;
                command.Parameters.Add(new MySqlParameter("pPocetnoStanje", MySqlDbType.Decimal)).Value   = this.PocetnoStanje;
                command.Parameters.Add(new MySqlParameter("pUlaz", MySqlDbType.Decimal)).Value            = this.Ulaz;
                command.Parameters.Add(new MySqlParameter("pIzlaz", MySqlDbType.Decimal)).Value           = this.Izlaz;
                command.Parameters.Add(new MySqlParameter("pZaliha", MySqlDbType.Decimal)).Value          = this.Zaliha;
                command.Parameters.Add(new MySqlParameter("pATC", MySqlDbType.String)).Value              = this.ATC;
                command.Parameters.Add(new MySqlParameter("pReferalnaCijena", MySqlDbType.Decimal)).Value = this.ReferalnaCijena;
                command.Parameters.Add(new MySqlParameter("pParticipacija", MySqlDbType.Int32)).Value     = this.Participacija;
                command.Parameters.Add(new MySqlParameter("pOpis", MySqlDbType.String)).Value             = this.Opis;
                command.Parameters.Add(new MySqlParameter("pMPC", MySqlDbType.Decimal)).Value             = this.MPC;
                command.Parameters.Add(new MySqlParameter("pOznaka", MySqlDbType.String)).Value           = this.Oznaka;
                command.Parameters.Add(new MySqlParameter("pMjeraID", MySqlDbType.Int32)).Value           = this.MjeraID;
                command.Parameters.Add(new MySqlParameter("pModifikatorID", MySqlDbType.Int32)).Value     = this.ModifikatorID;
                command.Parameters.Add(new MySqlParameter("pStopaMarze", MySqlDbType.Decimal)).Value      = this.StopaMarze;
                command.Parameters.Add(new MySqlParameter("pDatumCijene", MySqlDbType.Date)).Value        = this.DatumCijene;
                command.Parameters.Add(new MySqlParameter("pVrstaProskripcije", MySqlDbType.Int32)).Value = this.VrstaProskripcije;
                command.Parameters.Add(new MySqlParameter("pTaksa", MySqlDbType.Bit)).Value               = this.Taksa;
                command.Parameters.Add(new MySqlParameter("pTipRobeID", MySqlDbType.Int32)).Value         = this.TipRobeID;

                if (this.VrijemeModificiranja.Year == 1 && this.VrijemeModificiranja.Month == 1 &&
                    this.VrijemeModificiranja.Day == 1)
                {
                    command.Parameters.Add(new MySqlParameter("pVrijemeModifikacije", MySqlDbType.DateTime)).Value = null;
                }
                else
                {
                    command.Parameters.Add(new MySqlParameter("pVrijemeModifikacije", MySqlDbType.DateTime)).Value = this.VrijemeModificiranja;
                }

                //command.Parameters.Add(new MySqlParameter("pVrijemeModifikacije", MySqlDbType.DateTime)).Value = DateTime.Now;
                command.Parameters["pVrijemeModifikacije"].Direction = System.Data.ParameterDirection.InputOutput;
                command.Parameters.Add(new MySqlParameter("pError", MySqlDbType.Int32)).Direction = System.Data.ParameterDirection.Output;

                command.ExecuteNonQuery();

                int pError = (int)command.Parameters["pError"].Value;
                this.VrijemeModificiranja = (DateTime)command.Parameters["pVrijemeModifikacije"].Value;

                if (pError == -1)
                {
                    throw new SaveFailedException("Neko je vec promjenio podatke.");
                }
                //throw new ApplicationException("OBARANJE APPLIKACIJE");

                CacheSync.Sync <Roba>(this);
                return(true);
            }
            catch (SaveFailedException saveEx)
            {
                //throw saveEx;
            }
            catch (System.Exception ex)
            {
                Logging.Log.Create("Greska prilikom Save (Transaction) Robe.",
                                   Logging.LogEntryLevel.Critical, ex);
                //throw ex;
            }

            return(false);
        }