protected void TableReques_RowEditing(object sender, GridViewEditEventArgs e) { var fila = e.NewEditIndex; var idRow = TableReques.Rows[fila].Cells[0].Text; ConectionDB conection = new ConectionDB(); string commandUpdate = "UPDATE [dbo].[Requisicion] SET[estado] = 3,[fechaPedido] = '" + DateTime.Now.ToString("yyyy-MM-dd") + "' WHERE idRequisicion = " + idRow; int result = conection.insertCommand(commandUpdate); if (result != 0) { //Registramos los datos en Facturas commandUpdate = "INSERT INTO [dbo].[Factura] ([requisicion],[provedor],[Estatus]) VALUES(" + idRow + ",(" + "Select top 1 idProvedor from dbo.provedor where [categoria] = (Select idCategoria from dbo.Categoria where idCategoria = " + TableReques.Rows[fila].Cells[4].Text + "),4)"; result = conection.insertCommand(commandUpdate); if (result != 0) { Response.Write("<script>alert('La requicision fue aprovada, se enviara el pedido al Proveedor.');</script>"); Response.Redirect("~/NuevaRequisicion"); } } else { Response.Write("<script>alert('No pudimos borrar esta Requision, se encuetra ligada a unas Facturas');</script>"); } conection.CloseDB(); }
protected void guardar_user_Click(object sender, EventArgs e) { var nombre = nombre_txt.Text; var apellido = apellido_txt.Text; var correo = correo_txt.Text; var celular = celular_txt.Text; ConectionDB conection = new ConectionDB(); String sccript = String.Format("INSERT INTO [dbo].[Usuario] ([rol],[nombre],[apellido],[correo],[celular],[credencial])VALUES(2,'{0}','{1}','{2}','{3}','helloworld')", nombre, apellido, correo, celular); try { var result = conection.insertCommand(sccript); if (result != 0) { //mostrar notificacion Response.Write("<script>alert('Encargado registrado Exitosamente.');</script>"); Response.Redirect("~/Encargados"); } } catch (Exception ex) { Response.Write(ex.Message); } conection.CloseDB(); nombre_txt.Text = ""; apellido_txt.Text = ""; correo_txt.Text = ""; celular_txt.Text = ""; }
protected void pagarFactura_Click(object sender, EventArgs e) { var factura = DD_Pagar.SelectedValue; var tipoPago = DD_Pago.SelectedValue; var prove = DD_Provedor.SelectedValue; ConectionDB conection = new ConectionDB(); String SqlCommand = String.Format("UPDATE [dbo].[Factura] SET [pago] = {0},[fechaPago] = '{1}',[Estatus] = 5 WHERE idFactura = {2}", tipoPago, DateTime.Now.ToString("yyyy-MM-dd"), factura); try { var result = conection.insertCommand(SqlCommand); if (result != 0) { //notificacion DD_Pagar.Dispose(); DD_Pago.Dispose(); Response.Write("<script>alert('Pago registrado Exitosamente.');</script>"); Response.Redirect("~/PagarFactura"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } conection.CloseDB(); DD_Pagar.SelectedValue = ""; DD_Pago.SelectedValue = ""; }
protected void Btn_GuardarCategoria_Click(object sender, EventArgs e) { string categoria = Text_categoria.Text; if (categoria.Length > 0) { ConectionDB conection = new ConectionDB(); String InsertCommand = "INSERT INTO [dbo].[Categoria] ([descripcion]) VALUES ('" + categoria + "')"; var result = conection.insertCommand(InsertCommand); if (result != 0) { // Mostrar mensaje de registro guardado Response.Write("<script>alert('Categoria registrada Exitosamente.');</script>"); Response.Redirect("~/Categoria"); } Text_categoria.Text = ""; conection.CloseDB(); } else { //Mostrando un mensaje diciendo que el campo vacio Response.Write("<script>alert('La descripcion de la categoria no puede ir vacio.');</script>"); Response.Write("<script>toastr.error('Please Enter Name', 'Error');</script>"); } }
protected void Button1_Click(object sender, EventArgs e) { string razon = Razon.Text; string categoria = DD_categoria.SelectedValue; string direccion = direc.Text; string bancaria = Cuenta.Text; string telefono = Tele.Text; string correo = cocrreo.Text; ConectionDB conection = new ConectionDB(); String sccript = "INSERT INTO [dbo].[Provedor] ([razonSocial],[categoria],[direccion],[tel],[correo],[cuentaBancaria]) VALUES ('" + razon + "'," + categoria + ",'" + direccion + "','" + telefono + "','" + correo + "','" + bancaria + "')"; try { var result = conection.insertCommand(sccript); if (result != 0) { //notificacion Response.Write("<script>alert('Proveedor registrado Exitosamente.');</script>"); Response.Redirect("~/Proveedores"); } }catch (Exception ex) { Console.WriteLine(ex.Message); } Razon.Text = ""; categ.Text = ""; direc.Text = ""; Cuenta.Text = ""; Tele.Text = ""; cocrreo.Text = ""; conection.CloseDB(); }
protected void guardar_propietario_Click(object sender, EventArgs e) { var nombre = nombre_txt.Text; var apellido = apellido_text.Text; var telefono = telefono_text.Text; ConectionDB conection = new ConectionDB(); string sqlCommand = String.Format("INSERT INTO [dbo].[Propietario] ([nombre],[apellido],[celular]) VALUES({0},{1},{2})", nombre, apellido, telefono); try { var result = conection.insertCommand(sqlCommand); if (result != 0) { Response.Write("<script>alert('Propietario registrado Exitosamente.');</script>"); Response.Redirect("~/Propietario"); } } catch (Exception ex) { Response.Write(ex.Message); } nombre_txt.Text = ""; apellido_text.Text = ""; telefono_text.Text = ""; conection.CloseDB(); }
protected void Btn_guardar_Click(object sender, EventArgs e) { var requisicion = DropDownRequisiciones.SelectedValue; var monto = Txt_Monto.Text; string sqlCommand = "update [dbo].[Factura] set total = " + monto + " , fechaMaxPago = '" + DateTime.Now.AddDays(30).ToString("yyyy-MM-dd") + "' where requisicion = " + requisicion + ""; ConectionDB connection = new ConectionDB(); int result = connection.insertCommand(sqlCommand); sqlCommand = "update [dbo].[Requisicion] set estado = 3, fechaEntrega = '" + DateTime.Now.ToString("yyyy-MM-dd") + "';"; result = connection.insertCommand(sqlCommand); if (result != 0) { //notificacion DD_Pagar.Dispose(); DD_Pago.Dispose(); Response.Write("<script>alert('Requisicion actualizada correctamente.');</script>"); Response.Redirect("~/NuevaRequisicion"); } }
protected void proyec_RowDeleting(object sender, GridViewDeleteEventArgs e) { var fila = e.RowIndex; var idRow = proyec.Rows[fila].Cells[0].Text; ConectionDB conection = new ConectionDB(); string commandDelete = "Delete [dbo].[Obra] where idObra = " + fila; int result = conection.insertCommand(commandDelete); if (result != 0) { Response.Redirect("~/Obras"); } else { Response.Write("<script>alert('No pudimos borrar esta obra, se encuetra ligada a unas Facturas');</script>"); } conection.CloseDB(); }
protected void TableReques_RowDeleting(object sender, GridViewDeleteEventArgs e) { var fila = e.RowIndex; var idRow = TableReques.Rows[fila].Cells[0].Text; ConectionDB conection = new ConectionDB(); string commandDelete = "DELETE FROM [dbo].[Requisicion] WHERE [idRequisicion] = " + fila; int result = conection.insertCommand(commandDelete); if (result != 0) { Response.Redirect("~/NuevaRequisicion"); } else { Response.Write("<script>alert('No pudimos borrar esta Requision, se encuetra ligada a unas Facturas');</script>"); } conection.CloseDB(); }