public override bool Editar() { DbVentana cone = new DbVentana(); DataTable dt = new DataTable(); bool Retornar = false; try { Retornar = cone.Ejecutar(String.Format("Update Proyectos set Fecha = Convert(datetime,'{0}',5),Total={1} where ProyectoId={2}", this.Fecha, this.Total, this.ProyectoId)); if (Retornar) { cone.Ejecutar(String.Format("Delete from ProyectosDetalle where ProyectoId = {0}", this.ProyectoId)); cone.Ejecutar(String.Format("Delete from ProyectoPresupuesto where ProyectoId = {0}", this.ProyectoId)); foreach (ProyectosDetalle item in this.Detalle) { cone.Ejecutar(String.Format("Insert Into ProyectosDetalle(ProyectoId,ProductoId,Pie,Ancho,Altura,Precio) Values({0},{1},{2},{3},{4},{5})", this.ProyectoId, item.ProductoId, item.Pie, item.Ancho, item.Altura, item.Precio)); dt = cone.ObtenerDatos(String.Format("Select * from ProductosDetalle where ProductoId ={0}", item.ProductoId)); foreach (DataRow row in dt.Rows) { this.ListaMateriales.Add(new ProductosDetalle(Convert.ToInt32(row[2]), Convert.ToInt32(row[3]))); } //recorrer lista materiales para insertar cada material y el calculo de su valor o cantidad en la tabla pryecto conduce foreach (ProductosDetalle item2 in this.ListaMateriales) { if (item2.Asociacion == 0) { item2.Cantidad = item.Ancho / 12; } else if (item2.Asociacion == 1) { item2.Cantidad = item.Altura / 12; } else { item2.Cantidad = 1; } cone.Ejecutar(String.Format("Insert Into ProyectoPresupuesto(ProyectoId,MaterialId,Cantidad) Values({0},{1},{2}) ", this.ProyectoId, item2.MaterialId, item2.Cantidad)); } } } }catch (Exception ex) { throw ex; } return(Retornar); }
public override bool Insertar() { DbVentana cone = new DbVentana(); bool Retornar = false; try { Retornar = cone.Ejecutar(String.Format("Insert into Materiales(Detalle,Unidad,Cantidad,Precio) Values('{0}','{1}',{2},{3})", this.Detalle, this.Unidad, this.Cantidad, this.Precio)); cone.Ejecutar(String.Format("Insert into TotalMateriales(Total) Values({0}", this.Precio)); } catch (Exception ex) { throw ex; } return(Retornar); }
public override bool Insertar() { int Retornar = 0; DbVentana cone = new DbVentana(); object Identity = null; try { Identity = cone.ObtenerValor(String.Format("Insert into Productos(Descripcion,Pie,MinimoPie) Values('{0}',{1},{2}) SELECT @@Identity", this.Descripcion, this.Pie, this.MinimoPie)); int.TryParse(Identity.ToString(), out Retornar); if (Retornar > 0) { foreach (ProductosDetalle item in this.Detalle) { cone.Ejecutar(String.Format("Insert into ProductosDetalle(ProductoId,MaterialId,Asociacion) Values({0},{1},{2})", Retornar, item.MaterialId, item.Asociacion)); } } }catch (Exception ex) { throw ex; } return(Retornar > 0); }
public override bool Insertar() { DbVentana cone = new DbVentana(); DataTable dt = new DataTable(); int Retornar = 0; object Identity; try { Identity = cone.ObtenerValor(String.Format("Insert Into Proyectos(Fecha,Total,ClienteId) values(Convert(datetime,'{0}',5),{1},{2}) SELECT @@Identity", this.Fecha, this.Total, this.ClienteId)); int.TryParse(Identity.ToString(), out Retornar); if (Retornar > 0) { object Identity2; int Retornar2 = 0; foreach (ProyectosDetalle item in this.Detalle) { //areglar ete insert (poner id del producto) Identity2 = cone.ObtenerValor(String.Format("Insert Into ProyectosDetalle(ProyectoId,ProductoId,Pie,Ancho,Altura,Precio) Values({0},'{1}',{2},{3},{4},{5}) SELECT @@Identity", Retornar, item.ProductoId, item.Pie, item.Ancho, item.Altura, item.Precio)); int.TryParse(Identity2.ToString(), out Retornar2); //con el id anterior del producto hacer un select a a la tabla productodetalle y llenar ListaMateriales dt = cone.ObtenerDatos(String.Format("Select * from ProductosDetalle where ProductoId ={0}", item.ProductoId)); foreach (DataRow row in dt.Rows) { this.ListaMateriales.Add(new ProductosDetalle(Convert.ToInt32(row[2]), Convert.ToInt32(row[3]))); } //recorrer lista materiales para insertar cada material y el calculo de su valor o cantidad en la tabla pryecto conduce foreach (ProductosDetalle item2 in this.ListaMateriales) { if (item2.Asociacion == 0) { item2.Cantidad = item.Ancho / 12; } else if (item2.Asociacion == 1) { item2.Cantidad = item.Altura / 12; } cone.Ejecutar(String.Format("Insert Into ProyectoPresupuesto(ProyectoId,MaterialId,Cantidad) Values({0},{1},{2}) ", Retornar, item2.MaterialId, item2.Cantidad)); } } } return(Retornar > 0); }catch (Exception ex) { throw ex; } }
public override bool Eliminar() { bool Retornar = false; DbVentana cone = new DbVentana(); try { Retornar = cone.Ejecutar(String.Format("Delete from ProductosDetalle where ProductoId ={0}; " + "Delete from Productos where ProductoId={0}", this.ProductoId)); }catch (Exception ex) { throw ex; } return(Retornar); }
public override bool Eliminar() { DbVentana cone = new DbVentana(); bool Retornar = false; try { Retornar = cone.Ejecutar(String.Format("Delete from Cliente where IdCliente= ", this.IdCliente)); }catch (Exception ex) { throw ex; } return(Retornar); }
public override bool Editar() { DbVentana cone = new DbVentana(); bool Retornar = false; try { Retornar = cone.Ejecutar(String.Format("Update Cliente set Nombre='{0}',Telefono='{1}',Cedula='{2}',Direccion='{3}',Email='{4}' where IdCliente={5} ", this.Nombre, this.Telefono, this.Cedula, this.Direccion, this.Email, this.IdCliente)); }catch (Exception ex) { throw ex; } return(Retornar); }
public override bool Insertar() { DbVentana cone = new DbVentana(); bool Retornar = false; try { Retornar = cone.Ejecutar(String.Format("Insert into Cliente(Nombre,Telefono,Cedula,Direccion,Email)Values('{0}','{1}','{2}','{3}','{4}')", this.Nombre, this.Telefono, this.Cedula, this.Direccion, this.Email)); }catch (Exception ex) { throw ex; } return(Retornar); }
public override bool Editar() { bool Retornar = false; DbVentana cone = new DbVentana(); try { Retornar = cone.Ejecutar(String.Format("Update Productos set Descripcion='{0}',Pie={1},MinimoPie={2} where ProductoId={3}", this.Descripcion, this.Pie, this.MinimoPie, this.ProductoId)); if (Retornar) { cone.Ejecutar(String.Format("Delete from ProductosDetalle where ProductoId={0}", this.ProductoId)); foreach (ProductosDetalle item in this.Detalle) { cone.Ejecutar(String.Format("Insert into ProductosDetalle(ProductoId,MaterialId,Asociacion) Values({0},{1},{2})", this.ProductoId, item.MaterialId, item.Asociacion)); } } }catch (Exception ex) { throw ex; } return(Retornar); }
public override bool Eliminar() { bool Retornar = false; DbVentana cone = new DbVentana(); try { Retornar = cone.Ejecutar(String.Format("Delete From Usuario where IdUsuario ={0}", this.IdUsuario)); } catch (Exception ex) { throw ex; } return(Retornar); }
public override bool Editar() { bool retornar = false; DbVentana cone = new DbVentana(); try { retornar = cone.Ejecutar(String.Format("Update Usuario set Contrasena='{0}',UserName='******',Nombre='{2}',Restriccion = {3} WHERE IdUsuario = {4}", this.Contrasena, this.UserName, this.Nombre, this.Restriccion, this.IdUsuario)); } catch (Exception ex) { throw ex; } return(retornar); }
public override bool Insertar() { DbVentana cone = new DbVentana(); bool retornar = false; try { retornar = cone.Ejecutar(String.Format("Insert into Usuario(Contrasena,UserName,Restriccion,Nombre,Imagenes) Values('{0}','{1}', {2},'{3}','{4}')", this.Contrasena, this.UserName, this.Restriccion, this.Nombre, this.Imagenes)); } catch (Exception ex) { throw ex; } return(retornar); }
public override bool Eliminar() { DbVentana cone = new DbVentana(); bool Retornar = false; try { Retornar = cone.Ejecutar(String.Format("Delete from Materiales where MaterialId={0}", this.MaterialId)); } catch (Exception ex) { throw ex; } return(Retornar); }
public override bool Editar() { DbVentana cone = new DbVentana(); bool Retornar = false; try { Retornar = cone.Ejecutar(String.Format("Update Materiales set Detalle='{0}',Unidad='{1}',Cantidad={2},Precio={3} where MaterialId={4}", this.Detalle, this.Unidad, this.Cantidad, this.Precio, this.MaterialId)); } catch (Exception ex) { throw ex; } return(Retornar); }