Ejemplo n.º 1
0
        public int Update(int input)
        {
            string nama;

            var types = context.Tipes.Find(input);

            Console.WriteLine("\n-------Data Sebelum Diupdate---------");
            Console.WriteLine("Id               : " + types.type_id);
            Console.WriteLine("Name Type        : " + types.name);
            Console.WriteLine("-------------------------------------\n");

            Console.Write("Masukan Nama Type : ");
            nama = Console.ReadLine();

            TYPE tYPE = GetById(input);

            tYPE.name = nama;

            context.Entry(tYPE).State = System.Data.Entity.EntityState.Modified;
            context.SaveChanges();

            Console.WriteLine("\n-------Data Setelah Diupdate---------");
            Console.WriteLine("Id               : " + tYPE.type_id);
            Console.WriteLine("Name Type        : " + tYPE.name);
            Console.WriteLine("-------------------------------------");

            return(input);
        }
Ejemplo n.º 2
0
        public int Update(int input)
        {
            string nama;

            var departments = context.Departments.Find(input);

            Console.WriteLine("\n-------Data Sebelum Diupdate---------");
            Console.WriteLine("Id               : " + departments.department_id);
            Console.WriteLine("Name Department  : " + departments.name);
            Console.WriteLine("-------------------------------------\n");

            Console.Write("Masukan Nama Department : ");
            nama = Console.ReadLine();

            DEPARTMENT dEPARTMENT = GetById(input);

            dEPARTMENT.name = nama;

            context.Entry(dEPARTMENT).State = System.Data.Entity.EntityState.Modified;
            context.SaveChanges();

            Console.WriteLine("\n-------Data Setelah Diupdate---------");
            Console.WriteLine("Id               : " + dEPARTMENT.department_id);
            Console.WriteLine("Name Department  : " + dEPARTMENT.name);
            Console.WriteLine("-------------------------------------");

            return(input);
        }
Ejemplo n.º 3
0
        public int Update(int input)
        {
            string nama;

            var roles = context.Roles.Find(input);

            Console.WriteLine("\n-------Data Sebelum Diupdate---------");
            Console.WriteLine("Id   : " + roles.role_id);
            Console.WriteLine("Name : " + roles.name);
            Console.WriteLine("-------------------------------------\n");

            Console.Write("Masukan Nama Role : ");
            nama = Console.ReadLine();

            ROLE rOLE = GetById(input);

            rOLE.name = nama;

            context.Entry(rOLE).State = System.Data.Entity.EntityState.Modified;
            context.SaveChanges();

            Console.WriteLine("\n-------Data Setelah Diupdate---------");
            Console.WriteLine("Id   : " + rOLE.role_id);
            Console.WriteLine("Name : " + rOLE.name);
            Console.WriteLine("-------------------------------------");

            return(input);
        }
Ejemplo n.º 4
0
        public int Update(int input)
        {
            string nama;

            var categories = context.Categories.Find(input);

            Console.WriteLine("\n-------Data Sebelum Diupdate---------");
            Console.WriteLine("Id               : " + categories.catagory_id);
            Console.WriteLine("Name Category    : " + categories.name);
            Console.WriteLine("-------------------------------------\n");

            Console.Write("Masukan Nama Category : ");
            nama = Console.ReadLine();

            CATEGORY cATEGORY = GetById(input);

            cATEGORY.name = nama;

            context.Entry(cATEGORY).State = System.Data.Entity.EntityState.Modified;
            context.SaveChanges();

            Console.WriteLine("\n-------Data Setelah Diupdate---------");
            Console.WriteLine("Id               : " + cATEGORY.catagory_id);
            Console.WriteLine("Name Category    : " + cATEGORY.name);
            Console.WriteLine("-------------------------------------");

            return(input);
        }
Ejemplo n.º 5
0
        public int Update(int input)
        {
            string   attachment;
            DateTime date;
            int      harga, types;
            // inputan by user

            var temp = from tc in context.Transport_Costs.ToList()
                       join t in context.Travels.ToList()
                       on tc.travel_id equals t.travel_id
                       join ty in context.Tipes.ToList()
                       on tc.type_id equals ty.type_id
                       select tc;
            TRANSPORT_COST transport_costs = context.Transport_Costs.Find(input);

            Console.WriteLine("------------Data sebelum di Update-------------");
            Console.WriteLine("\nID Travel        : " + transport_costs.travel_id);
            Console.WriteLine("ID Type          : " + transport_costs.type_id);
            Console.WriteLine("\n-------------------------");
            Console.WriteLine("Id               : " + transport_costs.transport_id);
            Console.WriteLine("Cost Transport   : " + transport_costs.cost);
            Console.WriteLine("Attachment       : " + transport_costs.attachment);
            Console.WriteLine("Date             : " + transport_costs.date);
            Console.WriteLine("-------------------------");

            Console.Write("\nMasukkan Cost Transport  : ");
            harga = Convert.ToInt32(Console.ReadLine());
            Console.Write("Attachment               : ");
            attachment = Console.ReadLine();
            Console.Write("Masukkan Date            : ");
            date = Convert.ToDateTime(Console.ReadLine());
            Console.Write("Masukkan ID Type       : ");
            types = Convert.ToInt32(Console.ReadLine());


            TRANSPORT_COST tRANSPORT_COST = context.Transport_Costs.Find(input);

            tRANSPORT_COST.cost       = harga;
            tRANSPORT_COST.attachment = attachment;
            tRANSPORT_COST.date       = date;
            tRANSPORT_COST.type_id    = types;

            context.Entry(tRANSPORT_COST).State = System.Data.Entity.EntityState.Modified;
            context.SaveChanges();

            Console.WriteLine("\n------------Data sesudah di Update-------------");
            Console.WriteLine("\nID Travel        : " + tRANSPORT_COST.travel_id);
            Console.WriteLine("ID Type          : " + tRANSPORT_COST.type_id);
            Console.WriteLine("\n-------------------------");
            Console.WriteLine("Id               : " + tRANSPORT_COST.transport_id);
            Console.WriteLine("Cost Transport   : " + tRANSPORT_COST.cost);
            Console.WriteLine("Attachment       : " + tRANSPORT_COST.attachment);
            Console.WriteLine("Date             : " + tRANSPORT_COST.date);
            Console.WriteLine("-------------------------");

            return(input);
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (verificar() == false)
            {
                return;
            }

            string cedula    = txtCedula.Text;
            string nombres   = txtNombres.Text;
            string apellidos = txtApellidos.Text;
            string direccion = txtDireccion.Text;
            string telefono  = txtTelefono.Text;
            string celular   = txtCelular.Text;
            string usuario   = txtUsuario.Text;
            string clave     = txtClave.Text;



            try
            {
                if (idEmpleado == 0)
                {
                    Empleado emp = new Empleado();
                    emp.cedula    = cedula;
                    emp.nombres   = nombres;
                    emp.apellidos = apellidos;
                    emp.direccion = direccion;
                    emp.telefono  = telefono;
                    emp.celular   = celular;
                    emp.usuario   = usuario;
                    emp.clave     = clave;

                    bd.Empleado.Add(emp);
                    bd.SaveChanges();
                    MessageBox.Show("Empleado agregada exitosamente");
                    limpiar();
                }
                else
                {
                    Empleado emp = bd.Empleado.Find(idEmpleado);
                    emp.cedula          = cedula;
                    emp.nombres         = nombres;
                    emp.apellidos       = apellidos;
                    emp.direccion       = direccion;
                    emp.telefono        = telefono;
                    emp.celular         = celular;
                    emp.usuario         = usuario;
                    emp.clave           = clave;
                    bd.Entry(emp).State = EntityState.Modified;
                    bd.SaveChanges();
                    MessageBox.Show("Empleado editado exitosamente");
                    limpiar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 7
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (verificar() == false)
            {
                return;
            }

            string cedula    = txtCedula.Text;
            string nombre    = txtNombre.Text;
            string ciudad    = txtCiudad.Text;
            string direccion = txtDireccion.Text;
            string telefono  = txtTelefono.Text;
            string celular   = txtCelular.Text;
            string mail      = txtMail.Text;


            try
            {
                if (idProveedor == 0)
                {
                    Proveedor pro = new Proveedor();
                    pro.cedula    = cedula;
                    pro.nombre    = nombre;
                    pro.ciudad    = ciudad;
                    pro.direccion = direccion;
                    pro.telefono  = telefono;
                    pro.celular   = celular;
                    pro.mail      = mail;
                    bd.Proveedor.Add(pro);
                    bd.SaveChanges();
                    MessageBox.Show("Proveedor agregada exitosamente");
                    limpiar();
                }
                else
                {
                    Proveedor pro = bd.Proveedor.Find(idProveedor);
                    pro.cedula          = cedula;
                    pro.nombre          = nombre;
                    pro.ciudad          = ciudad;
                    pro.direccion       = direccion;
                    pro.telefono        = telefono;
                    pro.celular         = celular;
                    pro.mail            = mail;
                    bd.Entry(pro).State = EntityState.Modified;
                    bd.SaveChanges();
                    MessageBox.Show("Categoría editada exitosamente");
                    limpiar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 8
0
        public int Update(int input)
        {
            System.Console.WriteLine("Masukkan Nama Roles : ");
            string Nama_Rules = System.Console.ReadLine();
            Role   rule       = GetById(input);

            department.Roles = Nama_Rules;
            _context.Entry(department).State = System.Data.Entity.EntityState.Modified;
            _context.SaveChanges();
            return(input);
        }
Ejemplo n.º 9
0
        public int Update(int input)
        {
            System.Console.WriteLine("Masukkan Nama Departemen : ");
            string     Nama_Departemen = System.Console.ReadLine();
            Department department      = GetById(input);

            department.Department_Name       = Nama_Departemen;
            _context.Entry(department).State = System.Data.Entity.EntityState.Modified;
            _context.SaveChanges();
            return(input);
        }
Ejemplo n.º 10
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (verificar() == false)
            {
                return;
            }

            string nombre = txtNombre.Text;
            string costo  = txtCosto.Text;
            string pvp    = txtPVP.Text;
            string stock  = txtStock.Text;



            try
            {
                if (idProducto == 0)
                {
                    Producto pro = new Producto();
                    pro.nombre = nombre;

                    /*  pro.costo = costo;
                     * pro.pvp = pvp;
                     * pro.stock = stock;*/

                    bd.Producto.Add(pro);
                    bd.SaveChanges();
                    MessageBox.Show("Producto agregado exitosamente");
                    limpiar();
                }
                else
                {
                    Producto pro = bd.Producto.Find(idProducto);
                    pro.nombre = nombre;

                    /* pro.costo = costo;
                     * pro.pvp = pvp;
                     * pro.stock = stock;*/

                    bd.Entry(pro).State = EntityState.Modified;
                    bd.SaveChanges();
                    MessageBox.Show("Producto editado exitosamente");
                    limpiar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 11
0
        public ActionResult Edit([Bind(Include = "idNews,description,picture,admin_id_Member,topic_idTopic")] news model_news)
        {
            news n = bd_context.news.Where(x => x.idNews == model_news.idNews).SingleOrDefault();

            try
            {
                if (n != null)
                {
                    bd_context.Entry(n).CurrentValues.SetValues(model_news);
                    bd_context.SaveChanges();
                }
                return(RedirectToAction("Index", "AdminNews"));
            }
            catch
            {
                return(View(model_news));
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (verificar() == false)
            {
                return;
            }

            string nombre   = txtNombre.Text;
            string detalles = txtDetalle.Text;
            float  pvp      = (float)Convert.ToDouble(txtPvp.Text);
            bool   activo   = Convert.ToBoolean(cmbEstado.Text);

            try
            {
                if (idPlato == 0)
                {
                    Plato pla = new Plato();
                    pla.nombre  = nombre;
                    pla.detalle = detalles;
                    pla.pvp     = pvp;
                    pla.activo  = activo;
                    bd.Plato.Add(pla);
                    bd.SaveChanges();
                    MessageBox.Show("Proveedor agregada exitosamente");
                    limpiar();
                }
                else
                {
                    Plato pla = bd.Plato.Find(idPlato);
                    pla.nombre          = nombre;
                    pla.detalle         = detalles;
                    pla.pvp             = pvp;
                    pla.activo          = activo;
                    bd.Entry(pla).State = EntityState.Modified;
                    bd.SaveChanges();
                    MessageBox.Show("Categoría editada exitosamente");
                    limpiar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (verificar() == false)
            {
                return;
            }



            string nombre  = txtNombre.Text;
            string detalle = txtDetalle.Text;



            try
            {
                if (idReceta == 0)
                {
                    Receta rec = new Receta();
                    rec.nombre  = nombre;
                    rec.detalle = detalle;

                    bd.Receta.Add(rec);
                    bd.SaveChanges();
                    MessageBox.Show("Receta agregada exitosamente");
                    limpiar();
                }
                else
                {
                    Receta rec = bd.Receta.Find(idReceta);
                    rec.nombre          = nombre;
                    rec.detalle         = detalle;
                    bd.Entry(rec).State = EntityState.Modified;
                    bd.SaveChanges();
                    MessageBox.Show("Receta editada exitosamente");
                    limpiar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 14
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (verificar() == false)
            {
                return;
            }



            string nombre = txtNombre.Text;



            try
            {
                if (idCategoria == 0)
                {
                    Categoria cat = new Categoria();
                    cat.nombreCategoria = nombre;

                    bd.Categoria.Add(cat);
                    bd.SaveChanges();
                    MessageBox.Show("Categoría agregada exitosamente");
                    limpiar();
                }
                else
                {
                    Categoria cat = bd.Categoria.Find(idCategoria);
                    cat.nombreCategoria = nombre;
                    bd.Entry(cat).State = EntityState.Modified;
                    bd.SaveChanges();
                    MessageBox.Show("Categoría editada exitosamente");
                    limpiar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        public int Update(int input)
        {
            string   nama, attachment;
            DateTime dateCheckin, dateCheckout;
            int      harga;

            var temp = from h in context.Hotel_Costs.ToList()
                       join t in context.Travels.ToList()
                       on h.travel_id equals t.travel_id
                       where h.hotel_id == input
                       select h;

            HOTEL_COST hotel_costs = context.Hotel_Costs.Find(input);

            Console.WriteLine("------------Data sebelum di Update-------------");
            Console.WriteLine("\nID Travel        : " + hotel_costs.travel_id);
            Console.WriteLine("-------------------------");
            Console.WriteLine("Id           : " + hotel_costs.hotel_id);
            Console.WriteLine("Name Hotel   : " + hotel_costs.name);
            Console.WriteLine("Cost Hotel   : " + hotel_costs.cost);
            Console.WriteLine("Attachment   : " + hotel_costs.attachment);
            Console.WriteLine("Date Checkin : " + hotel_costs.date_checkin);
            Console.WriteLine("Date Checkout: " + hotel_costs.date_checkout);
            Console.WriteLine("-------------------------");

            // inputan by user
            Console.Write("\nMasukkan Nama Hotel      : ");
            nama = Console.ReadLine();
            Console.Write("Masukkan Cost Hotel      : ");
            harga = Convert.ToInt32(Console.ReadLine());
            Console.Write("Attachment               : ");
            attachment = Console.ReadLine();
            Console.Write("Masukkan Date Checkin    : ");
            dateCheckin = Convert.ToDateTime(Console.ReadLine());
            Console.Write("Masukkan Date Checkout   : ");
            dateCheckout = Convert.ToDateTime(Console.ReadLine());


            HOTEL_COST hOTEL_COST = GetById(input);

            hOTEL_COST.name          = nama;
            hOTEL_COST.cost          = harga;
            hOTEL_COST.attachment    = attachment;
            hOTEL_COST.date_checkin  = dateCheckin;
            hOTEL_COST.date_checkout = dateCheckout;


            context.Entry(hOTEL_COST).State = System.Data.Entity.EntityState.Modified;
            context.SaveChanges();

            Console.WriteLine("------------Data sesudah di Update-------------");
            Console.WriteLine("\nID Travel        : " + hotel_costs.travel_id);
            Console.WriteLine("-------------------------");
            Console.WriteLine("Id           : " + hotel_costs.hotel_id);
            Console.WriteLine("Name Hotel   : " + hotel_costs.name);
            Console.WriteLine("Cost Hotel   : " + hotel_costs.cost);
            Console.WriteLine("Attachment   : " + hotel_costs.attachment);
            Console.WriteLine("Date Checkin : " + hotel_costs.date_checkin);
            Console.WriteLine("Date Checkout: " + hotel_costs.date_checkout);
            Console.WriteLine("----------------------------------------------");

            return(input);
        }
Ejemplo n.º 16
0
        public int Update(int input)
        {
            string   destination, status;
            DateTime departureDate, arrivalDate;
            int      total, categoryId;

            var temp = from t in context.Travels.ToList()
                       join u in context.Users.ToList()
                       on t.user_id equals u.user_id
                       where t.travel_id == input
                       select t;

            TRAVEL travels = context.Travels.Find(input);

            Console.WriteLine("--------Data sebelum di Update--------\n");
            Console.WriteLine("Nama User        : "******"Category         : " + travels.category_id);
            Console.WriteLine("-------------------------");
            Console.WriteLine("Id               : " + travels.travel_id);
            Console.WriteLine("Departure Date   : " + travels.departure_date);
            Console.WriteLine("Arrival Date     : " + travels.arrival_date);
            Console.WriteLine("Destination      : " + travels.destination);
            Console.WriteLine("Status           : " + travels.status);
            Console.WriteLine("Total            : " + travels.total);
            Console.WriteLine("------------------------\n");

            // inputan by user
            Console.Write("Masukkan Departure Date      : ");
            departureDate = Convert.ToDateTime(Console.ReadLine());
            Console.Write("Masukkan Arrival Date        : ");
            arrivalDate = Convert.ToDateTime(Console.ReadLine());
            Console.Write("Masukkan Destination         : ");
            destination = Console.ReadLine();
            Console.Write("Masukkan Status              : ");
            status = Console.ReadLine();
            Console.Write("Masukkan Total               : ");
            total = Convert.ToInt32(Console.ReadLine());
            Console.Write("Masukkan Category            : ");
            categoryId = Convert.ToInt32(Console.ReadLine());

            /*Console.Write("Masukkan Id User             : "******"\n--------Data setelah di Update--------\n");
            Console.WriteLine("Nama User        : "******"Category         : " + tRAVEL.category_id);
            Console.WriteLine("-------------------------");
            Console.WriteLine("Id               : " + tRAVEL.travel_id);
            Console.WriteLine("Departure Date   : " + tRAVEL.departure_date);
            Console.WriteLine("Arrival Date     : " + tRAVEL.arrival_date);
            Console.WriteLine("Destination      : " + tRAVEL.destination);
            Console.WriteLine("Status           : " + tRAVEL.status);
            Console.WriteLine("Total            : " + tRAVEL.total);
            Console.WriteLine("-------------------------");

            return(input);
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (verificar() == false)
            {
                return;
            }



            string cedula = txtCedula.Text;

            string nombres   = txtNombres.Text;
            string apellidos = txtApellidos.Text;
            string direccion = txtDireccion.Text;
            string telefono  = txtTelefono.Text;
            string celular   = txtCelular.Text;
            string email     = txtEmail.Text;


            try
            {
                if (idCliente == 0)
                {
                    Cliente cli = new Cliente();
                    cli.cedula = cedula;

                    cli.nombres   = nombres;
                    cli.apellidos = apellidos;
                    cli.direccion = direccion;
                    cli.telefono  = telefono;
                    cli.celular   = celular;
                    cli.mail      = email;



                    bd.Cliente.Add(cli);
                    bd.SaveChanges();
                    MessageBox.Show("Cliente agregado exitosamente");
                    limpiar();
                }
                else
                {
                    Cliente cli = bd.Cliente.Find(idCliente);
                    cli.cedula = cedula;

                    cli.nombres         = nombres;
                    cli.apellidos       = apellidos;
                    cli.direccion       = direccion;
                    cli.telefono        = telefono;
                    cli.celular         = celular;
                    cli.mail            = email;
                    txtCedula.ReadOnly  = true;
                    bd.Entry(cli).State = EntityState.Modified;
                    bd.SaveChanges();
                    MessageBox.Show("Cliente editado exitosamente");
                    limpiar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
 public virtual void Update(T entity)
 {
     dbset.Attach(entity);
     dataContext.Entry(entity).State = EntityState.Modified;
 }
Ejemplo n.º 19
0
        public int Update(int input)
        {
            string   nama, email, jobtitle, jenis_kelamin, password;
            DateTime tanggal_lahir;
            //int id_dept, id_rol;
            // inputan by user
            var getAll = from u in context.Users.ToList()
                         join d in context.Departments.ToList()
                         on u.department_id equals d.department_id
                         join r in context.Roles.ToList()
                         on u.role_id equals r.role_id
                         select u;

            var users = context.Users.Find(input);

            if (users == null)
            {
                Console.Write("User dengan ID " + input + " tidak tersedia");
            }
            else
            {
                Console.WriteLine("--------Data Sebelum di Update---------");
                Console.WriteLine("Id           : " + users.user_id);
                Console.WriteLine("Name         : " + users.name);
                Console.WriteLine("Email        : " + users.email);
                Console.WriteLine("Job Title    : " + users.job_title);
                Console.WriteLine("Gender       : " + users.gender);
                Console.WriteLine("Birth Date   : " + users.birth_date);
                Console.WriteLine("Password     : "******"Department   : " + users.Departments.name);
                Console.WriteLine("Role         : " + users.Roles.name);
                Console.WriteLine("-------------------------\n");

                Console.Write("Masukkan Nama Lengkap    : ");
                nama = Console.ReadLine();
                Console.Write("Masukkan Email           : ");
                email = Console.ReadLine();
                Console.Write("Masukkan Job Title       : ");
                jobtitle = Console.ReadLine();
                Console.Write("Masukkan Gender          : ");
                jenis_kelamin = Console.ReadLine();
                Console.Write("Masukkan Birth Date      : ");
                tanggal_lahir = Convert.ToDateTime(Console.ReadLine());
                Console.Write("Masukkan Password        : "******"Masukkan Department ID : ");
                 * id_dept = Convert.ToInt32(Console.ReadLine());
                 * Console.Write("Masukkan Role ID : ");
                 * id_rol = Convert.ToInt32(Console.ReadLine());*/


                USER uSER = GetById(input);
                uSER.name       = nama;
                uSER.email      = email;
                uSER.job_title  = jobtitle;
                uSER.gender     = jenis_kelamin;
                uSER.birth_date = tanggal_lahir;
                uSER.password   = password;

                context.Entry(uSER).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();

                Console.WriteLine("\n--------Data Sesudah di Update---------");
                Console.WriteLine("Id           : " + users.user_id);
                Console.WriteLine("Name         : " + users.name);
                Console.WriteLine("Email        : " + users.email);
                Console.WriteLine("Job Title    : " + users.job_title);
                Console.WriteLine("Gender       : " + users.gender);
                Console.WriteLine("Birth Date   : " + users.birth_date);
                Console.WriteLine("Password     : "******"Department   : " + users.department_id);
                Console.WriteLine("Role         : " + users.role_id);
                Console.WriteLine("-------------------------");
            }



            return(input);
        }