public void Insert() { Console.Clear(); System.Console.Write("Masukkan Nama Departemen : "); string Nama_Departemen = System.Console.ReadLine(); System.Console.Write("Masukkan Id Departemen : "); int Id_dept = Convert.ToInt32(System.Console.ReadLine()); var getdept = _context.Departments.Find(Id_dept); Department department = new Department() { Id = Id_dept, Department_Name = Nama_Departemen }; try { _context.Departments.Add(department); var result = _context.SaveChanges(); } catch (Exception ex) { System.Console.Write(ex.InnerException); } }
public void Insert() { Console.Clear(); System.Console.Write("Masukkan Nama Departemen : "); string Nama_Rules = System.Console.ReadLine(); System.Console.Write("Masukkan Id Departemen : "); int Id_rules = Convert.ToInt32(System.Console.ReadLine()); var getdept = _context.Roles.Find(Id_rules); Role rules = new Role() { Id = Id_rules, Roles = Nama_Rules }; try { _context.Roles.Add(rules); var result = _context.SaveChanges(); } catch (Exception ex) { System.Console.Write(ex.InnerException); } }
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()); } }
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()); } }
public void Insert() { string nama, email, jobtitle, jenis_kelamin, password; DateTime tanggal_lahir; int id_dept, id_rol; // inputan by user 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()); // proses save ke database USER users = new USER() { name = nama, email = email, job_title = jobtitle, gender = jenis_kelamin, birth_date = tanggal_lahir, password = password, department_id = id_dept, role_id = id_rol }; try { context.Users.Add(users); context.SaveChanges(); } catch (Exception ex) { Console.Write(ex.InnerException); Console.Write(ex.Message); Console.Write(ex.StackTrace); } }
private void guardar() { FacturaVenta fv = new FacturaVenta(); fv.idEmpleado = idEmpleado; fv.fecha = DateTime.Now; fv.iva = 12; fv.descuento = 0; bd.FacturaVenta.Add(fv); bd.SaveChanges(); int contador = 0; foreach (var item in dtgFactura.Rows) { if (dtgFactura.Rows[contador].Cells["Identificador"].Value.ToString().Equals("1")) { try { DetalleFacturaVenta df = new DetalleFacturaVenta(); df.idFacturaVenta = idFactura; df.cantidad = Convert.ToDouble(dtgFactura.Rows[contador].Cells["Cantidad"].Value.ToString()); df.idProducto = 1; df.precio = 0; bd.DetalleFacturaVenta.Add(df); bd.SaveChanges(); } catch (Exception) { MessageBox.Show(""); } } else { DetalleFacturaVenta df = new DetalleFacturaVenta(); df.idFacturaVenta = idFactura; df.cantidad = Convert.ToDouble(dtgFactura.Rows[contador].Cells[1].Value.ToString()); df.idPlato = 1; df.precio = 0; bd.DetalleFacturaVenta.Add(df); bd.SaveChanges(); } contador++; } }
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()); } }
public ActionResult Create(news n) { try { if (ModelState.IsValid) { bd_context.news.Add(n); bd_context.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public void Insert() { string destination, status; DateTime departureDate, arrivalDate; int total, categoryId, userId; // 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 : "); userId = Convert.ToInt32(Console.ReadLine()); TRAVEL travels = new TRAVEL() { departure_date = departureDate, arrival_date = arrivalDate, destination = destination, status = status, total = total, category_id = categoryId, user_id = userId }; try { context.Travels.Add(travels); context.SaveChanges(); } catch (Exception ex) { Console.Write(ex.InnerException); Console.Write(ex.Message); Console.Write(ex.StackTrace); } }
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()); } }
public void Insert() { string nama, attachment; DateTime dateCheckin, dateCheckout; int harga, travel; // inputan by user Console.Write("Masukkan 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()); Console.Write("Masukkan ID Travel : "); travel = Convert.ToInt32(Console.ReadLine()); HOTEL_COST hotel_costs = new HOTEL_COST() { name = nama, cost = harga, attachment = attachment, date_checkin = dateCheckin, date_checkout = dateCheckout, travel_id = travel }; try { context.Hotel_Costs.Add(hotel_costs); context.SaveChanges(); } catch (Exception ex) { Console.Write(ex.InnerException); Console.Write(ex.Message); Console.Write(ex.StackTrace); } }
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()); } }
public void Insert() { string attachment; DateTime date; int harga, travel, types; // inputan by user Console.Write("Masukkan ID Travel : "); travel = Convert.ToInt32(Console.ReadLine()); Console.Write("Masukkan ID Type : "); types = Convert.ToInt32(Console.ReadLine()); Console.Write("Masukkan Cost Transport : "); harga = Convert.ToInt32(Console.ReadLine()); Console.Write("Attachment : "); attachment = Console.ReadLine(); Console.Write("Masukkan Date : "); date = Convert.ToDateTime(Console.ReadLine()); TRANSPORT_COST transport_costs = new TRANSPORT_COST() { cost = harga, attachment = attachment, date = date, travel_id = travel, type_id = types }; try { context.Transport_Costs.Add(transport_costs); context.SaveChanges(); } catch (Exception ex) { Console.Write(ex.InnerException); Console.Write(ex.Message); Console.Write(ex.StackTrace); } }
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 void Insert() { string nama; Console.Write("Masukan Nama Type : "); nama = Console.ReadLine(); TYPE types = new TYPE { name = nama }; try { context.Tipes.Add(types); context.SaveChanges(); } catch (Exception ex) { Console.Write(ex.InnerException); Console.Write(ex.Message); Console.Write(ex.StackTrace); } }
public void Insert() { string nama; Console.Write("Masukan Nama Department : "); nama = Console.ReadLine(); DEPARTMENT deparments = new DEPARTMENT { name = nama }; try { context.Departments.Add(deparments); context.SaveChanges(); } catch (Exception ex) { Console.Write(ex.InnerException); Console.Write(ex.Message); Console.Write(ex.StackTrace); } }
public void Insert() { string nama; Console.Write("Masukan Nama Category : "); nama = Console.ReadLine(); CATEGORY categories = new CATEGORY { name = nama }; try { context.Categories.Add(categories); context.SaveChanges(); } catch (Exception ex) { Console.Write(ex.InnerException); Console.Write(ex.Message); Console.Write(ex.StackTrace); } }
public IActionResult AddConnection(AddConnectionRequest model) { var loginId = ((Login)HttpContext.Items["Login"]).LoginId; //check if user already has registered this connection //get all connections from this user var connections = ctx.ConnectionTables.ToList().Where(c => c.LoginId == loginId).ToList(); if (connections.Exists(c => c.Database == model.Database && c.Host == model.Host && c.SqlPlatformId == Int32.Parse(model.SqlPlatformId) && c.Port == model.Port)) { return(BadRequest(new { error = true, message = "Identicall connection already registered." })); } ConnectionTable newConnection = new ConnectionTable { SqlPlatformId = Int32.Parse(model.SqlPlatformId), Database = model.Database, Host = model.Host, LoginId = loginId, Username = model.Username, Port = model.Port }; ctx.Add(newConnection); ctx.SaveChanges(); return(Ok(new { error = false, message = "Connection successfully created." })); }
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 void Commit() { dataContext.SaveChanges(); }