Files
SIG/OC/RepOCAnticiposPtes.aspx.cs
2023-10-09 11:55:07 -07:00

104 lines
3.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Extensiones;
using System.Data;
public partial class OC_RepOCAnticiposPtes : ClsPaginas
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CargaDatosIniciales();
}
}
private void CargaDatosIniciales()
{
DdlProveedores.DataSource = get_GlobalDTCompProveedores(UsuarioActual.CveEmpresa);
DdlProveedores.DataBind();
txtFechaI.Text = NowADS().FirstDayOfMonth().AddMonths(-1).ToShortDateString();
txtFechaF.Text = NowADS().ToShortDateString();
}
protected void BtnConsultar_Click(object sender, EventArgs e)
{
CargaGrid();
}
private void CargaGrid()
{
DateTime FechaI = txtFechaI.Text.ToDate();
DateTime FechaF = txtFechaF.Text.ToDate();
ClsOC clsOC = new ClsOC();
// Cargamos
if (clsOC.GetOCAnticiposPendientes(UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, DdlProveedores.SelectedValue.ToEntero(), FechaI, FechaF))
{
GvDatos.DataSource = clsOC.DtResultados;
GvDatos.DataBind();
}
clsOC.Dispose();
UpDatos.Update();
}
protected void GvDatos_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "DeleteAnticipo")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow selectedRow = GvDatos.Rows[index];
int CveOrdenCompra = Convert.ToInt32(selectedRow.DataKey("CveOrdenCompra"));
ClsOIEventos clsOI = new ClsOIEventos();
int CveOIEvento = 0;
int CveEventoPrincipal = 0;
Boolean tieneError = false;
if(CveOrdenCompra > 0)
{
if(clsOI.GetEventos(-1, 6, -1, "-1", "-1", -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, CveOrdenCompra, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa))
{
CveOIEvento = clsOI.CveEvento;
}
if (clsOI.GetEventos(-1, 1, -1, "-1", "-1", -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, CveOrdenCompra, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa))
{
CveEventoPrincipal = clsOI.CveEvento;
}
if (! clsOI.UpdateEstatusEvento(5,-1,CveOIEvento, UsuarioActual.CveEmpresa))
{
clsOI.Dispose();
tieneError = true;
}
if (!clsOI.UpdateEstatusEvento(5, -1, CveEventoPrincipal, UsuarioActual.CveEmpresa))
{
clsOI.Dispose();
tieneError = true;
}
if (tieneError)
{
Alert("Ocurrió un error al actualizar el estatus de anticipo de la OC/REQ.", ModExtensiones.TipoMensaje.MsgError);
}
else
{
Alert("Se canceló con exito", ModExtensiones.TipoMensaje.MsgInformacion);
CargaGrid();
}
}
}
}
}