protected void Button1_Click(object sender, EventArgs e) { string descripcion = nombre.Text; int codcategoria = int.Parse(categoria.SelectedValue); int precioo = int.Parse(precio.Text); int cantidadd = int.Parse(cantidad.Text); string imagen = ""; if (FileUpload1.HasFile) { //si hay una archivo. string nombreArchivo = FileUpload1.FileName; string ruta = "~/img/productos/" + nombreArchivo; FileUpload1.SaveAs(Server.MapPath(ruta)); imagen = nombreArchivo; } if (PrepararConsulta.AgregarProducto(descripcion, codcategoria, precioo, cantidadd, imagen, cadenaconexion)) { Response.Write("<script>alert('Producto " + descripcion + " agregado correctamente');</script>"); } else { Response.Write("<script>alert('Producto no se agrego correctamente');</script>"); } }
protected void updatepedido(object sender, SqlDataSourceStatusEventArgs e) { indexpedido = GridView1.EditIndex; Label estado = (Label)GridView1.Rows[indexpedido].FindControl("Labelestado2"); DropDownList estadodrop2 = (DropDownList)GridView1.Rows[indexpedido].FindControl("DropDownList2"); //estadodrop2.SelectedValue = estado.Text; codigoPedido = GridView1.DataKeys[indexpedido].Value.ToString();//row.Cells[1].Text.ToString(); if (estadodrop2.SelectedValue == "0") { string script = "alert('Seleccione estado valido.');"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); } else { if (PrepararConsulta.CambiarEstadoPedido(int.Parse(codigoPedido), int.Parse(estadodrop2.SelectedValue), cadenaconexion)) { //Response.Write("<script>alert('Producto dadon de baja correctamente');</script>"); string script = "alert('Se cambio de estado correctamente.');"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); GridView1.DataBind(); } else { //Response.Write("<script>alert('error al dar de baja');</script>"); string script = "alert('error al cambiar estado.');"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); GridView1.DataBind(); } } //GridView1.DataBind(); }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { int categoria = int.Parse(DropDownList1.SelectedValue); DataList1.DataSource = PrepararConsulta.CambiarCategoria(categoria, "", cadenaconexion); DataList1.DataBind(); DataList1.SelectedIndex = -1; }
protected void Button3_Click(object sender, EventArgs e) { TextBox1.Text = ""; DropDownList1.SelectedIndex = 0; DataList1.DataSource = PrepararConsulta.CambiarCategoria(0, "", cadenaconexion); DataList1.DataBind(); DataList1.SelectedIndex = -1; alertproducto.Visible = false; }
protected void Button2_Click(object sender, EventArgs e) { String nombrep = TextBox1.Text; int categoria = int.Parse(DropDownList1.SelectedValue); DataList1.DataSource = PrepararConsulta.CambiarCategoria(categoria, nombrep, cadenaconexion); DataList1.DataBind(); DataList1.SelectedIndex = -1; }
protected void Page_Load(object sender, EventArgs e) { string userName = HttpContext.Current.User.Identity.Name; if (Page.IsPostBack == false) { CargarDetalle(); lblAgregado.Text = ""; DataList1.DataSource = PrepararConsulta.CambiarCategoria(0, "", cadenaconexion); DataList1.DataBind(); } }
protected void Button1_Click(object sender, EventArgs e) { if (PrepararConsulta.validaruserpassadmin(nomusuario.Text.ToString(), password.Text.ToString(), cadenaconexion)) { Session["useradmin"] = nomusuario.Text.ToString(); Response.Write("<script>alert('Bienvenido " + Session["useradmin"] + "');window.location.href = '../adm/inicio.aspx';</script>"); /// Response.Redirect("~/adm/inicio.aspx"); } else { alertNoCoincide.Visible = true; } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int id = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString()); if (PrepararConsulta.CambiarEstadoProducto(id, 1, cadenaconexion)) { Response.Write("<script>alert('Producto dadon de baja correctamente');</script>"); } else { Response.Write("<script>alert('error al dar de baja');</script>"); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int id = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString()); if (PrepararConsulta.CambiarEstadoProducto(id, 1, cadenaconexion)) { //Response.Write("<script>alert('Producto dadon de baja correctamente');</script>"); string script = "alert('Producto dadon de baja correctamente');"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); GridView1.DataBind(); } else { //Response.Write("<script>alert('error al dar de baja');</script>"); string script = "alert('error al dar de baja');"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); GridView1.DataBind(); } }
protected void Button3_Click(object sender, EventArgs e) { if (GridView1.Rows.Count == 0) { alertpedido.CssClass = "alert alert-info"; lblAgregado.Text = "No hay productos agregados al pedido"; alertpedido.Visible = true; //this.Response.Write("<script language='JavaScript'>window.alert('No hay productos agregados al pedido')</script>"); } else { if (nombre.Text == "") { alertpedido.CssClass = "alert alert-danger"; lblAgregado.Text = "Inicie sesión para continuar."; alertpedido.Visible = true; //this.Response.Write("<script language='JavaScript'>window.alert('Inicie sesión para continuar')</script>"); } else { if (DropDownList1.SelectedValue == "0") { alertpedido.CssClass = "alert alert-warning"; lblAgregado.Text = "Selecione una forma de entrega."; alertpedido.Visible = true; //this.Response.Write("<script language='JavaScript'>window.alert('Selecione una forma de entrega')</script>"); } else { //VentasCN oMatriculaCN = new VentasCN(); //ComponenteEntidad.Ventas oMatriculaCE = new ComponenteEntidad.Ventas(); //oMatriculaCE.Codigo = txtCodigo.Text; //oMatriculaCE.Fecha = lblFecha.Text; //oMatriculaCE.Subtotal = decimal.Parse(lblSubTotal.Text); //oMatriculaCE.Igv = decimal.Parse(lblIGV.Text); //oMatriculaCE.Total = decimal.Parse(lblTotal.Text); //oMatriculaCN.Insertar(oMatriculaCE); try { DataTable users = PrepararConsulta.RecuperarInfoUser(User.Identity.Name, cadenaconexion); //users.Rows[0][0].ToString(); String idpedido = users.Rows[0][0].ToString(); DataTable pedido = PrepararConsulta.AgregarNuevoPedido(DateTime.Now, decimal.Parse(lblSubTotal.Text), decimal.Parse(lblIGV.Text), decimal.Parse(lblTotal.Text), idpedido, int.Parse(DropDownList1.SelectedValue), cadenaconexion); pedido.Rows[0][0].ToString(); foreach (GridViewRow row in GridView1.Rows) { //ComponenteNegocio.DetalleVentaCN oMatriculaCNN = new ComponenteNegocio.DetalleVentaCN(); //ComponenteEntidad.DetalleVenta oMatriculaCEE = new ComponenteEntidad.DetalleVenta(); //oMatriculaCEE.Codigo = txtCodigo.Text; //oMatriculaCEE.Cantidad = int.Parse(((TextBox)row.Cells[4].FindControl("TextBox1")).Text); //oMatriculaCEE.Precio = decimal.Parse(Convert.ToString(row.Cells[3].Text)); //oMatriculaCEE.Subtotal = decimal.Parse(Convert.ToString(row.Cells[5].Text)); //oMatriculaCEE.Codproducto = Convert.ToString(row.Cells[1].Text); //oMatriculaCNN.Insertar(oMatriculaCEE); PrepararConsulta.AgregarDetallePedido(Convert.ToInt32(pedido.Rows[0][0].ToString()), Convert.ToInt16(row.Cells[1].Text), int.Parse(((TextBox)row.Cells[4].FindControl("TextBox1")).Text), decimal.Parse(Convert.ToString(row.Cells[3].Text)), decimal.Parse(Convert.ToString(row.Cells[5].Text)), cadenaconexion); } SendEmail(sender, e); this.Response.Write("<script language='JavaScript'>window.alert('PROCESO TERMINADO CORRECTAMENTE')</script>"); //Response.Redirect("pedidos.aspx"); } catch (Exception) { this.Response.Write("<script language='JavaScript'>window.alert('Error al preocesar pedido')</script>"); throw; } } } } }