예제 #1
0
        public ActionResult Bestilling(Bestilling ordre)
        {
            if (!(bool)Session["Innlogget"]) {
                return RedirectToAction("Innlogging", "Kunde");
            }

            var kundeLogikk = new KundeLogikk();
            var kunden = kundeLogikk.HentEnKunde((int)Session["Kundenummer"]);
            var handlekurv = (Handlekurv)Session["Handlekurv"];
            var bestillingLogikk = new OrdreLogikk();
            var bank = new Bank();

            if (!bank.UtforTransaksjon()) {
                return View();
            }

            var bestilling = new Ordre() {
                Kunde = kunden,
                Navn = ordre.Navn,
                Adresse = ordre.Adresse,
                Postnummer = ordre.Postnummer,
                Poststed = ordre.Poststed,
                Ordredato = DateTime.Now,
                Ordrelinjer = handlekurv.Ordrelinjer
            };

            var ordrenummer = bestillingLogikk.LeggInnBestilling(bestilling);
            TempData["Ordrenummer"] = ordrenummer;

            Session["Handlekurv"] = new Handlekurv();

            return RedirectToAction("Fullfort");
        }
        public static string Insert(Bank _Bank)
        {
            DbCommand command = Catalog_Access.CreateCommand();
            //Have to wite the stored procedure
            command.CommandText = "sp_insert_Bank";

            DbParameter param;

            param = command.CreateParameter();
            param.ParameterName = "@Code";
            param.Value = _Bank.Code;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Name";
            param.Value = _Bank.Name;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Description";
            param.Value = _Bank.Description;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@CreatedBy";
            param.Value = _Bank.CreatedBy;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Return";
            param.DbType = DbType.String;
            param.Size = 2;
            param.Direction = ParameterDirection.Output;
            command.Parameters.Add(param);

            Catalog_Access.ExecuteNonQuery(command);

            string Return = command.Parameters["@Return"].Value.ToString();

            return Return;
        }
        public static string Update(Bank _Bank)
        {
            DbCommand command = Catalog_Access.CreateCommand();
            command.CommandText = "sp_Update_Bank";

            DbParameter param;

            param = command.CreateParameter();
            param.ParameterName = "@ID";
            param.Value = _Bank.ID;
            param.DbType = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Code";
            param.Value = _Bank.Code;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Name";
            param.Value = _Bank.Name;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Description";
            param.Value = _Bank.Description;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@UpdatedBy";
            param.Value = _Bank.UpdatedBy;
            param.DbType = DbType.String;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@Return";
            param.DbType = DbType.String;
            param.Size = 2;
            param.Direction = ParameterDirection.Output;
            command.Parameters.Add(param);
            Catalog_Access.ExecuteNonQuery(command);

            string Return = command.Parameters["@Return"].Value.ToString();

            return Return;
        }