예제 #1
0
        private int AddDirectoryToDB(string path, PSContext db)
        {
            Directory directory = new Directory()
            {
                FileDirectory = path
            };

            db.Directory.Add(directory);
            db.SaveChanges();
            directoryList.Add(directory.FileDirectory, directory.Id);
            return(directory.Id);
        }
예제 #2
0
        public List <OpstiDomenskiObjekat> pretraziProizvode(OpstiDomenskiObjekat o)
        {
            Roba r = o as Roba;
            List <OpstiDomenskiObjekat> objekti = new List <OpstiDomenskiObjekat>();

            using (var context = new PSContext())
            {
                context.StavkeOtpremnice.Where(x => x.RobaID == r.RobaID).ToList().ForEach(a => objekti.Add(a));
                context.StavkePrijemnice.Where(x => x.RobaID == r.RobaID).ToList().ForEach(a => objekti.Add(a));
            }
            return(objekti);
        }
예제 #3
0
 private void AddToDB(PictureInfo pictureInfo)
 {
     using (var db = new PSContext(_config.DBConnection))
     {
         var checkDirectoryIsOnList = directoryList.TryGetValue(pictureInfo.Path, out int directoryId);
         if (!checkDirectoryIsOnList)
         {
             directoryId = AddDirectoryToDB(pictureInfo.Path, db);
         }
         AddPictureToDB(pictureInfo, directoryId, db);
     };
 }
예제 #4
0
 public bool kreirajRevers(Revers r)
 {
     using (var conext = new PSContext())
     {
         conext.Revers.Add(r);
         if (conext.SaveChanges() == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
예제 #5
0
        public static TypeOfEntity GetExportType(this EntityType type, PSContext ctx)
        {
            if (ctx.EntityTypes.ProjectEntity.Name == type.Name)
            {
                return(TypeOfEntity.Project);
            }
            else if (ctx.EntityTypes.TaskEntity.Name == type.Name)
            {
                return(TypeOfEntity.Task);
            }
            else if (ctx.EntityTypes.ResourceEntity.Name == type.Name)
            {
                return(TypeOfEntity.Resource);
            }

            return(TypeOfEntity.Undefined);
        }
 public static ExportEnterpriseField GetExportField(this CustomField cf, PSContext ctx)
 {
     return(new ExportEnterpriseField()
     {
         Id = cf.Id,
         Name = cf.Name,
         Description = cf.Description,
         EntityType = cf.EntityType.GetExportType(ctx),
         FieldType = cf.FieldType,
         Formula = cf.Formula,
         IsEditableInVisibility = cf.IsEditableInVisibility,
         IsMultilineText = cf.IsMultilineText,
         IsRequired = cf.IsRequired,
         IsWorkflowControlled = cf.IsWorkflowControlled,
         LookupAllowMultiSelect = cf.LookupAllowMultiSelect,
         LookupDefaultValue = cf.LookupDefaultValue,
         LookupTable = (bool)cf.LookupTable.ServerObjectIsNull ? null : cf.LookupTable?.Id
     });
 }
예제 #7
0
        public bool Edit(Poliza entidad)
        {
            using (PSContext cnx = new PSContext())
            {
                Poliza poliza = cnx.Polizas.Find(entidad.IdPoliza);

                if (poliza != null)
                {
                    poliza.IdTipoRiesgo        = entidad.IdTipoRiesgo;
                    poliza.NombrePoliza        = entidad.NombrePoliza;
                    poliza.PrecioPoliza        = entidad.PrecioPoliza;
                    poliza.FechaInicioVigencia = entidad.FechaInicioVigencia;
                    poliza.DescripcionPoliza   = entidad.DescripcionPoliza;
                    cnx.SaveChanges();
                    return(true);
                }

                return(false);
            }
        }
        public bool IzvrsiSo(OpstiDomenskiObjekat odo)
        {
            bool rezultat;

            using (var context = new PSContext())
            {
                using (var transaction = context.Database.BeginTransaction())
                {
                    rezultat = izvrsi(odo);
                    if (rezultat)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        transaction.Rollback();
                    }
                }
            }
            return(rezultat);
        }
 public static ExportLookupTable GetExportTable(this LookupTable t, PSContext ctx)
 {
     return(new ExportLookupTable()
     {
         Id = t.Id,
         Name = t.Name,
         Entries = t.Entries.Select(e => new ExportLookupText()
         {
             FullValue = e.FullValue,
             Id = e.Id
         }).ToList(),
         FieldType = t.FieldType,
         Masks = t.Masks.Select(m => new ExportLookupMask()
         {
             MaskType = m.MaskType,
             Length = m.Length,
             Separator = m.Separator
         }).ToList(),
         SortOrder = t.SortOrder
     });
 }
예제 #10
0
        private void AddPictureToDB(PictureInfo p, int directoryId, PSContext db)
        {
            Picture picture = new Picture()
            {
                DirectoryId      = directoryId,
                CenterBottom     = p.CenterBottom,
                CenterCenter     = p.CenterCenter,
                CenterTop        = p.CenterTop,
                LeftBottom       = p.LeftBottom,
                LeftCenter       = p.LeftCenter,
                LeftTop          = p.LeftTop,
                RightBottom      = p.RightBottom,
                RightCenter      = p.RightCenter,
                RightTop         = p.RightTop,
                FileName         = p.FileName,
                CreationFileDate = p.CreationFileDate,
            };

            db.Picture.Add(picture);
            db.SaveChanges();
        }
        private void bSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                PSContext.IsOnline = rbOnline.Checked;
                PSContext.PSUrl    = tbUrl.Text;
                PSContext.UserName = tbUsername.Text;
                PSContext.Password = tbPass.Text;
                PSContext.Domain   = tbDomain.Text;

                using (var ctx = new PSContext())
                {
                    this.Hide();
                    ExportImportForm form = new ExportImportForm();
                    form.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #12
0
        public bool sacuvajOtpremnicu(OpstiDomenskiObjekat o)
        {
            Otpremnica otpremnica = o as Otpremnica;

            try
            {
                using (var context = new PSContext())
                {
                    using (var transakcija = context.Database.BeginTransaction())
                    {
                        //otpremnica.KupacID = otpremnica.Kupac.KupacID;
                        //otpremnica.Kupac = null;
                        foreach (StavkaOtpremnice item in otpremnica.Stavke)
                        {
                            //item.RobaID = item.Roba.RobaID;
                            //item.Roba = null;
                        }
                        context.Dokumenti.Add(otpremnica);
                        if (context.SaveChanges() > 0)
                        {
                            transakcija.Commit();
                            return(true);
                        }
                        else
                        {
                            transakcija.Rollback();
                            return(false);
                        }
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
 public PutProductCommandHandler(PSContext context)
 {
     _context = context;
 }
 public DeleteProductCommandHandler(PSContext context)
 {
     _context = context;
 }
예제 #15
0
 public GetProductQueryHandler(PSContext context)
 {
     _context = context;
 }