Exemplo n.º 1
0
        public ActionResult Nieuw()
        {
            PMKassa kassa = new PMKassa();

            //kassa.Kassa = new ItRegister();
            return(View(kassa));
        }
Exemplo n.º 2
0
        public ActionResult Aanpassen(int?id)
        {
            PMKassa kassa;

            if (!id.HasValue)
            {
                return(RedirectToAction("Index"));
            }
            kassa         = lijst.Find(o => o.Kassa.Id == id.Value) as PMKassa;
            geselecteerde = kassa;
            return(View("Nieuw", kassa));
        }
Exemplo n.º 3
0
        public static List <PMKassa> getKassas()
        {
            List <PMKassa> resultaat = new List <PMKassa>();
            DbDataReader   reader    = Database.GetData("AdminConnection", "select re.Id, re.RegisterName, re.Device, re.PurchaseDate, re.ExpiresDate, orre.UntilDate,orre.FromDate, org.OrganisationName,org.Id as 'IdOrg' from dbo.Registers re left outer join Organisation_Register orre on re.ID = orre.RegisterId left outer join Organisations org on orre.OrganisationId = org.Id");

            while (reader.Read())
            {
                PMKassa kassa = CreateKassa(reader);
                resultaat.Add(kassa);
            }
            reader.Close();
            return(resultaat);
        }
Exemplo n.º 4
0
 public static int KoppelKassaAanOrganisatie(PMKassa kassa, int i)
 {
     try
     {
         string      sql  = "INSERT INTO Organisation_Register (OrganisationId,RegisterId,FromDate,UntilDate)VALUES (@org,@reg,@from, @Until)";
         DbParameter par1 = Database.addParameter("AdminConnection", "@org", kassa.IdOrganisation);
         DbParameter par2 = Database.addParameter("AdminConnection", "@reg", i);
         DbParameter par3 = Database.addParameter("AdminConnection", "@from", kassa.Fromdate);
         DbParameter par4 = Database.addParameter("AdminConnection", "@Until", kassa.UntilDate);
         return(Database.InsertData("AdminConnection", sql, par1, par2, par3, par4));
     }
     catch (Exception)
     {
         return(0);
     }
 }
Exemplo n.º 5
0
        public ActionResult Delete(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index"));
            }

            PMKassa kassa = lijst.Find(o => o.Kassa.Id == id.Value) as PMKassa;

            if (kassa != null)
            {
                KassaDA.DeleteKoppelAanOrg(id.Value);
                KassaDA.DeleteKassa(id.Value);
            }

            return(RedirectToAction("index"));
        }
Exemplo n.º 6
0
        public ActionResult Nieuw(PMKassa pm)
        {
            if (!ModelState.IsValid)
            {
                return(View("Nieuw", pm));
            }
            int i = KassaDA.CreateKassa(pm.Kassa);

            if (pm.IdOrganisation != -1)
            {
                if (pm.UntilDate != -10 || pm.Fromdate != -10)
                {
                    KassaDA.KoppelKassaAanOrganisatie(pm, i);
                    //kassa aan klant database toevoegen
                }
            }
            return(RedirectToAction("index"));
        }
Exemplo n.º 7
0
        private static PMKassa CreateKassa(IDataRecord reader)
        {
            ItRegister nieuw = new ItRegister()
            {
                Id           = Convert.ToInt32(reader["Id"].ToString()),
                RegisterName = reader["RegisterName"].ToString(),
                Device       = reader["Device"].ToString(),
                PurchaseDate = Convert.ToInt32(reader["PurchaseDate"].ToString()),
                ExpireDate   = Convert.ToInt32(reader["ExpiresDate"].ToString()),
            };
            PMKassa kassa = new PMKassa();

            kassa.Kassa = nieuw;
            string org;

            if (reader["OrganisationName"].ToString() == "")
            {
                org = "/";
            }
            else
            {
                org = reader["OrganisationName"].ToString();
            }

            kassa.OrganisationName = org;
            if (reader["FromDate"].ToString() != "")
            {
                kassa.Fromdate = Convert.ToInt32(reader["FromDate"].ToString());
            }
            if (reader["UntilDate"].ToString() != "")
            {
                kassa.UntilDate = Convert.ToInt32(reader["UntilDate"].ToString());
            }
            if (reader["IdOrg"].ToString() != "")
            {
                kassa.IdOrganisation = Convert.ToInt32(reader["Idorg"].ToString());
            }
            return(kassa);
        }
Exemplo n.º 8
0
        public ActionResult Aanpassen(PMKassa pm)
        {
            pm.Kassa.Id = geselecteerde.Kassa.Id;
            if (!ModelState.IsValid)
            {
                return(View("Aanpassen", pm));
            }
            int i = KassaDA.ChangeKassa(pm.Kassa);

            if (pm.IdOrganisation != -1)
            {
                if (pm.UntilDate != -10 || pm.Fromdate != -10)
                {
                    int nmr = KassaDA.DeleteKoppelAanOrg(pm.Kassa.Id);
                    KassaDA.KoppelKassaAanOrganisatie(pm, pm.Kassa.Id);
                    //kassa aan klant database toevoegen
                }
            }
            else
            {
                int nmr = KassaDA.DeleteKoppelAanOrg(pm.Kassa.Id);
            }
            return(RedirectToAction("index"));;
        }