コード例 #1
0
        private void btnDeleteRow_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult delConf = MessageBox.Show("Are you sure delete this data?", "Delete data", MessageBoxButton.YesNo);

            switch (delConf)
            {
            case MessageBoxResult.Yes:
                var data = tblSupplier.SelectedItem;
                emptyFields();
                int id          = Convert.ToInt32((tblSupplier.SelectedCells[0].Column.GetCellContent(data) as TextBlock).Text);
                var rowSupplier = con.Suppliers.Where(s => s.Id == id).FirstOrDefault();
                var rowRole     = con.Roles.Where(s => s.Supplier.Id == rowSupplier.Id).FirstOrDefault();
                con.Roles.Remove(rowRole);
                con.Suppliers.Remove(rowSupplier);
                var update = con.SaveChanges();
                MessageBox.Show(update + " Data has been deleted");
                emptyFields();
                tblSupplier.ItemsSource = con.Suppliers.ToList();
                break;

            case MessageBoxResult.No:

                break;
            }
        }
コード例 #2
0
 public void guardarClientes(List <Cliente> listaClientesCargados)
 {
     foreach (Cliente cliente in listaClientesCargados)
     {
         ctx.Cliente.Add(cliente);
         ctx.SaveChanges();
     }
 }
コード例 #3
0
        public int Delete(int id)
        {
            var getByid = context.Departments.Find(id);

            context.Departments.Remove(getByid);
            var delete = context.SaveChanges();

            return(delete);
        }
コード例 #4
0
        //DELETE
        public int Delete(int id)
        {
            // dapetin id nya
            var getByid = context.Divisions.Find(id);

            // execute delete
            context.Divisions.Remove(getByid);
            var delete = context.SaveChanges();

            return(delete);
        }
コード例 #5
0
 public ActionResult Create([Bind(Include = "Name, Price, Stock, Supplierid")] Item item)
 {
     if (ModelState.IsValid)
     {
         // TODO: Add insert logic here
         connection.Items.Add(item);
         connection.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Id = new SelectList(connection.Suppliers, "Id", "Name", item.Supplier);
     return(View(item));
 }
コード例 #6
0
 public ActionResult Create(Department department)
 {
     try
     {
         myConn.Departments.Add(department);
         myConn.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #7
0
        private void Btn_Insert_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (TextBox_Name.Text == "" || TextBox_Address.Text == "" || TextBox_Email.Text == "")
                {
                    if (TextBox_Name.Text == "")
                    {
                        MessageBox.Show("Name is required", "Warning", MessageBoxButton.OK);
                        TextBox_Name.Focus();
                    }
                    else if (TextBox_Address.Text == "")
                    {
                        MessageBox.Show("Address is required", "Warning", MessageBoxButton.OK);
                        TextBox_Address.Focus();
                    }
                    else if (TextBox_Email.Text == "")
                    {
                        MessageBox.Show("Email is required", "Warning", MessageBoxButton.OK);
                        TextBox_Email.Focus();
                    }
                }


                else
                {
                    var check_email = connection.Suppliers.FirstOrDefault(S => S.Email == TextBox_Email.Text);
                    if (check_email == null)
                    {
                        MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are You Sure?", "Insert Confirmation", System.Windows.MessageBoxButton.YesNo);

                        if (messageBoxResult == MessageBoxResult.Yes)
                        {
                            var input_supplier = new Supplier(TextBox_Name.Text, TextBox_Address.Text, TextBox_Email.Text);


                            connection.Suppliers.Add(input_supplier);
                            var insert = connection.SaveChanges();
                            if (insert >= 1)
                            {
                                MessageBox.Show(insert + " Supplier has been inserted");
                            }

                            TB_M_Supplier.ItemsSource = connection.Suppliers.ToList();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Email has been used");
                    }
                }
            }

            catch (Exception)
            {
            }

            reset_supplier();
            Combo_Supplier.ItemsSource = connection.Suppliers.ToList();
        }
コード例 #8
0
 public ActionResult Create(Division division)
 {
     try
     {
         myConn.Divisions.Add(division);
         myConn.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         ViewBag.id_department = new SelectList(myConn.Departments, "Id", "Name", division.Name);
         return(View());
     }
 }
コード例 #9
0
        private void btnDeleteRow_Click(object sender, RoutedEventArgs e)
        {
            var data = tblItem.SelectedItem;

            emptyFields();
            int id       = Convert.ToInt32((tblItem.SelectedCells[0].Column.GetCellContent(data) as TextBlock).Text);
            var rowItems = con.Items.Where(s => s.Id == id).FirstOrDefault();

            con.Items.Remove(rowItems);
            var update = con.SaveChanges();

            MessageBox.Show(update + " Data has been deleted");
            tblItem.ItemsSource = con.Items.ToList();
        }
コード例 #10
0
        public ActionResult Create(Supplier supplier)
        {
            try
            {
                // TODO: Add insert logic here
                conn.Suppliers.Add(supplier);
                conn.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #11
0
 public ActionResult Add(Supplier supplier)
 {
     connection.Suppliers.Add(supplier);
     connection.SaveChanges();
     return(RedirectToAction("Index"));
     //return Json(new { success = true, message = "Add Success" }, JsonRequestBehavior.AllowGet);
 }
コード例 #12
0
        private void forgotpass_btn_Click(object sender, RoutedEventArgs e)
        {
            if (txb_email.Text == "")
            {
                MessageBox.Show("Please fill Email");
                txb_email.Focus();
            }
            else
            {
                try
                {
                    string password = System.Guid.NewGuid().ToString();
                    var    row      = con.Suppliers.Where(r => r.Email == txb_email.Text).FirstOrDefault();
                    var    myid     = con.Suppliers.Where(s => s.Id == row.Id).FirstOrDefault();

                    Sendmail(txb_email.Text, row.Name, password);
                    myid.Password = password;
                    con.SaveChanges();

                    MessageBox.Show("Success Reset Password \nPlease Check Your Email");

                    login.Show();
                    this.Close();
                }
                catch (Exception)
                {
                    MessageBox.Show("Email not Registered");
                    txb_email.Text = "";
                    txb_email.Focus();
                }
            }
        }
コード例 #13
0
ファイル: Form1.cs プロジェクト: Danielle9897/Core3App-EF
        private void EFbuttonAdd_Click(object sender, EventArgs e)
        {
            // Add new Blog entry to Blogs table
            try
            {
                using var dbContext = new myContext();
                var newBlog = new Blog()
                {
                    Title     = "from EF",
                    CreatedAt = DateTime.Now,
                    Subtitle  = "SubFromEF"
                                // Note : There is an issue with EF with this subtitle field
                                //        Although this field IS marked as 'allow nulls' in the sql server, the EF doesn't work if it is null
                                //        It is NOT a profiler issue, it is some issue with the EF core
                                //        See: https://stackoverflow.com/a/55889874/5737562
                };

                dbContext.Blogs.Add(newBlog);
                dbContext.SaveChanges();
                var lastBlogId = newBlog.Id;
                Console.WriteLine($"Added Blog: Blog with id {lastBlogId} was added");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
コード例 #14
0
        public ActionResult ConfirmarReserva(CarteleraReserva cr)
        {
            myContext ctx = new myContext();

            if (ModelState.IsValid)
            {
                Reservas reserva = new Reservas();

                string HoraInicio   = cr.Horario.ToString();
                int    sitioDeCorte = 2;
                string parte1       = HoraInicio.Substring(0, sitioDeCorte);
                string parte2       = HoraInicio.Substring(3, sitioDeCorte);

                int HoraInicioParte1, HoraInicioParte2;

                Int32.TryParse(parte1, out HoraInicioParte1);
                Int32.TryParse(parte2, out HoraInicioParte2);
                DateTime Hora = DateTime.Today;

                Hora = Hora.AddHours(HoraInicioParte1);
                Hora = Hora.AddMinutes(HoraInicioParte2);

                reserva.IdPelicula       = cr.IdPelicula;
                reserva.IdVersion        = cr.IdVersion;
                reserva.IdSede           = cr.IdSede;
                reserva.FechaHoraInicio  = Hora;
                reserva.FechaCarga       = DateTime.Now;
                reserva.Email            = cr.Email;
                reserva.IdTipoDocumento  = cr.IdTipoDocumento;
                reserva.NumeroDocumento  = cr.NumeroDocumento;
                reserva.CantidadEntradas = cr.CantidadEntradas;

                ctx.Reservas.Add(reserva);
                ctx.SaveChanges();


                cr.IdReserva = reserva.IdReserva;
                var sede = ctx.Sedes.Where(x => x.IdSede == cr.IdSede).FirstOrDefault();
                ViewBag.PrecioTotal = cr.CantidadEntradas * sede.PrecioGeneral;

                return(View(cr));
            }

            var a = ctx.Carteleras.Where(x => x.IdPelicula == cr.IdPelicula && x.IdSede == cr.IdSede && x.IdVersion == cr.IdVersion).First();

            ViewBag.ImagenPelicula  = ctx.Peliculas.Where(x => x.IdPelicula == cr.IdPelicula).FirstOrDefault().Imagen;
            ViewBag.TiposDocumentos = PeliculaServicio.TraeTiposDeDocumentos();

            cr.IdPelicula = a.IdPelicula;
            cr.IdSede     = a.IdSede;
            cr.NumeroSala = a.NumeroSala;
            cr.IdVersion  = a.IdVersion;
            cr.Peliculas  = a.Peliculas;
            cr.Sedes      = a.Sedes;
            cr.Versiones  = a.Versiones;
            cr.Horario    = cr.Horario;
            cr.Dia        = cr.Dia;
            return(View("FinalizarReserva", cr));
        }
コード例 #15
0
ファイル: DAC.cs プロジェクト: maani213/POS-Proj
 public static CookingInstruction AddCookInstr(CookingInstruction instr)
 {
     using (myContext db1 = new myContext())
     {
         var newItem = db1.CookingInstructions.Add(instr);
         db1.SaveChanges();
         return(newItem);
     }
 }
コード例 #16
0
ファイル: DAC.cs プロジェクト: maani213/POS-Proj
 public static void RemoveCollectionOrder(int Id)
 {
     using (myContext db1 = new myContext())
     {
         var order = db1.AwaitOrders.First(m => m.Id == Id);
         //db1.AwaitOrders.Remove(order);
         db1.Entry(order).State = EntityState.Deleted;
         db1.SaveChanges();
     }
 }
コード例 #17
0
        // Insert Supplier
        private void Btn_Insert_Click(object sender, RoutedEventArgs e)
        {
            string password = System.Guid.NewGuid().ToString();
            var    iRole    = conn.Roles.Where(S => S.Id == cb_role).FirstOrDefault();
            var    input    = new Supplier(txtb_name.Text, txtb_address.Text, txtb_email.Text, password, iRole);

            // pattern email
            string pattern = @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$";

            // validasi_supplier
            if (txtb_name.Text == "")
            {
                MessageBox.Show("Nama tidak boleh kosong...");
                txtb_name.Focus();
            }
            else if (txtb_address.Text == "")
            {
                MessageBox.Show("Address tidak boleh kosong...");
                txtb_address.Focus();
            }
            else if (txtb_email.Text == "")
            {
                MessageBox.Show("Email tidak boleh kosong...");
                txtb_email.Focus();
            }
            else if (!Regex.Match(txtb_email.Text, pattern).Success)
            {
                MessageBox.Show("Format email salah...");
                txtb_email.Focus();
            }
            else
            {
                //push ke database
                conn.Suppliers.Add(input);
                conn.SaveChanges();
                sendPassToEmail(txtb_email.Text, password, txtb_name.Text); // method send password to email
                txtb_name.Text    = string.Empty;
                txtb_address.Text = string.Empty;
                txtb_email.Text   = string.Empty;
                MessageBox.Show("Data Berhasil ditambahkan");
            }
            tbl_supplier.ItemsSource = conn.Suppliers.ToList(); // refresh table
        }
コード例 #18
0
        public ActionResult Create([Bind(Include = "Name, Price, Stock, SupplierID")] Item item)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    conn.Items.Add(item);
                    conn.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            PopulateSuppliersDropDownList(item.SupplierID);

            return(View(item));
        }
コード例 #19
0
ファイル: DAC.cs プロジェクト: maani213/POS-Proj
 public static void AddCollectionOrder(int orderId)
 {
     using (myContext db1 = new myContext())
     {
         var awaitOrder = new AwaitOrder()
         {
             OrderId = orderId
         };
         var result = db1.AwaitOrders.Add(awaitOrder);
         db1.SaveChanges();
     }
 }
コード例 #20
0
        public IActionResult CreateUser(RegisUser user)
        {
            if (ModelState.IsValid)
            {
                PasswordHasher <RegisUser> Hasher = new PasswordHasher <RegisUser>();
                user.Password = Hasher.HashPassword(user, user.Password);
                User NewUser = new User
                {
                    Firstname = user.Firstname,
                    Lastname  = user.Lastname,
                    Email     = user.Email,
                    Password  = user.Password,
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now
                };

                _context.Add(NewUser);
                _context.SaveChanges();
                User justCreated = _context.Users.FirstOrDefault(User => user.Email == user.Email);
                HttpContext.Session.SetInt32("UserId", justCreated.UserId);
                HttpContext.Session.SetString("Firstname", justCreated.Firstname);
                return(RedirectToAction("ActivityList"));
            }
            return(View("Index"));
        }
コード例 #21
0
ファイル: DAC.cs プロジェクト: maani213/POS-Proj
 public static void AddDeliverytoDespatch(int orderId)
 {
     using (myContext db1 = new myContext())
     {
         var deliveryOrder = new DeliverytoDespatch()
         {
             OrderId          = orderId,
             AssignedDriverId = 0
         };
         var result = db1.DeliveriestoDespatch.Add(deliveryOrder);
         db1.SaveChanges();
     }
 }
コード例 #22
0
 public ActionResult AltaSede(Sedes sede)
 {
     if (ModelState.IsValid)
     {
         myContext ctx = new myContext();
         sede.PrecioGeneral = Decimal.Parse(Request.Form["precioGeneral"]);
         ctx.Sedes.Add(sede);
         ctx.SaveChanges();
         var a = (ctx.Sedes).ToList();
         return(View("Sedes", a));
     }
     return(View());
 }
コード例 #23
0
        public ActionResult AltaCartelera(Carteleras cartelera)
        {
            myContext ctx = new myContext();

            if (ModelState.IsValid)
            {
                ViewBag.Mensaje      = "";
                cartelera.FechaCarga = DateTime.Now;
                var sede    = (ctx.Sedes).ToList();
                var peli    = (ctx.Peliculas).ToList();
                var version = (ctx.Versiones).ToList();
                ViewBag.Sedes   = sede;
                ViewBag.Peli    = peli;
                ViewBag.Version = version;

                if (cartelera.IdSede == 0)
                {
                    ViewBag.Mensaje = "Debe ingresar una sede";
                    return(View());
                }
                if (cartelera.IdPelicula == 0)
                {
                    ViewBag.Mensaje = "Debe ingresar una película";
                    return(View());
                }

                if (AdministracionServicio.ValidaCartelera(cartelera))
                {
                    ctx.Carteleras.Add(cartelera);
                    ctx.SaveChanges();

                    var a = (ctx.Carteleras).ToList();
                    return(View("Carteleras", a));
                }
                else
                {
                    ViewBag.Mensaje = "ATENCIÓN !!! La cartelera ingresada no se encuentra disponible en las fechas: " + cartelera.FechaInicio.ToShortDateString() + " - " + cartelera.FechaFin.ToShortDateString();
                    return(View());
                }
            }
            var b = (ctx.Sedes).ToList();
            var c = (ctx.Peliculas).ToList();
            var d = (ctx.Versiones).ToList();

            ViewBag.Sedes   = b;
            ViewBag.Peli    = c;
            ViewBag.Version = d;
            return(View());
        }
コード例 #24
0
        public ActionResult editarPelicula(Peliculas peli, HttpPostedFileBase image)
        {
            myContext ctx = new myContext();//Instancio el contexto

            if (ModelState.IsValid)
            {
                var       file  = image;
                var       id    = Int32.Parse(Request.Form["idPelicula"]);
                Peliculas peli2 = (from pel in ctx.Peliculas where pel.IdPelicula == id select pel).FirstOrDefault();

                if (file != null && file.ContentLength > 0) // Agregar IMAGEN
                {
                    try
                    {
                        string path = Path.Combine(Server.MapPath("~/Images"),
                                                   Path.GetFileName(file.FileName));
                        file.SaveAs(path);
                        peli2.Imagen = Path.GetFileName(file.FileName);
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Message = "ERROR:" + ex.Message.ToString();
                    }
                }

                else
                {
                    if (peli2.Imagen != Request.Form["Imagen"] && Request.Form["Imagen"] != "" && Request.Form["Imagen"] != null)
                    {
                        peli2.Imagen = Request.Form["Imagen"];
                    }
                }
                peli2.Nombre         = peli.Nombre;
                peli2.Descripcion    = peli.Descripcion;
                peli2.Duracion       = peli.Duracion;
                peli2.FechaCarga     = DateTime.Now;
                peli2.IdGenero       = peli.IdGenero;
                peli2.IdCalificacion = peli.IdCalificacion;
                ctx.SaveChanges();                //persisto los datos en la bdd
                var a = (ctx.Peliculas).ToList(); //Cargo el modelo para Peliculas
                return(View("Peliculas", a));
            }

            ViewBag.Generos        = AdministracionServicio.GetGeneros();
            ViewBag.Calificaciones = AdministracionServicio.GetCalificaciones();

            return(View(peli));
        }
コード例 #25
0
        private void Btn_SendEmail_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (TBEmail_Forget.Text == "")
                {
                    MessageBox.Show("Email is required", "Warning", MessageBoxButton.OK);
                    TBEmail_Forget.Focus();
                }
                else
                {
                    var check_email = connection.Users.FirstOrDefault(S => S.Email == TBEmail_Forget.Text);

                    if (check_email != null)
                    {
                        var this_email = check_email.Email;
                        if (TBEmail_Forget.Text == this_email)
                        {
                            string New_Password = Guid.NewGuid().ToString();
                            var    check_user   = connection.Users.FirstOrDefault(S => S.Email == TBEmail_Forget.Text);
                            check_user.Password = New_Password;
                            var chagepassword = connection.SaveChanges();

                            if (chagepassword >= 1)
                            {
                                MessageBox.Show("Password has been updated");
                            }

                            Outlook._Application openapp  = new Outlook.Application();
                            Outlook.MailItem     sentmail = (Outlook.MailItem)openapp.CreateItem(Outlook.OlItemType.olMailItem);
                            sentmail.To         = TBEmail_Forget.Text;
                            sentmail.Subject    = "Forgot Password " + DateTime.Now.ToString("dd/MM/yyyy");
                            sentmail.Body       = "Dear " + TBEmail_Forget.Text + "\nThis Is Your Password : "******"Check Your Email for Your New Password", "Message", MessageBoxButton.OK);
                        }
                    }
                    else
                    {
                        MessageBox.Show("That Email Not Registered Yet!", "Warning", MessageBoxButton.OK);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #26
0
 public ActionResult Edit(int id, Supplier supplier)
 {
     try
     {
         // TODO: Add update logic here
         using (myContext connection = new myContext())
         {
             connection.Entry(supplier).State = EntityState.Modified;
             connection.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #27
0
        private void btnSendPassword_Click(object sender, RoutedEventArgs e)
        {
            var userData = con.Suppliers.Where(s => s.Email == txtEmail.Text).FirstOrDefault();

            if (userData == null)
            {
                MessageBox.Show("Email tidak terdaftar");
            }
            else
            {
                string newPassword = System.Guid.NewGuid().ToString();
                userData.Password = newPassword;
                var update = con.SaveChanges();
                sendPasswordToEmail(userData.Email, newPassword, userData.Name);
                MessageBox.Show("Please check your email");
            }
        }
コード例 #28
0
        public ActionResult Create(Customer customer)
        {
            myContext conn = new myContext();

            try
            {
                // TODO: Add insert logic here
                conn.Customers.Add(customer);
                conn.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #29
0
        public ActionResult EditarSede(Sedes sede)
        {
            myContext ctx = new myContext();

            if (ModelState.IsValid)
            {
                Sedes sedeOrig = (from se in ctx.Sedes where se.IdSede == sede.IdSede select se).FirstOrDefault();
                sedeOrig.Nombre        = sede.Nombre;
                sedeOrig.Direccion     = sede.Direccion;
                sedeOrig.PrecioGeneral = sede.PrecioGeneral;
                ctx.SaveChanges();

                var a = (ctx.Sedes).ToList();
                return(View("Sedes", a));
            }
            return(View());
        }
コード例 #30
0
        public ActionResult Create(Supplier supplier)
        {
            try
            {
                using (myContext connection = new myContext())
                {
                    connection.Suppliers.Add(supplier);
                    connection.SaveChanges();
                }
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }