public static string Add(string company, string contact, string contacttit, string add, string city, string region, string code,
                             string country, string phone, string fax)
    {
        try
        {
            Supplier aSupplier = new Supplier
            {
                companyname  = company,
                contactname  = contact,
                contacttitle = contacttit,
                address      = add,
                city         = city,
                region       = region,
                postalcode   = code,
                country      = country,
                phone        = phone,
                fax          = fax
            };

            context.Suppliers.Add(aSupplier);
            context.SaveChanges();
            return("Add successful");
        }
        catch (Exception ex)
        {
            return(ex.Message);
        }
    }
Esempio n. 2
0
        public IHttpActionResult PutMISROT_LEMORIM(long id, MISROT_LEMORIM mISROT_LEMORIM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != mISROT_LEMORIM.SEQ_NUM)
            {
                return(BadRequest());
            }

            db.Entry(mISROT_LEMORIM).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MISROT_LEMORIMExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 3
0
        public ActionResult Edit(int id, Course courseToUpdate)
        {
            try
            {
                Course originalCourse = this.dbContext.Courses.FirstOrDefault(course => course.CourseId == id);
                originalCourse.CourseName = courseToUpdate.CourseName;
                originalCourse.Yardage    = courseToUpdate.Yardage;
                originalCourse.Tee        = courseToUpdate.Tee;
                originalCourse.Slope      = courseToUpdate.Slope;
                originalCourse.Rating     = courseToUpdate.Rating;
                originalCourse.Address1   = courseToUpdate.Address1;
                originalCourse.Address2   = courseToUpdate.Address2;
                originalCourse.City       = courseToUpdate.City;
                originalCourse.State      = courseToUpdate.State;
                originalCourse.Zip        = courseToUpdate.Zip;
                originalCourse.Website    = courseToUpdate.Website;
                originalCourse.Phone      = courseToUpdate.Phone;
                originalCourse.Notes      = courseToUpdate.Notes;

                dbContext.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
    public static string Add(string lastname, string firstname, string title, string titleOfCourtesy, string birthdate, string hiredate, string address, string city, string region, string postalcode, string country, string phone, string manager)
    {
        try
        {
            Employee aEmployee = new Employee()
            {
                lastname        = lastname,
                firstname       = firstname,
                title           = title,
                titleofcourtesy = titleOfCourtesy,
                birthdate       = DateTime.Parse(birthdate),
                hiredate        = DateTime.Parse(hiredate),
                address         = address,
                city            = city,
                region          = region,
                postalcode      = postalcode,
                country         = country,
                phone           = phone,
                //mgrid = manager
            };
            if (!manager.Equals("0"))
            {
                aEmployee.mgrid = int.Parse(manager);
            }

            context.Employees.Add(aEmployee);
            context.SaveChanges();
            return("Add sưccessful");
        }
        catch (Exception e)
        {
            return("Can't add! Please try again");
        }
    }
        public void AddKategori(KategoriCreateEditViewModel model)
        {
            var kategori = new Kategori()
            {
                Nama = model.Nama
            };

            context.Add(kategori);
            context.SaveChanges();
        }
        public void AddPembelian(PembelianCreateEditViewModel model)
        {
            var pembelian = new Pembelian()
            {
                ID = model.ID,
                TanggalPembelian = model.Tanggal
            };

            context.Add(pembelian);
            context.SaveChanges();
        }
        public void AddDetailPembelian(PembelianDetailCreateEditViewModel model)
        {
            var pembelian = new DetilPembelian()
            {
                PembelianID = model.PembelianID,
                BarangID    = model.BarangID
            };

            context.Add(pembelian);
            context.SaveChanges();
        }
        public void AddLokasi(LokasiCreateEditViewModel model)
        {
            var lokasi = new Lokasi()
            {
                NomorRak = model.NomorRak,
                NomorBay = model.NomorBay
            };

            context.Add(lokasi);
            context.SaveChanges();
        }
Esempio n. 9
0
    public static string Add(string name, string phone)
    {
        Shipper aShipper = new Shipper
        {
            companyname = name,
            phone       = phone
        };

        context.Shippers.Add(aShipper);
        context.SaveChanges();
        return("Add successful");
    }
    public static string Add(string name, string des)
    {
        Category aCategory = new Category
        {
            categoryname = name,
            description  = des
        };

        context.Categories.Add(aCategory);
        context.SaveChanges();
        return("Add successful");
    }
Esempio n. 11
0
        public void AddBarang(BarangCreateEditViewModel model)
        {
            var barang = new Barang()
            {
                Nama       = model.Nama,
                HargaBeli  = model.HargaBeli,
                HargaJual  = model.HargaJual,
                LokasiID   = model.LokasiID,
                KategoriID = model.KategoriID
            };

            context.Add(barang);
            context.SaveChanges();
        }
Esempio n. 12
0
 /// <summary>
 /// Update
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Update(ConnectionModel model)
 {
     try {
         using (var e = new EntitiesModel()) {
             if (e.Connections.Where(c => c.ConnectionId == model.ConnectionId).Count() != 0)
             {
                 var connection = e.Connections.Where(c => c.ConnectionId == model.ConnectionId).FirstOrDefault();
                 connection.Connected     = model.Connected;
                 connection.Description   = model.Description;
                 connection.Port          = model.Port;
                 connection.Server        = model.Server;
                 connection.UserId        = model.UserId;
                 connection.Monitoring    = model.Monitoring;
                 connection.ServiceTypeId = model.ServiceTypeId;
                 e.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     } catch (Exception ex) {
         throw ex;
     }
 }
Esempio n. 13
0
 /// <summary>
 /// Register
 /// </summary>
 /// <param name="emailAddress"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public int Register(string emailAddress, string password) {
     try {
         using (var e = new EntitiesModel()) {
             if (e.Users.Where(u => u.EmailAddress == emailAddress).Count() == 0) {
                 var user = new User();
                 user.EmailAddress = emailAddress;
                 user.Password = Crypto.EncryptStringAES(password, ;
                 user.EmailVerified = false;
                 user.IrcHostName = "";
                 user.IrcRealName = "";
                 user.IrcUser = "";
                 user.Nickname = "";
                 user.RegistrationGuid = "";
                 user.IrcServerName = "";
                 e.Add(user);
                 e.SaveChanges();
                 return user.UserId;
             } else {
                 return 0;
             }
         }
     } catch (Exception ex) {
         throw ex;
     }
 }
        public void EliminarProgramacion()
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                Programacion programaParaBorrar = dbContext.Programacions.Last();
                dbContext.Delete(programaParaBorrar);
                dbContext.SaveChanges();

            }
        }
Esempio n. 15
0
        public void EliminarRecarga()
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                Recarga RecargaParaBorrar = dbContext.Recargas.Last();
                dbContext.Delete(RecargaParaBorrar);

                dbContext.SaveChanges();

            }
        }
Esempio n. 16
0
 static void Main(string[] args)
 {
     using (EntitiesModel context = new EntitiesModel()) {
         context.UpdateSchema();
         var head = new Header();
         head.Status      = HeaderStates.Created;
         head.Title       = @"Header";
         head.DateCreated = DateTime.Now;
         context.Add(head);
         head.Positions.Add(new Position {
             DateCreated = DateTime.Now, Description = "Position text", SequenceNumber = 1
         });
         context.SaveChanges();
         Console.WriteLine("Positions: " + head.Positions.Count);
         Console.ReadKey(intercept: true);
         context.Delete(head);
         context.SaveChanges();
         Console.WriteLine("Heads: " + context.Headers.Count());
         Console.ReadKey(intercept: true);
     }
 }
    public static string Add(string name, int supplier, int category, bool discontinued, double price, string img)
    {
        Product aProduct = new Product()
        {
            productname  = name,
            supplierid   = supplier,
            categoryid   = category,
            discontinued = discontinued,
            unitprice    = decimal.Parse(price.ToString()),
        };

        if (img.Equals(""))
        {
            aProduct.img = null;
        }
        else
        {
            aProduct.img = img;
        }

        context.Products.Add(aProduct);
        context.SaveChanges();
        return("Add successful");
    }
Esempio n. 18
0
 /// <summary>
 /// Set Registration Guid
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="registrationGuid"></param>
 /// <returns></returns>
 public bool SetRegistrationGuid(int userId, string registrationGuid) {
     try {
         using (var e = new EntitiesModel()) {
             if (e.Users.Where(u => u.UserId == userId).Count() != 0) {
                 var item = e.Users.Where(u => u.UserId == userId).LastOrDefault();
                 item.RegistrationGuid = registrationGuid;
                 e.SaveChanges();
                 return true;
             } else {
                 return false;
             }
         }
     } catch (Exception ex) {
         throw ex;
     }
 }
 /// <summary>
 /// Create
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Create(DataArrivalLogModel model)
 {
     try {
         using (var e = new EntitiesModel()) {
             var item = new DataArrivalLog();
             item.Data         = model.Data;
             item.ConnectionId = model.ConnectionId;
             item.Timestamp    = model.Timestamp;
             e.Add(item);
             e.SaveChanges();
             return(true);
         }
     } catch (Exception ex) {
         throw ex;
     }
 }
Esempio n. 20
0
        public void AñadirRuta(int Id, DateTime Fecha_creacion, String descripcion, Boolean estado)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                Ruta ruta = new Ruta();
                ruta.Id = Id;
                ruta.Fecha_creacion = Fecha_creacion;
                ruta.Descripcion = descripcion;
                ruta.Estado = estado;

                dbContext.Add(ruta);
                dbContext.SaveChanges();

            }
        }
Esempio n. 21
0
 /// <summary>
 /// Email Verify
 /// </summary>
 /// <param name="guid"></param>
 /// <returns></returns>
 public int EmailVerify(string guid) {
     try {
         using (var e = new EntitiesModel()) {
             if (e.Users.Where(u => u.RegistrationGuid == guid).Count() != 0) {
                 var user = e.Users.Where(u => u.RegistrationGuid == guid).LastOrDefault();
                 user.EmailVerified = true;
                 user.RegistrationGuid = "";
                 e.SaveChanges();
                 return user.UserId;
             } else {
                 return 0;
             }
         }
     } catch (Exception ex) {
         throw ex;
     }
 }
Esempio n. 22
0
        public void AñadirRecarga(Estacion estacion, Tarjetum tarjeta, DateTime fecha, DateTime hora)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                Recarga recarga = new Recarga();

                recarga.Estacion = estacion ;
                recarga.Tarjetum = tarjeta;
                recarga.Fecha = fecha;
                recarga.Hora = hora;

                dbContext.Add(recarga);
                dbContext.SaveChanges();

            }
        }
Esempio n. 23
0
        public void AñadirConsumo(Estacion estacion, Tarjetum tarjeta, DateTime fecha, DateTime hora)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                Consumo consumo = new Consumo();

                consumo.Estacion = estacion;
                consumo.Tarjetum = tarjeta;
                consumo.Fecha = fecha;
                consumo.Hora = hora;

                dbContext.Add(consumo);
                dbContext.SaveChanges();

            }
        }
Esempio n. 24
0
        public void AñadirTarjeta(int id, int estacion)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                Tarjetum tarjeta = new Tarjetum();

                tarjeta.Id = id;
                tarjeta.Saldo = 0;
                tarjeta.Estado = true;
                tarjeta.Id_estacion = estacion;

                dbContext.Add(tarjeta);
                dbContext.SaveChanges();

            }
        }
Esempio n. 25
0
        private static void BulkInsert(EntitiesModel context)
        {
            List <Product> products = new List <Product>(50000);

            for (int i = 0; i < 30000; i++)
            {
                Product product = new Product()
                {
                    ProductName = "Lexus" + i, SupplierID = 5, CategoryID = 5, UnitPrice = 1000m, QuantityPerUnit = "1 piece"
                };
                products.Add(product);
            }

            context.Add(products);

            context.SaveChanges();
        }
Esempio n. 26
0
        public void EditarReclamo(String tipo_sol, String descripcion, String respuesta, Boolean estado)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                //se supone que debemos hacer el update pidiendo el ID.....falta implementarlo

                Solicitud_reclamo ReclamoParaEditar = dbContext.Solicitud_reclamos.First();

                ReclamoParaEditar.Descripcion = descripcion;
                //ReclamoParaEditar.Respuesta = respuesta; falta
                //ReclamoParaEditar = estado; falta tambien

                dbContext.SaveChanges();

            }
        }
        public void AñadirProgramacion(int bus, int ruta, int empleado, DateTime fecha, String horario)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                Programacion programacion = new Programacion();
                programacion.Id_bus = bus;
                programacion.Id_ruta = ruta;
                programacion.Id_empleado = empleado;
                programacion.Fecha = fecha;
                programacion.Horario = horario;

                dbContext.Add(programacion);
                dbContext.SaveChanges();

            }
        }
Esempio n. 28
0
        public void AñadirReclamo(int id,int tarjeta,int estacion, String tipo_sol, String descripcion)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                Solicitud_reclamo reclamo = new Solicitud_reclamo();
                reclamo.Id_tarjeta = tarjeta;
                reclamo.Id_estacion = estacion;
                reclamo.Tipo = tipo_sol;
                reclamo.Descripcion = descripcion;
                //reclamo.Respuesta = respuesta;
                reclamo.Estado = "Pendiente";
                reclamo.Id = id;
                dbContext.Add(reclamo);
                dbContext.SaveChanges();

            }
        }
Esempio n. 29
0
        public void EditarRecarga(Estacion estacion, Tarjetum tarjeta, DateTime fecha, DateTime hora)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                //se supone que debemos hacer el update pidiendo el ID.....falta implementarlo

                Recarga RecargaParaEditar = dbContext.Recargas.First();

                RecargaParaEditar.Estacion = estacion ;
                RecargaParaEditar.Tarjetum = tarjeta ;
                RecargaParaEditar.Fecha = fecha ;
                RecargaParaEditar.Hora = hora;

                dbContext.SaveChanges();

            }
        }
        public void EditarProgramacion(Bu bus, Ruta ruta, Empleado empleado, DateTime fecha, String horario)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                //se supone que debemos hacer el update pidiendo el ID.....falta implementarlo

                Programacion programaParaEditar = dbContext.Programacions.First();

                programaParaEditar.Bu= bus;
                programaParaEditar.Rutum= ruta;
                programaParaEditar.Empleado= empleado;
                programaParaEditar.Fecha = fecha;
                programaParaEditar.Horario= horario;

                dbContext.SaveChanges();

            }
        }
Esempio n. 31
0
    public static string Add(int customer, int employee,
                             int shipper, string orderDate, string requiredDate, string shippedDate,
                             string freight, string name, string address, string city, string postalcode,
                             string region, string country)
    {
        //DateTime curdate = DateTime.Now;
        //DateTime orderdate = DateTime.Parse(orderDate);
        //DateTime requireddate = DateTime.Parse(orderDate);
        //DateTime shippeddate = DateTime.Parse(orderDate);
        //if (requireddate < orderdate)
        //{
        //    return "Required date must be more than equal order date";
        //}
        //if (shippedDate.Length > 0)
        //{
        //    if (shippeddate < orderdate)
        //    {
        //        return "Shipped date must be more than equal order date";
        //    }
        //}

        Order order = new Order();

        order.custid       = customer;
        order.empid        = employee;
        order.shipperid    = shipper;
        order.orderdate    = DateTime.Parse(orderDate);
        order.requireddate = DateTime.Parse(requiredDate);
        if (shippedDate.Length > 0)
        {
            order.shippeddate = DateTime.Parse(shippedDate);
        }
        order.freight        = decimal.Parse(freight);
        order.shipname       = name;
        order.shipaddress    = address;
        order.shipcity       = city;
        order.shippostalcode = postalcode;
        order.shipregion     = region;
        order.shipcountry    = country;
        context.Orders.Add(order);
        context.SaveChanges();
        //}
        //catch (Exception e)
        //{

        //    return e.Message;
        //}
        return("Add successful");
    }
Esempio n. 32
0
 /// <summary>
 /// Create
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Create(ConnectionModel model)
 {
     try {
         using (var e = new EntitiesModel()) {
             var connection = new Connection();
             connection.UserId        = model.UserId;
             connection.Server        = model.Server;
             connection.Port          = model.Port;
             connection.Connected     = model.Connected;
             connection.Description   = model.Description;
             connection.Monitoring    = model.Monitoring;
             connection.ServiceTypeId = model.ServiceTypeId;
             e.Add(connection);
             e.SaveChanges();
             return(connection.ConnectionId);
         }
     } catch (Exception ex) {
         throw ex;
     }
 }
        public void AñadirTarjetaPersonalizada(int id, int id_cliente, String numeroTel, String nombreCliente, int estacion)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                Tarjeta_personalizada tarjetaP = new Tarjeta_personalizada();

                tarjetaP.Id = id;
                tarjetaP.Saldo = 0;
                tarjetaP.Estado = true;
                tarjetaP.Id_estacion = estacion;
                tarjetaP.Id_cliente = id_cliente;
                tarjetaP.Nombre = nombreCliente;
                tarjetaP.Telefono = numeroTel;

                dbContext.Add(tarjetaP);
                dbContext.SaveChanges();

            }
        }
Esempio n. 34
0
        public void AñadirBus(int Id, DateTime Fecha_adq, String modelo, String placa, String tipo, String color, String fabricante, String capacidad, String tipo_combust)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                Bu bus = new Bu();
                bus.Id = Id;
                bus.Fecha_adq = Fecha_adq;
                bus.Modelo = modelo;
                bus.Placa = placa;
                bus.Tipo = tipo;
                bus.Color = color;
                bus.Fabricante = fabricante;
                bus.Capacidad = capacidad;
                bus.Tipo_combust = tipo_combust;
                bus.Estado = true;

                dbContext.Add(bus);
                dbContext.SaveChanges();

            }
        }
Esempio n. 35
0
        public void AñadirEmpleado(int Id, String tipo_id, String nombre, String email, String direccion, String telefono, String cargo, String estado_civil, int salario,int esta, String clave)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                Empleado empleado = new Empleado();
                empleado.Id = Id;
                empleado.Tipo_id = tipo_id;
                empleado.Nombre = nombre;
                empleado.Email = email;
                empleado.Direccion = direccion;
                empleado.Telefono = telefono;
                empleado.Cargo= cargo;
                //empleado.Estado_Civil = estado_civil;
                empleado.Salario = salario;
                empleado.Estado = true;
                empleado.Id_estacion = esta;
                empleado.Contrasena = clave;

                dbContext.Add(empleado);
                dbContext.SaveChanges();

            }
        }
Esempio n. 36
0
        private void DoWork(object sender, DoWorkEventArgs e)
        {
            ProductActivation.ProductKey = ProductKey;
            var key = _dbContext.ActivationKeys
                      .FirstOrDefault(a => a.ProductKey == ProductActivation.ProductKey &&
                                      a.KeyStatus == 0 && a.ProductType == 0);

            //O represents Active and O represents PinnaFace

            if (key != null)
            {
                try
                {
                    if (string.IsNullOrEmpty(key.BIOS_SN))
                    {
                        key.BIOS_SN = ProductActivation.BiosSn;
                        //key.FirstActivatedDate = DateTime.Now;
                        //    //GETUTCDATETIME StoredPr. //the time will be better if it is the server timer
                        //key.ExpirationDate = key.FirstActivatedDate.Value.AddDays(key.ExpiryDuration);
                    }
                    else
                    {
                        if (!key.BIOS_SN.Contains(ProductActivation.BiosSn))
                        {
                            if (key.NoOfAllowedPcs == 1)
                            {
                                MessageBox.Show(
                                    "Can't Activate the product, " +
                                    "Check your product key and try again, " +
                                    "or contact pinnaface office!", "More than Allowed Pcs");
                                ProductKey        = "";
                                CommandsEnability = true;

                                return;
                            }

                            key.BIOS_SN = key.BIOS_SN + "," + ProductActivation.BiosSn;
                            if (key.BIOS_SN.Split(',').Count() > key.NoOfAllowedPcs)
                            {
                                MessageBox.Show(
                                    "Can't Activate the product, " +
                                    "Check your product key and try again, " +
                                    "or contact pinnaface office!", "More than Allowed Pcs");
                                ProductKey        = "";
                                CommandsEnability = true;
                                return;
                            }
                        }
                    }

                    key.NoOfActivations = key.NoOfActivations + 1;
                    if (key.NoOfActivations > key.NoOfAllowedActivations)
                    {
                        MessageBox.Show(
                            "Can't Activate the product, " +
                            "Check your product key and try again, " +
                            "or contact pinnaface office!", "More than Allowed Activations");
                        ProductKey        = "";
                        CommandsEnability = true;
                        return;
                    }

                    _dbContext.Add(key);
                    _dbContext.SaveChanges();

                    ProductActivation.RegisteredBiosSn = key.BIOS_SN;
                    ProductActivation.DateLastModified = DbCommandUtil.GetCurrentSqlDate(true);//  DateTime.Now; //GETUTCDATETIME StoredPr
                    ProductActivation.Synced           = false;

                    if (ProductActivation.Id == 0)
                    {
                        ProductActivation.LicensedTo           = key.CustomerName;
                        ProductActivation.DatabaseVersionDate  = Singleton.SystemVersionDate;
                        ProductActivation.MaximumSystemVersion = key.MaximumAllowedSystemVersion;


                        ProductActivation.ModifiedByUserId  = 1;
                        ProductActivation.CreatedByUserId   = 1;
                        ProductActivation.DateRecordCreated = DbCommandUtil.GetCurrentSqlDate(true);//DateTime.Now; //GETUTCDATETIME StoredPr

                        #region Set UserAccounts

                        ProductActivation.SuperName = key.SuperName; //.Email;
                        ProductActivation.SuperPass = key.SuperPass;
                        ProductActivation.AdminName = key.AdminName;
                        ProductActivation.AdminPass = key.AdminPass;
                        ProductActivation.User1Name = key.User1Name;
                        ProductActivation.User1Pass = key.User1Pass;

                        #endregion

                        #region Agency

                        var localAgency = new AgencyDTO
                        {
                            AgencyName         = key.CustomerName ?? (key.CustomerName = ""),
                            AgencyNameAmharic  = "-",
                            ManagerName        = "-",
                            ManagerNameAmharic = "-",
                            Address            = new AddressDTO
                            {
                                AddressType  = AddressTypes.Local,
                                Country      = CountryList.Ethiopia,
                                City         = EnumUtil.GetEnumDesc(CityList.AddisAbeba),
                                Region       = "14",
                                Telephone    = key.Telephone ?? (key.Telephone = ""),
                                PrimaryEmail = key.Email ?? (key.Email = "")
                            },
                            Header           = new AttachmentDTO(),
                            Footer           = new AttachmentDTO(),
                            LicenceNumber    = "-",
                            SaudiOperation   = key.SaudiOperation,
                            DubaiOperation   = key.DubaiOperation,
                            KuwaitOperation  = key.KuwaitOperation,
                            QatarOperation   = key.QatarOperation,
                            JordanOperation  = key.JordanOperation,
                            LebanonOperation = key.LebanonOperation,
                            BahrainOperation = key.BahrainOperation,
                            DepositAmount    = "100,000 USD",
                            Managertype      = "ዋና ስራ አስኪያጅ"
                        };

                        #endregion

                        #region Foreign Agents

                        var foreignAgent = new AgentDTO
                        {
                            AgentName        = "-",
                            AgentNameAmharic = "-",
                            Address          = new AddressDTO
                            {
                                AddressType = AddressTypes.Foreign,
                                Country     = CountryList.SaudiArabia,
                                City        = EnumUtil.GetEnumDesc(CityList.Riyadh)
                            },
                            LicenseNumber = "-",
                            Header        = new AttachmentDTO(),
                            Footer        = new AttachmentDTO(),
                        };

                        #endregion

                        #region Setting

                        var setting = new SettingDTO
                        {
                            AwajNumber             = "923/2008",
                            EmbassyApplicationType = EmbassyApplicationTypes.SponsorNameOnTop,
                            SyncDuration           = 1,
                            StartSync = true,
                        };

                        #endregion

                        ProductActivation.FirstActivatedDate = key.FirstActivatedDate; // DateTime.Now; //GETUTCDATETIME StoredPr
                        ProductActivation.ExpiryDate         = key.ExpiryDate;         // DateTime.Now.AddDays(key.ExpiryDuration);

                        ProductActivation.Agency = localAgency;
                        setting.Agency           = localAgency;

                        ////Since we don't update Header and Footer from Server we didnt need the following 6 lines
                        //localAgency.Address.Agency = localAgency;
                        //localAgency.Header.Agency = localAgency;
                        //localAgency.Footer.Agency = localAgency;

                        //foreignAgent.Address.Agency = localAgency;
                        //foreignAgent.Header.Agency = localAgency;
                        //foreignAgent.Footer.Agency = localAgency;

                        _unitOfWork.Repository <AgencyDTO>().Insert(localAgency);
                        _unitOfWork.Repository <AgentDTO>().Insert(foreignAgent);

                        _unitOfWork.Repository <SettingDTO>().Insert(setting);
                        _unitOfWork.Repository <ProductActivationDTO>().Insert(ProductActivation);
                    }
                    else
                    {
                        //localAgency.Synced = false;
                        //foreignAgent.Synced = false;

                        //_unitOfWork.Repository<AgencyDTO>().Update(localAgency);
                        //_unitOfWork.Repository<AgentDTO>().Update(foreignAgent);

                        _unitOfWork.Repository <ProductActivationDTO>().Update(ProductActivation);
                    }

                    int changes = _unitOfWork.Commit();
                    if (changes > 0)
                    {
                        Singleton.ProductActivation = ProductActivation;
                        _login = true;
                    }
                    else
                    {
                        MessageBox.Show(
                            "Can't Activate the product, check your product key and try again, or contact pinnasofts!");
                        ProductKey        = "";
                        CommandsEnability = true;
                    }
                }
                catch
                {
                    MessageBox.Show("Error:" + Environment.NewLine + " There may be no Internet connection." +
                                    Environment.NewLine + "Check your connection and try again.");
                    CommandsEnability = true;
                }
            }
            else
            {
                MessageBox.Show(
                    "Can't Activate the product, check your product key and try again, or contact pinnasofts!");
                ProductKey        = "";
                CommandsEnability = true;
            }
        }
Esempio n. 37
0
 public void InserirRelacao(int pEntidadePaiID, int pEntidadeFilhoID)
 {
     dbContext.ExecuteNonQuery(string.Format("INSERT INTO dbo.EntidadeRelacao ( EntidadePaiID, EntidadeFilhoID ) VALUES  ({0}, {1})", pEntidadePaiID, pEntidadeFilhoID));
     dbContext.SaveChanges();
 }
        public void EditarTarjetaPersonalizada(int id, int saldo, Boolean estado, String nombre, String numTelefono)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                //se supone que debemos hacer el update pidiendo el ID.....falta implementarlo

                Tarjeta_personalizada TarjetaPersParaEditar = dbContext.Tarjeta_personalizadas.First();

                TarjetaPersParaEditar.Saldo = saldo;
                TarjetaPersParaEditar.Estado = estado;
                TarjetaPersParaEditar.Nombre = nombre;
                TarjetaPersParaEditar.Telefono = numTelefono;

                dbContext.SaveChanges();

            }
        }
        public void EliminarTarjetaPersonalizada()
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                Recarga TarjetaPersParaBorrar = dbContext.Recargas.Last();
                dbContext.Delete(TarjetaPersParaBorrar);

                dbContext.SaveChanges();

            }
        }
Esempio n. 40
0
        private void DoWork(object sender, DoWorkEventArgs e)
        {
            ProductActivation.ProductKey = ProductKey;
            var act = _dbContext.ActivationKeys.FirstOrDefault(a => a.ProductKey == ProductActivation.ProductKey &&
                                                               a.KeyStatus == 0 && a.ProductType == 3); //O represents Active and 3 represents PinnaRent

            if (act != null)                                                                            //
            {
                try
                {
                    if (string.IsNullOrEmpty(act.BIOS_SN))//ON PinnaRent Activation Server
                    {
                        act.BIOS_SN            = ProductActivation.BiosSn;
                        act.FirstActivatedDate = DateTime.Now; //the time will be better if it is the server timer
                        act.ExpirationDate     = act.FirstActivatedDate.Value.AddDays(act.ExpiryDuration);
                    }
                    else
                    {
                        if (!act.BIOS_SN.Contains(ProductActivation.BiosSn))
                        {
                            if (act.NoOfAllowedPcs == 1)
                            {
                                MessageBox.Show(
                                    "Can't Activate the product, check your product key and try again, or contact PinnaRent office!");
                                ProductKey        = "";
                                CommandsEnability = true;
                                return;
                            }

                            act.BIOS_SN = act.BIOS_SN + "," + ProductActivation.BiosSn;
                            if (act.BIOS_SN.Split(',').Count() > act.NoOfAllowedPcs)
                            {
                                MessageBox.Show(
                                    "Can't Activate the product, check your product key and try again, or contact PinnaRent office!");
                                ProductKey        = "";
                                CommandsEnability = true;
                                return;
                            }
                        }
                    }
                    act.NoOfActivations = act.NoOfActivations + 1;

                    _dbContext.Add(act);
                    _dbContext.SaveChanges();

                    ProductActivation.RegisteredBiosSn = act.BIOS_SN;

                    if (ProductActivation.Id == 0)
                    {
                        ProductActivation.LicensedTo = act.CustomerName;

                        ProductActivation.DateLastModified  = DateTime.Now;
                        ProductActivation.ModifiedByUserId  = 1;
                        ProductActivation.CreatedByUserId   = 1;
                        ProductActivation.DateRecordCreated = DateTime.Now;

                        ProductActivation.ActivatedDate  = DateTime.Now;
                        ProductActivation.ExpirationDate = DateTime.Now.AddDays(act.ExpiryDuration);

                        if (Singleton.Edition != PinnaRentEdition.OnlineEdition)
                        {
                            #region Company

                            var company = new CompanyDTO
                            {
                                DisplayName    = act.CustomerName,
                                CompanyAddress = new AddressDTO
                                {
                                    Country      = "ኢትዮጲያ",
                                    City         = "አዲስ አበባ",
                                    Telephone    = act.Telephone,
                                    PrimaryEmail = act.Email
                                },
                                Address = new AddressDTO
                                {
                                    Country      = "ኢትዮጲያ",
                                    City         = "አዲስ አበባ",
                                    Telephone    = act.Telephone,
                                    PrimaryEmail = act.Email
                                }
                            };

                            #endregion

                            #region Warehouse

                            var warehouse = new WarehouseDTO
                            {
                                Id              = 1,
                                DisplayName     = "_Default Store",
                                WarehouseNumber = 11,
                                IsDefault       = true,
                                Company         = company,
                                Address         = new AddressDTO
                                {
                                    Country = "Ethiopia",
                                    City    = "Addis Abeba"
                                }
                            };

                            #endregion

                            _unitOfWork.Repository <CompanyDTO>().Insert(company);
                            _unitOfWork.Repository <WarehouseDTO>().Insert(warehouse);
                        }
                        _unitOfWork.Repository <ProductActivationDTO>().Insert(ProductActivation);
                    }
                    else
                    {
                        _unitOfWork.Repository <ProductActivationDTO>().Update(ProductActivation);
                    }

                    _unitOfWork.Commit();

                    Singleton.ProductActivation = ProductActivation;

                    _login = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error:" + Environment.NewLine + " There may be no Internet connection." +
                                    Environment.NewLine + "Check your connection and try again." + Environment.NewLine + ex.Message);
                    CommandsEnability = true;
                }
            }
            else
            {
                MessageBox.Show("Can't Activate the product, check your product key and try again, or contact PinnaRent office!");
                ProductKey        = "";
                CommandsEnability = true;
            }
        }
Esempio n. 41
0
        private void DoWork(object sender, DoWorkEventArgs e)
        {
            ProductActivation.ProductKey = ProductKey;
            var act = _dbContext.ActivationKeys.FirstOrDefault(a => a.ProductKey == ProductActivation.ProductKey &&
                                                               a.KeyStatus == 0 && a.ProductType == 2);//O represents Active and 1 represents PinnaFit,2=PinnaFit

            if (act != null)
            {
                try
                {
                    if (string.IsNullOrEmpty(act.BIOS_SN))//ON PinnaFit Activation Server
                    {
                        act.BIOS_SN            = ProductActivation.BiosSn;
                        act.FirstActivatedDate = DateTime.Now; //the time will be better if it is the server timer
                        act.ExpirationDate     = act.FirstActivatedDate.Value.AddDays(act.ExpiryDuration);
                    }
                    else
                    {
                        if (!act.BIOS_SN.Contains(ProductActivation.BiosSn))
                        {
                            if (act.NoOfAllowedPcs == 1)
                            {
                                MessageBox.Show(
                                    "Can't Activate the product, check your product key and try again, or contact PinnaFit office!");
                                ProductKey        = "";
                                CommandsEnability = true;
                                return;
                            }

                            act.BIOS_SN = act.BIOS_SN + "," + ProductActivation.BiosSn;
                            if (act.BIOS_SN.Split(',').Count() > act.NoOfAllowedPcs)
                            {
                                MessageBox.Show(
                                    "Can't Activate the product, check your product key and try again, or contact PinnaFit office!");
                                ProductKey        = "";
                                CommandsEnability = true;
                                return;
                            }
                        }
                    }
                    act.NoOfActivations = act.NoOfActivations + 1;

                    _dbContext.Add(act);
                    _dbContext.SaveChanges();

                    ProductActivation.RegisteredBiosSn = act.BIOS_SN;

                    if (ProductActivation.Id == 0)
                    {
                        ProductActivation.LicensedTo = act.CustomerName;

                        ProductActivation.DateLastModified  = DateTime.Now;
                        ProductActivation.ModifiedByUserId  = 1;
                        ProductActivation.CreatedByUserId   = 1;
                        ProductActivation.DateRecordCreated = DateTime.Now;

                        ProductActivation.ActivatedDate  = DateTime.Now;
                        ProductActivation.ExpirationDate = DateTime.Now.AddDays(act.ExpiryDuration);

                        if (Singleton.Edition != PinnaFitEdition.OnlineEdition)
                        {
                            #region Company

                            var company = new CompanyDTO
                            {
                                Id          = 1,
                                DisplayName = "Deyinsher Fitness Center",
                                Address     = new AddressDTO
                                {
                                    AddressDetail   = "Jemmo, Yehender Business Center, Ground Floor",
                                    Country         = "ኢትዮጲያ",
                                    City            = "አዲስ አበባ",
                                    Telephone       = "0111266701",
                                    Mobile          = "0929142121",
                                    AlternateMobile = "0911168312",
                                    PrimaryEmail    = "*****@*****.**"
                                }
                            };

                            #endregion

                            _unitOfWork.Repository <CompanyDTO>().Insert(company);
                        }
                        _unitOfWork.Repository <ProductActivationDTO>().Insert(ProductActivation);
                    }
                    else
                    {
                        _unitOfWork.Repository <ProductActivationDTO>().Update(ProductActivation);
                    }

                    _unitOfWork.Commit();

                    Singleton.ProductActivation = ProductActivation;

                    //new Login().Show();
                    _login = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error:" + Environment.NewLine + " There may be no Internet connection." +
                                    Environment.NewLine + "Check your connection and try again." + Environment.NewLine + ex.Message);
                    CommandsEnability = true;
                }
            }
            else
            {
                MessageBox.Show("Can't Activate the product, check your product key and try again, or contact PinnaFit office!");
                ProductKey        = "";
                CommandsEnability = true;
            }
        }
Esempio n. 42
0
        public void EditarTarjeta(int id, int saldo, Boolean estado)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                //se supone que debemos hacer el update pidiendo el ID.....falta implementarlo

                Tarjetum TarjetaParaEditar = dbContext.Tarjeta.First();

                TarjetaParaEditar.Saldo = saldo;
                TarjetaParaEditar.Estado = estado;

                dbContext.SaveChanges();

            }
        }
Esempio n. 43
0
 public void Save()
 {
     _context.SaveChanges();
 }
Esempio n. 44
0
        public void EditarEmpleado(String tipo_id, String nombre, String email, String direccion, String telefono, String cargo, String estado_civil, int salario, Boolean estado)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                //se supone que debemos hacer el update pidiendo el ID.....falta implementarlo

                Empleado empleadoParaEditar = dbContext.Empleados.First();

                empleadoParaEditar.Tipo_id = tipo_id;
                empleadoParaEditar.Nombre = nombre;
                empleadoParaEditar.Email = email;
                empleadoParaEditar.Direccion = direccion;
                empleadoParaEditar.Telefono = telefono;
                empleadoParaEditar.Cargo = cargo;
                //empleadoParaEditar.Estado_Civil = estado_civil;
                empleadoParaEditar.Salario = salario;
                empleadoParaEditar.Estado = estado;

                dbContext.SaveChanges();

            }
        }
Esempio n. 45
0
        public void EditarBus(DateTime Fecha_adq, String modelo, String placa, String tipo, String color, String fabricante, String capacidad, String tipo_combust, Boolean estado)
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                //se supone que debemos hacer el update pidiendo el ID.....falta implementarlo

                Bu busParaEditar = dbContext.Bus.First();

                busParaEditar.Fecha_adq = Fecha_adq;
                busParaEditar.Modelo = modelo;
                busParaEditar.Placa = placa;
                busParaEditar.Tipo = tipo;
                busParaEditar.Color = color;
                busParaEditar.Fabricante = fabricante;
                busParaEditar.Capacidad = capacidad;
                busParaEditar.Tipo_combust = tipo_combust;
                busParaEditar.Estado = estado;

                dbContext.SaveChanges();

            }
        }
Esempio n. 46
0
        public void EditarRuta(DateTime Fecha_creacion, String Descripcion )
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                //se supone que debemos hacer el update pidiendo el ID.....falta implementarlo

                Ruta rutaParaEditar = dbContext.Rutas.First();

                rutaParaEditar.Fecha_creacion = Fecha_creacion;
                rutaParaEditar.Descripcion = Descripcion;

                dbContext.SaveChanges();

            }
        }
Esempio n. 47
0
        public void EliminarEmpleado()
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                //eliminar debe ser solo cambiar el estado......

                Empleado EmpleadoParaBorrar = dbContext.Empleados.Last();
                dbContext.Delete(EmpleadoParaBorrar);
                dbContext.SaveChanges();

            }
        }
Esempio n. 48
0
        public void EliminarBus()
        {
            using (EntitiesModel dbContext = new EntitiesModel())
            {

                Bu BusParaBorrar = dbContext.Bus.Last();
                dbContext.Delete(BusParaBorrar);
                dbContext.SaveChanges();

            }
        }
Esempio n. 49
0
 private static void SlowDelete(EntitiesModel context)
 {
     context.Delete(context.Products.Where(p => p.ProductID % 7 == 2));
     context.SaveChanges();
 }