Exemplo n.º 1
0
 public void SetOgraniczenieSprzedazyStan(EnovaContext ec, Web.WebContext lc, int stanMagazynu)
 {
     if (ec != null)
     {
         Feature feature = this.Features.Where(f => f.Name == "STAN MAGAZYNU").FirstOrDefault();
         if (feature != null)
         {
             feature.Data = stanMagazynu.ToString();
             ec.SaveChanges();
             if (stanMagazynu <= 0)
             {
                 this.UstawDostepnosc(ec, lc, false);
             }
         }
     }
 }
Exemplo n.º 2
0
        public Image GetImage()
        {
            Image image = null;

            try
            {
                if (this.ImageBytes != null)
                {
                    using (MemoryStream ms = new MemoryStream(this.ImageBytes))
                        image = Image.FromStream(ms);
                }
                else
                {
                    string file = this.GetFileName();
                    if (file != null && File.Exists(file))
                    {
                        image = Image.FromFile(file);

                        using (MemoryStream ms = new MemoryStream())
                        {
                            image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                            using (var dc = new WebContext())
                            {
                                var img = dc.Zdjecia.Where(z => z.ID == this.ID).FirstOrDefault();
                                img.ImageBytes = ms.ToArray();
                                dc.OptimisticSaveChanges();
                            }
                            if (this.DbContext != null)
                            {
                                this.DbContext.Refresh(RefreshMode.StoreWins, this);
                            }
                        }
                    }
                }
            }
            catch
            {
            }

            return(image);
        }
Exemplo n.º 3
0
        private void TowaryForm_Load(object sender, EventArgs e)
        {
            var dostawcy = new List <DostawcaInfo>();

            dostawcy.Add(new DostawcaInfo()
            {
                ID = 0, Nazwa = "Wszyscy"
            });
            if (!this.DesignMode)
            {
                using (var dc = new Enova.Business.Old.DB.Web.WebContext())
                {
                    dostawcy.AddRange(from d in dc.Dostawcy orderby d.Nazwa select new DostawcaInfo()
                    {
                        ID = d.ID, Nazwa = d.Nazwa
                    });
                }
            }
            disableDostawcaChanged           = true;
            dostawcaBindingSource.DataSource = dostawcy;
            dostawcaComboBox.SelectedIndex   = 0;
            disableDostawcaChanged           = false;
        }
Exemplo n.º 4
0
        protected void OnSaved(WebContext dc)
        {
            if (!this.Deleted)
            {
                var h = OstatniaHistoriaDokumentu;

                if (h != null)
                {
                    if (this.OstatniaHistoriaID == null || this.OstatniaHistoriaID != h.ID)
                    {
                        this.OstatniaHistoriaID         = h.ID;
                        this.OstatniaHistoriaOperatorID = h.Operator != null ? h.Operator.ID : 0;
                        this.OstatniStatusID            = h.Status != null ? h.Status.ID : 0;
                    }
                }

                if (this is INumerDokumentu)
                {
                    var n = (INumerDokumentu)this;
                    if (n.Numer.Numer == 0)
                    {
                        var symbol = this.Numer.Symbol;
                        if (!dc.Reklamacje.Any(r => r.Numer.Symbol == symbol))
                        {
                            this.Numer.Numer = 1;
                        }
                        else
                        {
                            var last = dc.Reklamacje.Where(r => r.Numer.Symbol == symbol).Max(r => r.Numer.Numer);
                            this.Numer.Numer = last + 1;
                        }

                        n.Numer.NumerPelny = n.Numer.CalcNumerPelny();
                    }
                }
            }
        }
Exemplo n.º 5
0
 public GridViewBaseWithDbContext(DBWeb.WebContext dbContext)
 {
     this.dbContext = dbContext;
 }
Exemplo n.º 6
0
        private void zatwierdźButton_Click(object sender, EventArgs e)
        {
            Enabled = false;
            Cursor  = Cursors.WaitCursor;

            string przedstawiciel = kontrahentSelect.Przedstawiciel;
            string trasa          = kontrahentSelect.Trasa;

            Enova.API.CRM.Kontrahent kontrahent = kontrahentSelect.Kontrahent;
            FeatureDef featureDef = featureGroupSelect.DefinicjaCechy;
            string     grupa      = featureDef.Name;
            string     słownik    = featureDef.Dictionary;
            DateTime   dateFrom1  = okres1dateSpan.DateFrom;
            DateTime   dateTo1    = okres1dateSpan.DateTo;
            DateTime   dateFrom2  = okres2DateSpan.DateFrom;
            DateTime   dateTo2    = okres2DateSpan.DateTo;

            List <Enova.Business.Old.Types.ObrotyWgGrupTowarowych> reportSource = null;


            if (string.IsNullOrEmpty(trasa) || kontrahent != null)
            {
                var obroty = (from o in DataContext.ObrotyByKontrahent(przedstawiciel, kontrahent)
                              join f in DataContext.FeaturesByDef("Towary", grupa) on o.Towar.ID equals f.Parent
                              where o.Data >= dateFrom1 && o.Data <= dateTo1
                              group o by new { Grupa = f.Data, KontrahentID = o.RozchodKontrahent.ID } into g
                              select new ObrotyWgGrupTowarowych()
                {
                    GrupaTowarowa = g.Key.Grupa,
                    IDKontrahenta = g.Key.KontrahentID,
                    KodKontrahenta = g.FirstOrDefault().RozchodKontrahent.Kod,
                    NazwaKontrahenta = g.FirstOrDefault().RozchodKontrahent.NazwaStr,
                    ObrótNettoI = g.Sum(ob => ob.RozchodWartosc),
                    ObrótNettoII = 0
                }).ToList();

                using (var lc = new DBWeb.WebContext())
                {
                    lc.CommandTimeout = int.MaxValue;
                    int?kontrahentID = kontrahent == null ? (int?)null : kontrahent.ID;
                    foreach (var f in DataContext.FeaturesByDef("Towary", grupa).ToList())
                    {
                        var towar = DataContext.Towary.Where(t => t.ID == f.Parent).FirstOrDefault();

                        var pozycje = (from pz in lc.PozycjeZamowien
                                       where
                                       pz.Zamowienie.DataDodania >= dateFrom2 && pz.Zamowienie.DataDodania <= dateTo2 &&
                                       pz.Zamowienie.Synchronizacja != (int)RowSynchronizeOld.NotsynchronizedDelete &&
                                       pz.Zamowienie.Synchronizacja != (int)RowSynchronizeOld.Notsaved &&
                                       pz.Zamowienie.Synchronizacja != (int)RowSynchronizeOld.Synchronizing &&
                                       (pz.ProduktIndywidualny == null || pz.ProduktIndywidualny == false) && pz.Produkt.EnovaGuid == towar.Guid && pz.Ilosc > 0 &&
                                       (kontrahentID == null || pz.Zamowienie.Kontrahent.ID == kontrahentID) &&
                                       (przedstawiciel == null || pz.Zamowienie.Kontrahent.Przedstawiciel.Kod == przedstawiciel)
                                       select pz).ToList();

                        foreach (var poz in pozycje)
                        {
                            var     kontr   = DataContext.Kontrahenci.Where(k => k.Guid == poz.Zamowienie.Kontrahent.Guid).FirstOrDefault();
                            decimal wartosc = (decimal)(poz.Ilosc == null ? 0 : poz.Ilosc.Value) * (poz.Cena == null ? 0 : poz.Cena.Value) * (1 - (poz.Rabat == null ? 0 : poz.Rabat.Value));

                            obroty.Add(new ObrotyWgGrupTowarowych()
                            {
                                GrupaTowarowa    = f.Data,
                                IDKontrahenta    = kontr.ID,
                                KodKontrahenta   = kontr.Kod,
                                NazwaKontrahenta = kontr.NazwaStr,
                                ObrótNettoI      = 0,
                                ObrótNettoII     = decimal.Round(wartosc, 2)
                            });
                        }
                    }
                }

                reportSource = (from o in obroty
                                group o by new { o.GrupaTowarowa, o.IDKontrahenta } into g
                                select new ObrotyWgGrupTowarowych()
                {
                    GrupaTowarowa = g.Key.GrupaTowarowa,
                    IDKontrahenta = g.Key.IDKontrahenta,
                    KodKontrahenta = g.FirstOrDefault().KodKontrahenta,
                    NazwaKontrahenta = g.FirstOrDefault().NazwaKontrahenta,
                    ObrótNettoI = g.Sum(o => o.ObrótNettoI),
                    ObrótNettoII = g.Sum(o => o.ObrótNettoII)
                }).ToList();
            }
            else
            {
            }

            reportViewer.LocalReport.ReportPath = "Reports\\ObrotyWgGrupTowarowychReport.rdlc";
            reportViewer.LocalReport.DataSources.Clear();
            reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("ObrotyWgGrupTowarowych", reportSource));
            reportViewer.RefreshReport();


            Cursor  = Cursors.Default;
            Enabled = true;
        }
Exemplo n.º 7
0
        /*
         * public static StatusZwrotu GetByTyp(TypStatusuZwrotu typ)
         * {
         *  return ContextManager.WebContext.StatusyZwrotow.Where(sz => sz.Typ == (int)typ).FirstOrDefault();
         * }
         */

        public static StatusZwrotu GetByTyp(WebContext dc, TypStatusuZwrotu typ)
        {
            return(dc.StatusyZwrotow.Where(sz => sz.Typ == (int)typ).FirstOrDefault());
        }
Exemplo n.º 8
0
 public static KategoriaOld GetRoot(WebContext dc)
 {
     return(dc.KategorieOld.Where(k => k.PoziomGlebokosci == 0).FirstOrDefault());
 }
Exemplo n.º 9
0
 public static KategoriaOld GetEnovaRoot(WebContext dc)
 {
     return(dc.KategorieOld.Where(k => k.GUID == enovaRootGuid).FirstOrDefault());
 }
Exemplo n.º 10
0
 public void UstawDostepnosc(EnovaContext ec, Web.WebContext lc, bool dostepnosc)
 {
 }
Exemplo n.º 11
0
 public Operator GetOperator(WebContext dc)
 {
     return(dc.Operatorzy.Where(r => r.ID == this.ID).FirstOrDefault());
 }
Exemplo n.º 12
0
 public HistoriaDokumentuCollection(WebContext dc, IDokumentZHistoria dokument)
 {
     dbContext     = dc;
     this.dokument = dokument;
     added         = new List <HistoriaDokumentu>();
 }