protected void Button2_Click(object sender, EventArgs e) { int confirmacion = 0; int doc = 0; int correo = 0; int proceso_rol = 0; // int rol_nuevo = 0; DTOUsuario user = new DTOUsuario(); CADUsuario procesos = new CADUsuario(); try { //int dni = int.Parse(identificacion.Text); //int tel = int.Parse(telefono.Text); //rol_nuevo = int.Parse(roles.SelectedValue); user.Id = int.Parse(ViewState["id_user"].ToString()); // rol_viejo = (procesos.ObtenerIdRolUsuarioParaModificar(user)); confirmacion = 2; } catch { confirmacion = 0; ScriptManager.RegisterClientScriptBlock(this, GetType(), "nopermitecamp", "campos();", true); } if (nombres.Text != "") { confirmacion = confirmacion + 1; } if (apellidos.Text != "") { confirmacion = confirmacion + 1; } if (email.Text != "") { confirmacion = confirmacion + 1; } if (password.Text != "" && password.Text == confirmpassword.Text) { confirmacion = confirmacion + 1; } if (confirmacion == 6) { user.Dni = identificacion.Text; user.Nombre = nombres.Text; user.Apellidos = apellidos.Text; user.Correo = email.Text; user.Contraseña = password.Text; user.Tel = telefono.Text; user.Id_u_logueado = int.Parse(Convert.ToString(Session["id_usuario"])); user.Descripcion_history = "Actualización usuario: " + identificacion.Text; if (procesos.ConsultarDNIPorId(user) != (identificacion.Text)) { doc = 1; } if (procesos.ConsultarCorreoPorId(user) != email.Text) { correo = 1; } if (correo == 1 && doc == 1) { if (procesos.ConsultarUsuarioPorDni(user) == 0) { if (procesos.ConsultarUsuarioPorCorreo(user) == 0) { if (procesos.ActualizarUsuario(user) == 0) { foreach (ListItem rolselected in rolesuser.Items) { user.Id_rol = int.Parse(rolselected.Value); if (rolselected.Selected) { if (procesos.BuscarSiRolEstaAsignado(user) == 0) { if (procesos.AsignarRolUsuario(user) == 0) { proceso_rol++; } } else { proceso_rol++; } } else { if (procesos.BuscarSiRolEstaAsignado(user) > 0) { if (procesos.EliminarRolAsignado(user) == 0) { proceso_rol++; } } } } if (proceso_rol > 0) { procesos.InsertarHistorial(user); identificacion.Text = ""; nombres.Text = ""; apellidos.Text = ""; email.Text = ""; password.Text = ""; confirmpassword.Text = ""; telefono.Text = ""; //Estadou.SelectedIndex = 0; //picture1.Text = ""; Button1.CssClass = "btn btn-default"; Button1.Enabled = true; Button2.CssClass = "btn btn-default"; Button2.Enabled = false; //FileUpload1.Enabled = true; Button3.CssClass = "btn btn-default"; Button3.Enabled = false; rolesuser.ClearSelection(); // procesos.ConsultarUltimoIdUsuario(CodigoUsuario); ScriptManager.RegisterClientScriptBlock(this, GetType(), "modif", "modificacion();", true); } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "unerror", "Problema();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "errores", "Problema();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "email", "yaexistecorreo();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "dni", "yaexistedni();", true); } } if (correo == 1 && doc == 0) { if (procesos.ConsultarUsuarioPorCorreo(user) == 0) { if (procesos.ActualizarUsuario(user) == 0) { foreach (ListItem rolselected in rolesuser.Items) { user.Id_rol = int.Parse(rolselected.Value); if (rolselected.Selected) { if (procesos.BuscarSiRolEstaAsignado(user) == 0) { if (procesos.AsignarRolUsuario(user) == 0) { proceso_rol++; } } else { proceso_rol++; } } else { if (procesos.BuscarSiRolEstaAsignado(user) > 0) { if (procesos.EliminarRolAsignado(user) == 0) { proceso_rol++; } } } } if (proceso_rol > 0) { procesos.InsertarHistorial(user); identificacion.Text = ""; nombres.Text = ""; apellidos.Text = ""; email.Text = ""; password.Text = ""; confirmpassword.Text = ""; telefono.Text = ""; //Estadou.SelectedIndex = 0; //picture1.Text = ""; Button1.CssClass = "btn btn-default"; Button1.Enabled = true; Button2.CssClass = "btn btn-default"; Button2.Enabled = false; //FileUpload1.Enabled = true; Button3.CssClass = "btn btn-default"; Button3.Enabled = false; rolesuser.ClearSelection(); //procesos.ConsultarUltimoIdUsuario(CodigoUsuario); ScriptManager.RegisterClientScriptBlock(this, GetType(), "modif", "modificacion();", true); } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "unerror", "Problema();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "Problema();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "email", "yaexistecorreo();", true); } } if (doc == 1 && correo == 0) { if (procesos.ConsultarUsuarioPorDni(user) == 0) { if (procesos.ActualizarUsuario(user) == 0) { foreach (ListItem rolselected in rolesuser.Items) { user.Id_rol = int.Parse(rolselected.Value); if (rolselected.Selected) { if (procesos.BuscarSiRolEstaAsignado(user) == 0) { if (procesos.AsignarRolUsuario(user) == 0) { proceso_rol++; } } else { proceso_rol++; } } else { if (procesos.BuscarSiRolEstaAsignado(user) > 0) { if (procesos.EliminarRolAsignado(user) == 0) { proceso_rol++; } } } } if (proceso_rol > 0) { procesos.InsertarHistorial(user); identificacion.Text = ""; nombres.Text = ""; apellidos.Text = ""; email.Text = ""; password.Text = ""; confirmpassword.Text = ""; telefono.Text = ""; //Estadou.SelectedIndex = 0; //picture1.Text = ""; Button1.CssClass = "btn btn-default"; Button1.Enabled = true; Button2.CssClass = "btn btn-default"; Button2.Enabled = false; //FileUpload1.Enabled = true; Button3.CssClass = "btn btn-default"; Button3.Enabled = false; rolesuser.ClearSelection(); // procesos.ConsultarUltimoIdUsuario(CodigoUsuario); ScriptManager.RegisterClientScriptBlock(this, GetType(), "modif", "modificacion();", true); } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "unerror", "Problema();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "Problema();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "dni", "yaexistedni();", true); } } if (correo == 0 && doc == 0) { if (procesos.ActualizarUsuario(user) == 0) { foreach (ListItem rolselected in rolesuser.Items) { user.Id_rol = int.Parse(rolselected.Value); if (rolselected.Selected) { if (procesos.BuscarSiRolEstaAsignado(user) == 0) { if (procesos.AsignarRolUsuario(user) == 0) { proceso_rol++; } } else { proceso_rol++; } } else { if (procesos.BuscarSiRolEstaAsignado(user) > 0) { if (procesos.EliminarRolAsignado(user) == 0) { proceso_rol++; } } } } if (proceso_rol > 0) { procesos.InsertarHistorial(user); identificacion.Text = ""; nombres.Text = ""; apellidos.Text = ""; email.Text = ""; password.Text = ""; confirmpassword.Text = ""; telefono.Text = ""; //Estadou.SelectedIndex = 0; // picture1.Text = ""; Button1.CssClass = "btn btn-default"; Button1.Enabled = true; Button2.CssClass = "btn btn-default"; Button2.Enabled = false; //FileUpload1.Enabled = true; Button3.CssClass = "btn btn-default"; Button3.Enabled = false; rolesuser.ClearSelection(); // procesos.ConsultarUltimoIdUsuario(CodigoUsuario); ScriptManager.RegisterClientScriptBlock(this, GetType(), "modif", "modificacion();", true); } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "unerror", "Problema();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "Problema();", true); } } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "nocamp", "campos();", true); } GVUsuarios.EditIndex = -1; procesos.CargarUsuarios(GVUsuarios); }
private void btnAceptar_Click(object sender, EventArgs e) { if (txtEmpresa.Text == string.Empty) { errorProvider1.SetError(txtEmpresa, "Debe ingresar el Nit de la empresa"); txtEmpresa.Focus(); return; } errorProvider1.SetError(txtUsuario, string.Empty); decimal cantidad; if (!decimal.TryParse(txtEmpresa.Text, out cantidad)) { errorProvider1.SetError(txtEmpresa, "La información ingresada no corresponde a un Nit"); return; } errorProvider1.SetError(txtEmpresa, string.Empty); if (!CADEmpresa.ValidaExisteEmpresa(Convert.ToInt32(txtEmpresa.Text))) { errorProvider1.SetError(txtEmpresa, "No se encuentra el Nit de la empresa, verifíquelo"); return; } errorProvider1.SetError(txtEmpresa, string.Empty); if (txtUsuario.Text == string.Empty) { errorProvider1.SetError(txtUsuario, "Debe ingresar el nombre de usuario"); txtUsuario.Focus(); return; } errorProvider1.SetError(txtUsuario, string.Empty); if (txtClave.Text == string.Empty) { errorProvider1.SetError(txtClave, "Debe ingresar una clave"); txtClave.Focus(); return; } errorProvider1.SetError(txtClave, string.Empty); if (!CADUsuario.ValidarUsuario(txtUsuario.Text, txtClave.Text)) { MessageBox.Show("Usuario o clave no válidos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtEmpresa.Text = string.Empty; txtUsuario.Text = string.Empty; txtClave.Text = string.Empty; txtEmpresa.Focus(); return; } this.Hide(); frmSaludoUsuario miForm = new frmSaludoUsuario(); miForm.UsuarioLogueado = CADUsuario.GetUsuario(txtUsuario.Text); miForm.EmpresaLogueada = CADEmpresa.GetEmpresa(Convert.ToInt32(txtEmpresa.Text)); miForm.ShowDialog(); //CADUsuario.UpdateUltimoIngreso(txtUsuario.Text); }
protected void Button1_Click(object sender, EventArgs e) { int confirmacion = 0; int rol = 0; DTOUsuario user = new DTOUsuario(); CADUsuario procesos = new CADUsuario(); try { //int dni = int.Parse(identificacion.Text); //int tel = int.Parse(telefono.Text); //rol = int.Parse(roles.SelectedValue); int count = 0; foreach (ListItem rolselect in rolesuser.Items) { if (rolselect.Selected) { count++; } } if (count > 0) { confirmacion = 2; } } catch { confirmacion = 0; ScriptManager.RegisterClientScriptBlock(this, GetType(), "nopermitecamp", "campos();", true); } if (nombres.Text != "") { confirmacion = confirmacion + 1; } if (apellidos.Text != "") { confirmacion = confirmacion + 1; } if (email.Text != "") { confirmacion = confirmacion + 1; } if (password.Text != "" && password.Text == confirmpassword.Text) { confirmacion = confirmacion + 1; } /*if (FileUpload1.FileName.ToString() == "") * { * picture1.Text = "photoperfilpodefecto.jpg"; * } * else * { * picture1.Text = FileUpload1.FileName.ToString(); * }*/ if (confirmacion == 6) { //user.Id = Convert.ToInt32(CodigoUsuario.Text); user.Dni = identificacion.Text; user.Nombre = nombres.Text; user.Apellidos = apellidos.Text; user.Correo = email.Text; user.Contraseña = password.Text; user.Tel = telefono.Text; user.Estado = "Habilitado"; //user.Foto = ("Fotos/" + picture1.Text); user.Foto = "Fotos/photoperfilpodefecto.jpg"; if (procesos.ConsultarUsuarioPorDni(user) == 0) { if (procesos.ConsultarUsuarioPorCorreo(user) == 0) { if (procesos.InsertarUsuario(user) == 0) { string id = procesos.ObtenerIDUsuarioAlIngresarAlSistema(user); user.Id = int.Parse(id); /*if (picture1.Text != "photoperfilpodefecto.jpg") * { * FileUpload1.SaveAs(Server.MapPath("Fotos\\" + FileUpload1.FileName)); * }*/ foreach (ListItem rolselected in rolesuser.Items) { if (rolselected.Selected) { user.Id_rol = int.Parse(rolselected.Value); if (procesos.AsignarRolUsuario(user) == 0) { rol++; } } } if (rol != 0) { procesos.EnviarCorreoRegistro(user); user.Id_u_logueado = int.Parse(Convert.ToString(Session["id_usuario"])); user.Descripcion_history = "Registro usuario: " + identificacion.Text; procesos.InsertarHistorial(user); identificacion.Text = ""; nombres.Text = ""; apellidos.Text = ""; email.Text = ""; password.Text = ""; confirmpassword.Text = ""; telefono.Text = ""; Estadou.SelectedIndex = 0; //picture1.Text = ""; //procesos.ConsultarUltimoIdUsuario(CodigoUsuario); rolesuser.ClearSelection(); procesos.CargarUsuarios(GVUsuarios); ScriptManager.RegisterClientScriptBlock(this, GetType(), "mensaje", "registro();", true); } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "problema();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "problema();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "registrado", "yaexistecorreo();", true); identificacion.Text = ""; nombres.Text = ""; apellidos.Text = ""; email.Text = ""; password.Text = ""; confirmpassword.Text = ""; telefono.Text = ""; Estadou.SelectedIndex = 0; //picture1.Text = ""; rolesuser.ClearSelection(); // procesos.ConsultarUltimoIdUsuario(CodigoUsuario); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "ya", "yaexistedni();", true); identificacion.Text = ""; nombres.Text = ""; apellidos.Text = ""; email.Text = ""; password.Text = ""; confirmpassword.Text = ""; telefono.Text = ""; Estadou.SelectedIndex = 0; //picture1.Text = ""; rolesuser.ClearSelection(); // procesos.ConsultarUltimoIdUsuario(CodigoUsuario); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "nopermite", "campos();", true); } }
protected void btn_Registrar_Click(object sender, EventArgs e) { int val = 0; int consu = 2; int confirma = 0; int cantid_p = 0; DTOInventario inven = new DTOInventario(); CADInventario inventario = new CADInventario(); try { val = Convert.ToInt32(valorUnitario.Text); consu = Convert.ToInt32(consumible.SelectedValue); cantid_p = Convert.ToInt32(cantidad.Text); } catch { ScriptManager.RegisterClientScriptBlock(this, GetType(), "nopermitecamp", "campos();", true); } if (referencia.Text != "" && nombre.Text != "" && descripcion.Text != "" && novedad.Text != "" && placa.Text != "" && serial.Text != "" && marca.Text != "" && modelo.Text != "") { confirma += 1; } if (val != 0 && consu >= 0 && consu < 2) { confirma += 1; } if (confirma == 2) { inven.Referencia_Producto = referencia.Text; inven.Nombre_Producto = nombre.Text; inven.Descripcion_Producto = descripcion.Text; inven.Novedad_Producto = novedad.Text; inven.Placa_Producto = placa.Text; inven.Serial_Producto = serial.Text; inven.Marca_Producto = marca.Text; inven.Modelo_Producto = modelo.Text; inven.ValorUnitario_Producto = val; inven.Consumible = consu; inven.Cantidad_Producto = cantid_p; if (inventario.ConsultarProductoPorPlaca(inven) == 0) { if (inventario.ConsultarProductoPorSerial(inven) == 0) { if (inventario.InsertarProducto(inven) == 0) { //Genernado Codigo QR QrEncoder qrencoder = new QrEncoder(); QrCode qrcode = new QrCode(); //Recolectando referencia producto qrencoder.TryEncode(placa.Text, out qrcode); //Generar dicho datos con cierta estructura y estipular colores GraphicsRenderer renderer = new GraphicsRenderer(new FixedCodeSize(400, QuietZoneModules.Zero), Brushes.Black, Brushes.White); //Memoria de datos MemoryStream ms = new MemoryStream(); renderer.WriteToStream(qrcode.Matrix, ImageFormat.Png, ms); var image = new Bitmap(ms); var imagenfinal = new Bitmap(image, new Size(new Point(200, 200))); //Guardar codigoQR en carpeta servidor imagenfinal.Save(Server.MapPath("~/QR/") + placa.Text + ".png", ImageFormat.Png); DTOUsuario u = new DTOUsuario(); CADUsuario process = new CADUsuario(); u.Id_u_logueado = int.Parse(Convert.ToString(Session["id_usuario"])); u.Descripcion_history = "Registro producto placa: " + placa.Text; process.InsertarHistorial(u); btn_Registrar.CssClass = "btn btn-default"; btn_Registrar.Enabled = true; btn_Actualizar.CssClass = "btn btn-default"; btn_Actualizar.Enabled = false; btn_Cancelar.CssClass = "btn btn-default"; btn_Cancelar.Enabled = false; codigo.Text = ""; referencia.Text = ""; nombre.Text = ""; descripcion.Text = ""; novedad.Text = ""; placa.Text = ""; serial.Text = ""; marca.Text = ""; modelo.Text = ""; cantidad.Text = ""; valorUnitario.Text = ""; inventario.CargarProductos(GVProductos); ScriptManager.RegisterClientScriptBlock(this, GetType(), "mensaje", "registro();", true); } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "inconsis", "problema();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "yaexisserial", "yaexisteserial();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "yaexisplaca", "yaexisteplaca();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "nopermitecamp", "campos();", true); } inventario.CargarProductos(GVProductos); }
protected void btn_Actualizar_Click(object sender, EventArgs e) { int val = 0, consu = 2, confirma = 0, modifi = 0; DTOInventario inven = new DTOInventario(); CADInventario inventario = new CADInventario(); inven.Id_Producto = Convert.ToInt32(codigo.Text); string placa_p = inventario.ObtenerPlacaProducto(inven); string serial_p = inventario.ObtenerSerialProducto(inven); if (placa_p != placa.Text && serial_p != serial.Text) { modifi = 1; } if (placa_p != placa.Text && serial_p == serial.Text) { modifi = 2; } if (placa_p == placa.Text && serial_p != serial.Text) { modifi = 3; } if (placa_p == placa.Text && serial_p == serial.Text) { modifi = 4; } try { val = int.Parse(valorUnitario.Text); consu = int.Parse(consumible.SelectedValue); confirma = 2; } catch { ScriptManager.RegisterClientScriptBlock(this, GetType(), "nopermitecamp", "campos();", true); } if (nombre.Text != "" && descripcion.Text != "" && novedad.Text != "" && placa.Text != "" && serial.Text != "" && marca.Text != "" && modelo.Text != "") { confirma += 7; } if (confirma == 9) { inven.Referencia_Producto = referencia.Text; inven.Nombre_Producto = nombre.Text; inven.Descripcion_Producto = descripcion.Text; inven.Novedad_Producto = novedad.Text; inven.Placa_Producto = placa.Text; inven.Serial_Producto = serial.Text; inven.Marca_Producto = marca.Text; inven.Modelo_Producto = modelo.Text; inven.ValorUnitario_Producto = val; inven.Consumible = consu; inven.Cantidad_Producto = int.Parse(cantidad.Text); if (modifi == 1) { if (inventario.ConsultarProductoPorPlaca(inven) == 0) { if (inventario.ConsultarProductoPorSerial(inven) == 0) { if (inventario.ModificarProducto(inven) == 0) { var filePath = Server.MapPath("~/QR/" + placa_p + ".png"); if (File.Exists(filePath)) { File.Delete(filePath); } //Genernado Codigo QR QrEncoder qrencoder = new QrEncoder(); QrCode qrcode = new QrCode(); //Recolectando referencia producto qrencoder.TryEncode(placa.Text, out qrcode); //Generar dicho datos con cierta estructura y estipular colores GraphicsRenderer renderer = new GraphicsRenderer(new FixedCodeSize(400, QuietZoneModules.Zero), Brushes.Black, Brushes.White); //Memoria de datos MemoryStream ms = new MemoryStream(); renderer.WriteToStream(qrcode.Matrix, ImageFormat.Png, ms); var image = new Bitmap(ms); var imagenfinal = new Bitmap(image, new Size(new Point(200, 200))); //Guardar codigoQR en carpeta servidor imagenfinal.Save(Server.MapPath("~/QR/") + placa.Text + ".png", ImageFormat.Png); DTOUsuario u = new DTOUsuario(); CADUsuario process = new CADUsuario(); u.Id_u_logueado = int.Parse(Convert.ToString(Session["id_usuario"])); u.Descripcion_history = "Actualización producto placa: " + placa.Text; process.InsertarHistorial(u); codigo.Text = ""; referencia.Text = ""; nombre.Text = ""; descripcion.Text = ""; novedad.Text = ""; placa.Text = ""; serial.Text = ""; marca.Text = ""; modelo.Text = ""; cantidad.Text = ""; valorUnitario.Text = ""; // consumible.Text = ""; btn_Registrar.CssClass = "btn btn-default"; btn_Registrar.Enabled = true; btn_Actualizar.CssClass = "btn btn-default"; btn_Actualizar.Enabled = false; btn_Cancelar.CssClass = "btn btn-default"; btn_Cancelar.Enabled = false; cantidad.ReadOnly = false; // program.ObtenerUltimoIDProgramaEIncrementarlo(codigo_programa); inventario.CargarProductos(GVProductos); ScriptManager.RegisterClientScriptBlock(this, GetType(), "mensaje", "modificacion();", true); } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "inconsis", "problema();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "yaexisserial", "yaexisteserial();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "yaexisplaca", "yaexisteplaca();", true); } } if (modifi == 2) { if (inventario.ConsultarProductoPorPlaca(inven) == 0) { if (inventario.ModificarProducto(inven) == 0) { var filePath = Server.MapPath("~/QR/" + placa_p + ".png"); if (File.Exists(filePath)) { File.Delete(filePath); } //Genernado Codigo QR QrEncoder qrencoder = new QrEncoder(); QrCode qrcode = new QrCode(); //Recolectando referencia producto qrencoder.TryEncode(placa.Text, out qrcode); //Generar dicho datos con cierta estructura y estipular colores GraphicsRenderer renderer = new GraphicsRenderer(new FixedCodeSize(400, QuietZoneModules.Zero), Brushes.Black, Brushes.White); //Memoria de datos MemoryStream ms = new MemoryStream(); renderer.WriteToStream(qrcode.Matrix, ImageFormat.Png, ms); var image = new Bitmap(ms); var imagenfinal = new Bitmap(image, new Size(new Point(200, 200))); //Guardar codigoQR en carpeta servidor imagenfinal.Save(Server.MapPath("~/QR/") + placa.Text + ".png", ImageFormat.Png); DTOUsuario u = new DTOUsuario(); CADUsuario process = new CADUsuario(); u.Id_u_logueado = int.Parse(Convert.ToString(Session["id_usuario"])); u.Descripcion_history = "Actualización producto placa: " + placa.Text; process.InsertarHistorial(u); codigo.Text = ""; referencia.Text = ""; nombre.Text = ""; descripcion.Text = ""; novedad.Text = ""; placa.Text = ""; serial.Text = ""; marca.Text = ""; modelo.Text = ""; cantidad.Text = ""; valorUnitario.Text = ""; // consumible.Text = ""; btn_Registrar.CssClass = "btn btn-default"; btn_Registrar.Enabled = true; btn_Actualizar.CssClass = "btn btn-default"; btn_Actualizar.Enabled = false; btn_Cancelar.CssClass = "btn btn-default"; btn_Cancelar.Enabled = false; cantidad.ReadOnly = false; // program.ObtenerUltimoIDProgramaEIncrementarlo(codigo_programa); inventario.CargarProductos(GVProductos); ScriptManager.RegisterClientScriptBlock(this, GetType(), "mensaje", "modificacion();", true); } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "inconsis", "problema();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "yaexisplaca", "yaexisteplaca();", true); } } if (modifi == 3) { if (inventario.ConsultarProductoPorSerial(inven) == 0) { if (inventario.ModificarProducto(inven) == 0) { DTOUsuario u = new DTOUsuario(); CADUsuario process = new CADUsuario(); u.Id_u_logueado = int.Parse(Convert.ToString(Session["id_usuario"])); u.Descripcion_history = "Actualización producto placa: " + placa.Text; process.InsertarHistorial(u); codigo.Text = ""; referencia.Text = ""; nombre.Text = ""; descripcion.Text = ""; novedad.Text = ""; placa.Text = ""; serial.Text = ""; marca.Text = ""; modelo.Text = ""; cantidad.Text = ""; valorUnitario.Text = ""; // consumible.Text = ""; btn_Registrar.CssClass = "btn btn-default"; btn_Registrar.Enabled = true; btn_Actualizar.CssClass = "btn btn-default"; btn_Actualizar.Enabled = false; btn_Cancelar.CssClass = "btn btn-default"; btn_Cancelar.Enabled = false; cantidad.ReadOnly = false; // program.ObtenerUltimoIDProgramaEIncrementarlo(codigo_programa); inventario.CargarProductos(GVProductos); ScriptManager.RegisterClientScriptBlock(this, GetType(), "mensaje", "modificacion();", true); } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "inconsis", "problema();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "yaexisserial", "yaexisteserial();", true); } } if (modifi == 4) { if (inventario.ModificarProducto(inven) == 0) { DTOUsuario u = new DTOUsuario(); CADUsuario process = new CADUsuario(); u.Id_u_logueado = int.Parse(Convert.ToString(Session["id_usuario"])); u.Descripcion_history = "Actualización producto placa: " + placa.Text; process.InsertarHistorial(u); codigo.Text = ""; referencia.Text = ""; nombre.Text = ""; descripcion.Text = ""; novedad.Text = ""; placa.Text = ""; serial.Text = ""; marca.Text = ""; modelo.Text = ""; cantidad.Text = ""; valorUnitario.Text = ""; // consumible.Text = ""; btn_Registrar.CssClass = "btn btn-default"; btn_Registrar.Enabled = true; btn_Actualizar.CssClass = "btn btn-default"; btn_Actualizar.Enabled = false; btn_Cancelar.CssClass = "btn btn-default"; btn_Cancelar.Enabled = false; cantidad.ReadOnly = false; // program.ObtenerUltimoIDProgramaEIncrementarlo(codigo_programa); inventario.CargarProductos(GVProductos); ScriptManager.RegisterClientScriptBlock(this, GetType(), "mensaje", "modificacion();", true); } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "inconsis", "problema();", true); } } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "nopermitecamp", "campos();", true); } GVProductos.EditIndex = -1; inventario.CargarProductos(GVProductos); }
protected void btn_Actualizar_Click(object sender, EventArgs e) { int titu = 0, modifi = 0, confirm = 0; float val = 0, m = 0; var culture = (CultureInfo)CultureInfo.CurrentCulture.Clone(); culture.NumberFormat.NumberDecimalSeparator = "."; DTOInventario inven = new DTOInventario(); CADInventario inventario = new CADInventario(); inven.Id_Hilo = Convert.ToInt32(codigo.Text); /* string referencia_h = inventario.ObtenerRefHilo(inven); * if (referencia_h == referencia.Text) * { * modifi = 1; * }*/ try { titu = int.Parse(titulo.Text); val = float.Parse(valor.Text); m = float.Parse(tmetros.Text, culture); confirm = 2; } catch { ScriptManager.RegisterClientScriptBlock(this, GetType(), "nopermitecamp", "campos();", true); } if (tipoh.SelectedItem.Text != "Seleccione un tipo" && color.Text != "") { confirm += 2; } if (confirm == 4) { inven.Referencia_Hilo = referencia.Text; inven.Tipo_Hilo = tipoh.SelectedItem.Text; inven.Titulo_Hilo = titu; inven.Color_Hilo = color.Text; inven.ValorMetro = val; inven.Metros_Hilo = m; /* if (modifi == 1) * {*/ if (inventario.ModificarHilo(inven) == 0) { DTOUsuario u = new DTOUsuario(); CADUsuario process = new CADUsuario(); u.Id_u_logueado = int.Parse(Convert.ToString(Session["id_usuario"])); u.Descripcion_history = "Actualización hilo referencia: " + referencia.Text; process.InsertarHistorial(u); codigo.Text = ""; referencia.Text = ""; tipoh.SelectedValue = "0"; titulo.Text = ""; color.Text = ""; valor.Text = ""; tmetros.Text = ""; btn_Registrar.CssClass = "btn btn-default"; btn_Registrar.Enabled = true; btn_Actualizar.CssClass = "btn btn-default"; btn_Actualizar.Enabled = false; btn_Cancelar.CssClass = "btn btn-default"; btn_Cancelar.Enabled = false; tmetros.ReadOnly = false; inventario.CargarHilos(GVHilos); ScriptManager.RegisterClientScriptBlock(this, GetType(), "mensaje", "modificacion();", true); } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "inconsis", "problema();", true); } /*}*/ } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "nopermitecamp", "campos();", true); } GVHilos.EditIndex = -1; inventario.CargarHilos(GVHilos); }
protected void btn_Registrar_Click(object sender, EventArgs e) { int titu = 0, val = 0, confirma = 0; string id_code = ""; float m = 0; var culture = (CultureInfo)CultureInfo.CurrentCulture.Clone(); culture.NumberFormat.NumberDecimalSeparator = "."; DTOInventario inven = new DTOInventario(); CADInventario inventario = new CADInventario(); try { titu = Convert.ToInt32(titulo.Text); val = Convert.ToInt32(valor.Text); m = float.Parse(tmetros.Text, culture); Guid guid = Guid.NewGuid(); byte[] guidbytes = guid.ToByteArray(); id_code = Convert.ToBase64String(guidbytes).Trim('='); } catch { ScriptManager.RegisterClientScriptBlock(this, GetType(), "nopermitecamp", "campos();", true); } if (referencia.Text != "" && tipoh.SelectedItem.Text != "Seleccione un tipo" && color.Text != "") { confirma += 1; } if (titu != 0 && val != 0) { confirma += 1; } if (confirma == 2) { inven.Referencia_Hilo = referencia.Text; inven.Code_Hilo = id_code; inven.Tipo_Hilo = tipoh.SelectedItem.Text; inven.Titulo_Hilo = titu; inven.Color_Hilo = color.Text; inven.ValorMetro = val; inven.Metros_Hilo = m; if (inventario.InsertarHilo(inven) == 0) { QrEncoder qrencoder = new QrEncoder(); QrCode qrcode = new QrCode(); //Recolectando referencia producto qrencoder.TryEncode(id_code, out qrcode); //Generar dicho datos con cierta estructura y estipular colores GraphicsRenderer renderer = new GraphicsRenderer(new FixedCodeSize(400, QuietZoneModules.Zero), Brushes.Black, Brushes.White); //Memoria de datos MemoryStream ms = new MemoryStream(); renderer.WriteToStream(qrcode.Matrix, ImageFormat.Png, ms); var image = new Bitmap(ms); var imagenfinal = new Bitmap(image, new Size(new Point(200, 200))); //Guardar codigoQR en carpeta servidor imagenfinal.Save(Server.MapPath("~/QR/") + id_code + ".png", ImageFormat.Png); DTOUsuario u = new DTOUsuario(); CADUsuario process = new CADUsuario(); u.Id_u_logueado = int.Parse(Convert.ToString(Session["id_usuario"])); u.Descripcion_history = "Registro hilo referencia: " + referencia.Text; process.InsertarHistorial(u); btn_Registrar.CssClass = "btn btn-default"; btn_Registrar.Enabled = true; btn_Actualizar.CssClass = "btn btn-default"; btn_Actualizar.Enabled = false; btn_Cancelar.CssClass = "btn btn-default"; btn_Cancelar.Enabled = false; codigo.Text = ""; referencia.Text = ""; tipoh.SelectedValue = "0"; titulo.Text = ""; color.Text = ""; valor.Text = ""; tmetros.Text = ""; inventario.CargarHilos(GVHilos); ScriptManager.RegisterClientScriptBlock(this, GetType(), "mensaje", "registro();", true); } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "inconsis", "problema();", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "nopermitecamp", "campos();", true); } inventario.CargarHilos(GVHilos); }