-RegistraScript se unifica en una sola clase static/shared y se simplica el código -Alert se vuelve estático -Random() no se manda a crear cada vez que se registra un script (esto tenía un costo alto) -Se corrigieron unos errores en los nombres de funciones -Las clases que ya heredan de Clspaginas, se les quita el this a RegistraScript y a Alert puesto que era innecesario (y además al haberlos vuelto métodos estáticos, NO pueden llamarse de un this)
1014 lines
42 KiB
C#
1014 lines
42 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI.WebControls;
|
|
using Extensiones;
|
|
using System.Data;
|
|
using static Extensiones.ModExtensiones;
|
|
using System.Web.UI;
|
|
using System.IO;
|
|
|
|
public partial class CGame_Fletes : ClsPaginas
|
|
{
|
|
|
|
|
|
#region Propiedades
|
|
|
|
private int CveFlete
|
|
{
|
|
get { return (ViewState["CveFlete"] == null) ? 0 : Convert.ToInt32(ViewState["CveFlete"]); }
|
|
set { ViewState["CveFlete"] = value; }
|
|
}
|
|
private int CveOrdenCorteOpcion
|
|
{
|
|
get { return (ViewState["CveOrdenCorteOpcion"] == null) ? 0 : Convert.ToInt32(ViewState["CveOrdenCorteOpcion"]); }
|
|
set { ViewState["CveOrdenCorteOpcion"] = value; }
|
|
}
|
|
private int CveOrdenProduccionOpcion
|
|
{
|
|
get { return (ViewState["CveOrdenProduccionOpcion"] == null) ? 0 : Convert.ToInt32(ViewState["CveOrdenProduccionOpcion"]); }
|
|
set { ViewState["CveOrdenProduccionOpcion"] = value; }
|
|
}
|
|
private String Modalidad
|
|
{
|
|
get { return (ViewState["Modalidad"] == null) ? "-1" : ViewState["Modalidad"].ToString(); }
|
|
set { ViewState["Modalidad"] = value; }
|
|
}
|
|
|
|
private int Index
|
|
{
|
|
get { return (ViewState["Index"] == null) ? 0 : Convert.ToInt32(ViewState["Index"]); }
|
|
set { ViewState["Index"] = value; }
|
|
}
|
|
|
|
private String Adjunto
|
|
{
|
|
get { return (ViewState["Adjunto"] == null) ? "-1" : (String)(ViewState["Adjunto"]); }
|
|
set { ViewState["Adjunto"] = value; }
|
|
}
|
|
|
|
private int CveHuerta
|
|
{
|
|
get { return (ViewState["CveHuerta"] == null) ? 0 : Convert.ToInt32(ViewState["CveHuerta"]); }
|
|
set { ViewState["CveHuerta"] = value; }
|
|
}
|
|
private int Tipo
|
|
{
|
|
get { return (ViewState["Tipo"] == null) ? 0 : Convert.ToInt32(ViewState["Tipo"]); }
|
|
set { ViewState["Tipo"] = value; }
|
|
}
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
InicializaValores();
|
|
CargaProveedor();
|
|
CargaRemolque();
|
|
CargaTracto();
|
|
CargaHuerta();
|
|
CargaChofer();
|
|
CargaScat();
|
|
CargaOrdenCorte();
|
|
CargaOrdenProduccion();
|
|
CargaFleteHuertaEmpaque();
|
|
CargaEmpaque();
|
|
if (CveHuerta > 0 || Tipo>0)
|
|
{
|
|
TxtFiltrosFechaInicio.Text = MinFecha.ToShortDateString();
|
|
TxtFiltrosFechaFin.Text = MaxFecha.ToShortDateString();
|
|
DdlHuertaFiltro.SelectedValueExist(CveHuerta);
|
|
DdlFiltrosTipo.SelectedValueExist(Tipo);
|
|
}
|
|
CargaFletes();
|
|
if (CveOrdenCorteOpcion > 0 || CveOrdenProduccionOpcion > 0) { Agregar(); }
|
|
}
|
|
}
|
|
|
|
protected void InicializaValores()
|
|
{
|
|
TxtFiltrosFechaInicio.Text = DateTime.Now.FirstDayOfMonth().ToShortDateString();
|
|
TxtFiltrosFechaFin.Text = DateTime.Now.ToShortDateString();
|
|
CveOrdenCorteOpcion = Request["CveOrdenCorte"] == null ? 0 : Request["CveOrdenCorte"].ToString().ToEntero();
|
|
CveOrdenProduccionOpcion = Request["CveOrdenProduccion"] == null ? 0 : Request["CveOrdenProduccion"].ToString().ToEntero();
|
|
CveHuerta = Request["CveHuerta"] == null ? 0 : Request["CveHuerta"].ToString().ToEntero();
|
|
Tipo = Request["Tipo"] == null ? 0 : Request["Tipo"].ToString().ToEntero();
|
|
}
|
|
|
|
protected void CargaFletes()
|
|
{
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
if (ObjCGame.GetFlete(UsuarioActual.CveEmpresa, -1, DdlFiltrosTipoFlete.SelectedValue.ToEntero(), DdlFiltrosTipo.SelectedValue.ToEntero(), TxtFiltrosFechaInicio.Text.ToDateTime(), TxtFiltrosFechaFin.Text.ToDateTime(), CveHuerta: DdlHuertaFiltro.SelectedValue.ToEntero(), Opcion: 1))
|
|
{
|
|
GvFlete.DataSource = ObjCGame.DtResultados;
|
|
}
|
|
ObjCGame.Dispose();
|
|
GvFlete.DataBind();
|
|
UpDatos.Update();
|
|
}
|
|
|
|
protected void CargaProveedor()
|
|
{
|
|
ClsCompProveedores ObjProv = new ClsCompProveedores();
|
|
if (ObjProv.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, -1, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
DdlProveedor.DataSource = ObjProv.DtResultados;
|
|
DdlProveedor.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
DdlProveedor.DataBind();
|
|
}
|
|
ObjProv.Dispose();
|
|
UpModalFleteAdd.Update();
|
|
}
|
|
|
|
protected void CargaOrdenCorte(int CveOrdenCorte = -1)
|
|
{
|
|
DdlOrdenCorte.Items.Clear();
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
if (ObjCGame.GetOrdenCorte(UsuarioActual.CveEmpresa))
|
|
{
|
|
if (CveOrdenCorte < 1)
|
|
{
|
|
DdlOrdenCorte.DataSource = ObjCGame.DtResultados.FiltraParametros("Disponible = 1");
|
|
}
|
|
else
|
|
{
|
|
DdlOrdenCorte.DataSource = ObjCGame.DtResultados.FiltraParametros(String.Format("Disponible = 1 OR CveOrdenCorte = {0}", CveOrdenCorte));
|
|
}
|
|
DdlOrdenCorte.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
}
|
|
ObjCGame.Dispose();
|
|
DdlOrdenCorte.DataBind();
|
|
UpModalFleteAdd.Update();
|
|
}
|
|
|
|
|
|
protected void CargaRemolque()
|
|
{
|
|
DdlRemolque.DataSource = get_GlobalDTActivoFijos(UsuarioActual.CveEmpresa);
|
|
DdlRemolque.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
DdlRemolque.DataBind();
|
|
UpModalFleteAdd.Update();
|
|
}
|
|
|
|
protected void CargaTracto()
|
|
{
|
|
DdlTractor.DataSource = get_GlobalDTActivoFijos(UsuarioActual.CveEmpresa);
|
|
DdlTractor.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
DdlTractor.DataBind();
|
|
UpModalFleteAdd.Update();
|
|
}
|
|
protected void CargaScat()
|
|
{
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
if (ObjCGame.GetScat(UsuarioActual.CveEmpresa, Estatus: 1))
|
|
{
|
|
DdlScat.DataSource = ObjCGame.DtResultados;
|
|
DdlScat.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
ObjCGame.Dispose();
|
|
}
|
|
DdlScat.DataBind();
|
|
}
|
|
|
|
protected void CargaFleteHuertaEmpaque(int CveFleteHuertaEmpaque = 1)
|
|
{
|
|
DdlFleteHuertaEmpaque.Items.Clear();
|
|
DdlFleteHuertaEmpaque.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
if (DdlOrdenCorte.SelectedValue.ToEntero() != -1)
|
|
{
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
if (ObjCGame.GetFleteHuertaEmpaque(UsuarioActual.CveEmpresa, CveOrdenCorte: DdlOrdenCorte.SelectedValue.ToEntero()))
|
|
{
|
|
if (CveFleteHuertaEmpaque < 1)
|
|
{
|
|
DdlFleteHuertaEmpaque.DataSource = ObjCGame.DtResultados.FiltraParametros("CveFlete IS NULL");
|
|
}
|
|
else
|
|
{
|
|
DdlFleteHuertaEmpaque.DataSource = ObjCGame.DtResultados.FiltraParametros(String.Format("CveFlete IS NULL OR CveFleteHuertaEmpaque = {0}", CveFleteHuertaEmpaque));
|
|
}
|
|
}
|
|
ObjCGame.Dispose();
|
|
}
|
|
DdlFleteHuertaEmpaque.DataBind();
|
|
}
|
|
|
|
protected void CargaHuerta()
|
|
{
|
|
ClsCGame ObjCort = new ClsCGame();
|
|
if (ObjCort.GetHuerta(UsuarioActual.CveEmpresa))
|
|
{
|
|
DdlHuerta.DataSource = ObjCort.DtResultados;
|
|
DdlHuerta.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
DdlHuertaFiltro.DataSource = ObjCort.DtResultados;
|
|
DdlHuertaFiltro.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
}
|
|
ObjCort.Dispose();
|
|
DdlHuerta.DataBind();
|
|
DdlHuertaFiltro.DataBind();
|
|
UpModalFleteAdd.Update();
|
|
}
|
|
|
|
protected void CargaChofer()
|
|
{
|
|
ClsAcarreos ObjAcar = new ClsAcarreos();
|
|
if (ObjAcar.GetChofer(-1, UsuarioActual.CveEmpresa, 1, -1))
|
|
{
|
|
DdlChofer.DataSource = ObjAcar.DtResultados;
|
|
DdlChofer.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
DdlChofer.DataBind();
|
|
}
|
|
ObjAcar.Dispose();
|
|
UpModalFleteAdd.Update();
|
|
}
|
|
|
|
protected void CargaOrdenProduccion(int CveOrdenProduccion = -1)
|
|
{
|
|
DdlOrdenProduccion.Items.Clear();
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
if (ObjCGame.GetOrdenProduccion(-1, UsuarioActual.CveEmpresa, -1, "-1", MinFecha, MaxFecha, -1))
|
|
{
|
|
if (CveOrdenProduccion < 1)
|
|
{
|
|
DdlOrdenProduccion.DataSource = ObjCGame.DtResultados.FiltraParametros("CveEstatus = 5 AND FechaEmpaqueUSA IS NOT NULL");
|
|
}
|
|
else
|
|
{
|
|
DdlOrdenProduccion.DataSource = ObjCGame.DtResultados.FiltraParametros(String.Format("(CveEstatus = 5 AND FechaEmpaqueUSA IS NOT NULL) OR CveOrdenProduccion = {0}", CveOrdenProduccion));
|
|
}
|
|
DdlOrdenProduccion.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
DdlOrdenProduccion.DataBind();
|
|
}
|
|
ObjCGame.Dispose();
|
|
UpDatos.Update();
|
|
}
|
|
private void CargaEmpaque()
|
|
{
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
if (ObjCGame.GetEmpaques(UsuarioActual.CveEmpresa, -1, 1))
|
|
{
|
|
DdlEmpaque.DataSource = ObjCGame.DtResultados;
|
|
DdlEmpaque.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
}
|
|
ObjCGame.Dispose();
|
|
DdlEmpaque.DataBind();
|
|
}
|
|
|
|
protected void LimpiaModal()
|
|
{
|
|
DdlTractor.SelectedIndex = 0;
|
|
DdlRemolque.SelectedIndex = 0;
|
|
DdlFleteHuertaEmpaque.SelectedIndex = 0;
|
|
DdlScat.SelectedIndex = 0;
|
|
DdlChofer.SelectedIndex = 0;
|
|
DdlHuerta.SelectedIndex = 0;
|
|
DdlOrdenProduccion.SelectedIndex = 0;
|
|
DdlOrdenCorte.SelectedIndex = 0;
|
|
DdlProveedor.SelectedIndex = 0;
|
|
DdlTipo.SelectedIndex = 0;
|
|
DdlTipoFlete.SelectedIndex = 0;
|
|
DdlTipoEmpaque.SelectedIndex = 0;
|
|
TxtModalAdjuntoArchivo.Text = "";
|
|
TxtKmInicio.Text = "";
|
|
TxtKmFin.Text = "";
|
|
TxtCamion.Text = "";
|
|
TxtChofer.Text = "";
|
|
TxtColor.Text = "";
|
|
TxtPlaca.Text = "";
|
|
TxtFecha.Text = DateTime.Now.ToString();
|
|
ChkConCruce.Checked = false;
|
|
ChkCalculaImporte.Checked = false;
|
|
UpModalFleteAdd.Update();
|
|
}
|
|
|
|
public bool Validaciones()
|
|
{
|
|
if (DdlRemolque.SelectedValue == "-1" && DivRemolque.Visible)
|
|
{
|
|
Alert("Tiene que seleccionar un remolque", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
if (DdlFleteHuertaEmpaque.SelectedValue == "-1" && DivFleteHuertaEmpaque.Visible)
|
|
{
|
|
Alert("Tiene que seleccionar un flete", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
|
|
if (DdlTractor.SelectedValue == "-1" && DivTractor.Visible)
|
|
{
|
|
Alert("Tiene que seleccionar un tracto", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
if (DdlScat.SelectedValue == "-1" && DivScat.Visible)
|
|
{
|
|
Alert("Tiene que seleccionar un scat", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
|
|
|
|
if (DdlOrdenCorte.SelectedValue == "-1" && DivOrdenCorte.Visible)
|
|
{
|
|
Alert("Tiene que seleccionar una orden de corte", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
|
|
if (DdlChofer.SelectedValue == "-1" && DivChofer.Visible)
|
|
{
|
|
Alert("Tiene que seleccionar un chofer", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
|
|
if (DdlHuerta.SelectedValue == "-1" && DivHuerta.Visible)
|
|
{
|
|
Alert("Tiene que seleccionar una huerta", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
|
|
if (DdlOrdenProduccion.SelectedValue == "-1" && DivOrdenProduccion.Visible)
|
|
{
|
|
Alert("Tiene que seleccionar una orden de produccion", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
|
|
if (DdlProveedor.SelectedValue == "-1" && DivProveedor.Visible)
|
|
{
|
|
Alert("Tiene que seleccionar un proveedor", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
|
|
if (DdlTipo.SelectedValue == "-1")
|
|
{
|
|
Alert("Tiene que seleccionar un tipo", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
|
|
if (DdlTipoFlete.SelectedValue == "-1")
|
|
{
|
|
Alert("Tiene que seleccionar un tipo de flete", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
|
|
if (DdlTipoEmpaque.SelectedValue == "-1" && DivTipoEmpaque.Visible)
|
|
{
|
|
Alert("Tiene que seleccionar un tipo de empaque", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
protected void LnkEditarFlete_Click(object sender, EventArgs e)
|
|
{
|
|
LimpiaModal();
|
|
GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
CveFlete = gvRow.DataKey("CveFlete").ToEntero();
|
|
Index = gvRow.RowIndex;
|
|
DdlTractor.SelectedValueExist(gvRow.DataKey("CveAFTractor"));
|
|
DdlRemolque.SelectedValueExist(gvRow.DataKey("CveAFRemolque"));
|
|
DdlScat.SelectedValueExist(gvRow.DataKey("CveScat"));
|
|
DdlChofer.SelectedValueExist(gvRow.DataKey("CveChofer"));
|
|
DdlHuerta.SelectedValueExist(gvRow.DataKey("CveHuerta"));
|
|
CargaOrdenProduccion(gvRow.DataKey("CveOrdenProduccion").ToEntero());
|
|
DdlOrdenProduccion.SelectedValueExist(gvRow.DataKey("CveOrdenProduccion"));
|
|
CargaOrdenCorte(gvRow.DataKey("CveOrdenCorte").ToEntero());
|
|
DdlOrdenCorte.SelectedValueExist(gvRow.DataKey("CveOrdenCorte"));
|
|
CargaFleteHuertaEmpaque(gvRow.DataKey("CveFleteHuertaEmpaque").ToEntero());
|
|
DdlFleteHuertaEmpaque.SelectedValueExist(gvRow.DataKey("CveFleteHuertaEmpaque"));
|
|
DdlProveedor.SelectedValueExist(gvRow.DataKey("CveProveedor"));
|
|
Adjunto = gvRow.DataKey("Adjunto");
|
|
DdlTipo.SelectedValueExist(gvRow.DataKey("Tipo"));
|
|
DdlTipoFlete.SelectedValueExist(gvRow.DataKey("TipoFlete"));
|
|
DdlTipoEmpaque.SelectedValueExist(gvRow.DataKey("TipoEmpaque"));
|
|
DdlEmpaque.SelectedValueExist(gvRow.DataKey("CveEmpaque"));
|
|
IndexChange();
|
|
TxtFecha.Text = gvRow.DataKey("Fecha");
|
|
TxtKmInicio.Text = gvRow.DataKey("KmInicio");
|
|
TxtKmFin.Text = gvRow.DataKey("KmFin");
|
|
TxtCamion.Text = gvRow.DataKey("Camion");
|
|
TxtColor.Text = gvRow.DataKey("Color");
|
|
TxtPlaca.Text = gvRow.DataKey("Placa");
|
|
TxtChofer.Text = gvRow.DataKey("Chofer");
|
|
TxtImporte.Text = gvRow.DataKey("Importe");
|
|
if (gvRow.DataKey("ConCruce") != "") { ChkConCruce.Checked = Convert.ToBoolean(gvRow.DataKey("ConCruce")); }
|
|
if (gvRow.DataKey("Adjunto").ToString() != "-1") { LnkDescargar.Visible = true; }
|
|
Modalidad = "U";
|
|
BtnAddFlete.Text = "Actualizar";
|
|
RegistraScript("$('#DModalFlete').modal();","asd");
|
|
UpModalFleteAdd.Update();
|
|
}
|
|
|
|
protected void LnkAddFlete_Click(object sender, EventArgs e)
|
|
{
|
|
Agregar();
|
|
}
|
|
protected void Agregar()
|
|
{
|
|
Modalidad = "A";
|
|
LimpiaModal();
|
|
IndexChange();
|
|
BtnAddFlete.Text = "Agregar";
|
|
if (CveOrdenCorteOpcion > 0) { DdlOrdenCorte.SelectedValueExist(CveOrdenCorteOpcion); CargaFleteHuertaEmpaque(); DdlTipo.SelectedValue = "1"; }
|
|
if (CveOrdenProduccionOpcion > 0) { DdlOrdenProduccion.SelectedValueExist(CveOrdenProduccionOpcion); DdlTipo.SelectedValue = "2"; }
|
|
RegistraScript("$('#DModalFlete').modal();");
|
|
UpModalFleteAdd.Update();
|
|
}
|
|
protected void BtnAddFlete_Click(object sender, EventArgs e)
|
|
{
|
|
if (Validaciones())
|
|
{
|
|
int CveHuerta = -1;
|
|
if (DivHuerta.Visible == true) { CveHuerta = DdlHuerta.SelectedValue.ToEntero(); }
|
|
|
|
int CveAFRemolque = -1;
|
|
if (DivRemolque.Visible == true) { CveAFRemolque = DdlRemolque.SelectedValue.ToEntero(); }
|
|
|
|
int CveAFTractor = -1;
|
|
if (DivTractor.Visible == true) { CveAFTractor = DdlTractor.SelectedValue.ToEntero(); }
|
|
|
|
int CveScat = -1;
|
|
if (DivScat.Visible == true || DdlScat.SelectedValue.ToEntero() > 0) { CveScat = DdlScat.SelectedValue.ToEntero(); }
|
|
|
|
int CveChofer = -1;
|
|
String Chofer = "";
|
|
if (DivChofer.Visible == true) { CveChofer = DdlChofer.SelectedValue.ToEntero(); Chofer = DdlChofer.SelectedItem.Text; }
|
|
if (DivTxtChofer.Visible == true) { Chofer = TxtChofer.Text; }
|
|
|
|
int CveProveedor = -1;
|
|
if (DivProveedor.Visible == true) { CveProveedor = DdlProveedor.SelectedValue.ToEntero(); }
|
|
|
|
int CveOrdenProduccion = -1;
|
|
if (DivOrdenProduccion.Visible == true) { CveOrdenProduccion = DdlOrdenProduccion.SelectedValue.ToEntero(); }
|
|
|
|
int CveOrdenCorte = -1;
|
|
if (DivOrdenCorte.Visible == true) { CveOrdenCorte = DdlOrdenCorte.SelectedValue.ToEntero(); }
|
|
|
|
String KmFin = "";
|
|
if (DdlTipo.SelectedValue == "2" && DdlTipoFlete.SelectedValue == "1") { KmFin = TxtKmFin.Text; }
|
|
|
|
int CveEmpaque = -1;
|
|
if (DivEmpaque.Visible == true) { CveEmpaque = DdlEmpaque.SelectedValue.ToEntero(); }
|
|
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
ObjCGame.IniciaTransacSQL();
|
|
var Error = false;
|
|
var _CveFlete = -1;
|
|
var ImporteTotal = 0.0;
|
|
if (Modalidad == "A")
|
|
{
|
|
String Adjunto = "-1";
|
|
if (TxtModalAdjuntoArchivo.getfiles().Archivos.Count > 0)
|
|
{
|
|
Archivo ArchivoAdjunto = TxtModalAdjuntoArchivo.getfiles().Archivos[0];
|
|
Adjunto = ArchivoAdjunto.filenameO;
|
|
}
|
|
if (ObjCGame.AddFlete(DdlTipo.SelectedValue.ToEntero(), CveHuerta, TxtFecha.Text.ToDate(), DdlTipoFlete.SelectedValue.ToEntero(), CveAFRemolque, CveChofer, CveProveedor, CveOrdenProduccion, TxtKmInicio.Text.ToDouble(), KmFin.ToDouble(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, ChkConCruce.Checked, Adjunto, CveOrdenCorte, CveAFTractor, CveScat, TxtCamion.Text, TxtColor.Text, TxtPlaca.Text, TxtChofer.Text, DdlTipoEmpaque.SelectedValue.ToEntero(),TxtImporte.Text.ToDouble(),CveEmpaque))
|
|
{
|
|
_CveFlete = ObjCGame.CveFlete;
|
|
GuardarAdjunto();
|
|
RegistraScript("$('#DModalFlete').modal('hide');");
|
|
}
|
|
else
|
|
{
|
|
Error = true;
|
|
}
|
|
|
|
if (DdlTipo.SelectedValue == "1" && DdlTipoFlete.SelectedValue == "2")
|
|
{
|
|
int CveCorteGasto = 0;
|
|
if (ObjCGame.AddCorteGasto(CveOrdenCorte, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DateTime.Now, 0.0))
|
|
{
|
|
CveCorteGasto = ObjCGame.CveCorteGasto;
|
|
if (ObjCGame.AddCorteGastoDetalle(CveCorteGasto, 16, 1, TxtImporte.Text.ToDouble()) == false)
|
|
{
|
|
Error = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Error = true;
|
|
}
|
|
}
|
|
if (!ObjCGame.RemoveFleteDetalle(_CveFlete))
|
|
{
|
|
Error = true;
|
|
}
|
|
if (DdlTipo.SelectedValue.ToEntero() == 2 && DdlTipoFlete.SelectedValue.ToEntero()==1 && ChkCalculaImporte.Checked)
|
|
{
|
|
if (ObjCGame.GetProduccionResultado(-1, CveOrdenProduccion: DdlOrdenProduccion.SelectedValue.ToEntero()))
|
|
{
|
|
DataTable DtProduccionResultado = ObjCGame.DtResultados.Copy();
|
|
foreach (DataRow Dr in DtProduccionResultado.Rows)
|
|
{
|
|
if (ObjCGame.AddFleteDetalle(_CveFlete, Dr["CveProduccionResultado"].ToEntero(), DdlOrdenProduccion.SelectedValue.ToEntero(), DdlTipoEmpaque.SelectedValue.ToEntero()))
|
|
{
|
|
ImporteTotal = ImporteTotal + ObjCGame.ImporteDetalle;
|
|
}
|
|
else
|
|
{
|
|
Error = true;
|
|
}
|
|
}
|
|
if (!ObjCGame.UpdateFlete(_CveFlete, DdlTipo.SelectedValue.ToEntero(), CveHuerta, TxtFecha.Text.ToDate(), DdlTipoFlete.SelectedValue.ToEntero(), CveAFRemolque, CveChofer, CveProveedor, CveOrdenProduccion, TxtKmInicio.Text.ToDouble(), TxtKmFin.Text.ToDouble(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, ChkConCruce.Checked, Adjunto, CveOrdenCorte, CveAFTractor, CveScat, TxtCamion.Text, TxtColor.Text, TxtPlaca.Text, TxtChofer.Text, DdlTipoEmpaque.SelectedValue.ToEntero(), ImporteTotal,CveEmpaque))
|
|
{
|
|
Error = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Error = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ObjCGame.UpdateFleteHuertaEmpaque(DdlFleteHuertaEmpaque.SelectedValue.ToEntero(), _CveFlete) == false)
|
|
{
|
|
Error = true;
|
|
}
|
|
}
|
|
}
|
|
else if (Modalidad == "U")
|
|
{
|
|
if (TxtModalAdjuntoArchivo.getfiles().Archivos.Count > 0)
|
|
{
|
|
Archivo ArchivoAdjunto = TxtModalAdjuntoArchivo.getfiles().Archivos[0];
|
|
Adjunto = ArchivoAdjunto.filenameO;
|
|
}
|
|
if (ObjCGame.UpdateFlete(CveFlete, DdlTipo.SelectedValue.ToEntero(), CveHuerta, TxtFecha.Text.ToDate(), DdlTipoFlete.SelectedValue.ToEntero(), CveAFRemolque, CveChofer, CveProveedor, CveOrdenProduccion, TxtKmInicio.Text.ToDouble(), TxtKmFin.Text.ToDouble(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, ChkConCruce.Checked, Adjunto, CveOrdenCorte, CveAFTractor, CveScat, TxtCamion.Text, TxtColor.Text, TxtPlaca.Text, TxtChofer.Text, DdlTipoEmpaque.SelectedValue.ToEntero(), TxtImporte.Text.ToDouble(),CveEmpaque))
|
|
{
|
|
_CveFlete = CveFlete;
|
|
Alert("El Flete fue actualizado correctamente");
|
|
GuardarAdjunto();
|
|
RegistraScript("$('#DModalFlete').modal('hide');");
|
|
}
|
|
else
|
|
{
|
|
Error = true;
|
|
}
|
|
if (!ObjCGame.RemoveFleteDetalle(_CveFlete))
|
|
{
|
|
Error = true;
|
|
}
|
|
if (DdlTipo.SelectedValue.ToEntero() == 2 && DdlTipoFlete.SelectedValue.ToEntero() == 1 && ChkCalculaImporte.Checked)
|
|
{
|
|
if (ObjCGame.GetProduccionResultado(-1, CveOrdenProduccion: DdlOrdenProduccion.SelectedValue.ToEntero()))
|
|
{
|
|
DataTable DtProduccionResultado = ObjCGame.DtResultados.Copy();
|
|
foreach (DataRow Dr in DtProduccionResultado.Rows)
|
|
{
|
|
if (ObjCGame.AddFleteDetalle(_CveFlete, Dr["CveProduccionResultado"].ToEntero(), DdlOrdenProduccion.SelectedValue.ToEntero(), DdlTipoEmpaque.SelectedValue.ToEntero()))
|
|
{
|
|
ImporteTotal = ImporteTotal + ObjCGame.ImporteDetalle;
|
|
}
|
|
else
|
|
{
|
|
Error = true;
|
|
}
|
|
}
|
|
if (!ObjCGame.UpdateFlete(_CveFlete, DdlTipo.SelectedValue.ToEntero(), CveHuerta, TxtFecha.Text.ToDate(), DdlTipoFlete.SelectedValue.ToEntero(), CveAFRemolque, CveChofer, CveProveedor, CveOrdenProduccion, TxtKmInicio.Text.ToDouble(), TxtKmFin.Text.ToDouble(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, ChkConCruce.Checked, Adjunto, CveOrdenCorte, CveAFTractor, CveScat, TxtCamion.Text, TxtColor.Text, TxtPlaca.Text, TxtChofer.Text, DdlTipoEmpaque.SelectedValue.ToEntero(), ImporteTotal, CveEmpaque))
|
|
{
|
|
Error = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Error = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ObjCGame.UpdateFleteHuertaEmpaque(DdlFleteHuertaEmpaque.SelectedValue.ToEntero(), _CveFlete) == false)
|
|
{
|
|
Error = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (!Error)
|
|
{
|
|
ObjCGame.Commit();
|
|
if (CveOrdenCorteOpcion > 0)
|
|
{
|
|
Alert("El Flete fue agregado correctamente", TipoMensaje.MsgInformacion, $"document.location.href=\"/CGame/RepOrdenCorteDetalle.aspx?CveOrdenCorte={CveOrdenCorteOpcion}\"");
|
|
}
|
|
else if (CveOrdenProduccionOpcion > 0)
|
|
{
|
|
Alert("El Flete fue agregado correctamente", TipoMensaje.MsgInformacion, $"document.location.href=\"/CGame/OrdenProduccion.aspx?CveOrdenProduccion={CveOrdenProduccionOpcion}\"");
|
|
}
|
|
else if (Modalidad == "A")
|
|
{
|
|
|
|
Alert("El Flete fue agregado correctamente");
|
|
}
|
|
CargaFletes();
|
|
}
|
|
else
|
|
{
|
|
ObjCGame.RollBack();
|
|
}
|
|
ObjCGame.Dispose();
|
|
if (Modalidad == "A")
|
|
{
|
|
var Fecha = "";
|
|
var Empaque = "";
|
|
var Body = "";
|
|
var Descripcion = "";
|
|
ClsCGame ObjEnvio = new ClsCGame();
|
|
if (DdlTipo.SelectedValue.ToEntero() == 1)
|
|
{
|
|
if (ObjEnvio.GetFleteHuertaEmpaque(UsuarioActual.CveEmpresa, DdlFleteHuertaEmpaque.SelectedValue.ToEntero()))
|
|
{
|
|
Fecha = ObjEnvio.DtResultados.Rows[0]["FechaFleteHuertaEmpaque"].ToString().ToDate().ToShortDateString();
|
|
Empaque = ObjEnvio.DtResultados.Rows[0]["Empaque"].ToString();
|
|
Descripcion = ObjEnvio.DtResultados.Rows[0]["FolioFechaEmpaque"].ToString();
|
|
}
|
|
Body = ObjEnvio.GeneraCorreoFlete(DdlOrdenCorte.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa, UsuarioActual.Nombre, Fecha, Empaque);
|
|
}
|
|
else
|
|
{
|
|
Body = ObjEnvio.GeneraCorreoFlete(DdlOrdenProduccion.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa, UsuarioActual.Nombre, Fecha, Empaque, Opcion: 1);
|
|
}
|
|
ObjEnvio.Dispose();
|
|
//EnviarCorreo(DdlOrdenCorte.SelectedValue.ToEntero(), Body, Descripcion);
|
|
}
|
|
CargaOrdenCorte();
|
|
CargaFleteHuertaEmpaque();
|
|
CargaOrdenProduccion();
|
|
UpDatos.Update();
|
|
}
|
|
}
|
|
|
|
protected void DdlTipo_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
IndexChange();
|
|
}
|
|
protected void DdlTipoFlete_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
IndexChange();
|
|
}
|
|
protected void IndexChange()
|
|
{
|
|
LnkDescargar.Visible = false;
|
|
DivRemolque.Visible = false;
|
|
DivTractor.Visible = false;
|
|
DivScat.Visible = false;
|
|
DivOrdenCorte.Visible = false;
|
|
DivChofer.Visible = false;
|
|
DivHuerta.Visible = false;
|
|
DivFleteHuertaEmpaque.Visible = false;
|
|
DivKmFin.Visible = false;
|
|
DivKmInicio.Visible = false;
|
|
DivOrdenProduccion.Visible = false;
|
|
DivProveedor.Visible = false;
|
|
DivConCruce.Visible = false;
|
|
DivFecha.Visible = false;
|
|
DivImporte.Visible = false;
|
|
DivImporteCalcula.Visible = false;
|
|
DivTxtChofer.Visible = false;
|
|
DivCamion.Visible = false;
|
|
DivColor.Visible = false;
|
|
DivPlaca.Visible = false;
|
|
DivTipoEmpaque.Visible = false;
|
|
DivEmpaque.Visible = false;
|
|
if (DdlTipo.SelectedValue != "-1" && DdlTipoFlete.SelectedValue != "-1")
|
|
{
|
|
if (DdlTipo.SelectedValue.ToEntero() == 1)
|
|
{
|
|
DivOrdenCorte.Visible = true;
|
|
DivCamion.Visible = true;
|
|
DivColor.Visible = true;
|
|
DivPlaca.Visible = true;
|
|
DivFleteHuertaEmpaque.Visible = true;
|
|
DivImporte.Visible = true;
|
|
if (DdlTipoFlete.SelectedValue.ToEntero() == 1)
|
|
{
|
|
DivRemolque.Visible = true;
|
|
DivTractor.Visible = true;
|
|
DivChofer.Visible = true;
|
|
DivImporteCalcula.Visible = true;
|
|
}
|
|
else if (DdlTipoFlete.SelectedValue.ToEntero() == 2)
|
|
{
|
|
DivProveedor.Visible = true;
|
|
DivTxtChofer.Visible = true;
|
|
}
|
|
}
|
|
else if (DdlTipo.SelectedValue.ToEntero() == 2)
|
|
{
|
|
DivFecha.Visible = true;
|
|
DivOrdenProduccion.Visible = true;
|
|
DivTipoEmpaque.Visible = true;
|
|
DivEmpaque.Visible = true;
|
|
DivCamion.Visible = true;
|
|
DivColor.Visible = true;
|
|
DivPlaca.Visible = true;
|
|
DivImporte.Visible = true;
|
|
if (DdlTipoFlete.SelectedValue.ToEntero() == 1)
|
|
{
|
|
DivRemolque.Visible = true;
|
|
DivTractor.Visible = true;
|
|
DivChofer.Visible = true;
|
|
DdlScat.SelectedValueExist("1");
|
|
DivCamion.Visible = false;
|
|
DivColor.Visible = false;
|
|
DivPlaca.Visible = false;
|
|
DivImporteCalcula.Visible = true;
|
|
}
|
|
else if (DdlTipoFlete.SelectedValue.ToEntero() == 2)
|
|
{
|
|
DivProveedor.Visible = true;
|
|
DivTxtChofer.Visible = true;
|
|
}
|
|
}
|
|
}
|
|
UpModalFleteAdd.Update();
|
|
}
|
|
|
|
protected void LnkEliminarFlete_Click(object sender, EventArgs e)
|
|
{
|
|
GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
ClsCGame ObjCGame = new ClsCGame();
|
|
bool Continuar = ObjCGame.RemoveFlete(gvRow.DataKey("CveFlete").ToEntero());
|
|
ObjCGame.Dispose();
|
|
if (Continuar)
|
|
{
|
|
CargaFletes();
|
|
Alert("El Flete se ha eliminado correctamente");
|
|
}
|
|
}
|
|
|
|
protected void GvFlete_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.RowIndex == 0)
|
|
{
|
|
e.Row.Cells[0].Text = "Total";
|
|
e.Row.CssClass = "Totales";
|
|
e.Row.Cells[4].Text = "";
|
|
}
|
|
else
|
|
{
|
|
if (e.Row.DataKey("Tipo").ToEntero() == 1)
|
|
{
|
|
e.Row.FCLabel("LblTipo").Text = "Huerta Empaque";
|
|
}
|
|
else if (e.Row.DataKey("Tipo").ToEntero() == 2)
|
|
{
|
|
e.Row.FCLabel("LblTipo").Text = "Empaque USA";
|
|
}
|
|
|
|
if (e.Row.DataKey("TipoFlete").ToEntero() == 1)
|
|
{
|
|
e.Row.FCLabel("LblTipoFlete").Text = "Interno";
|
|
}
|
|
else if (e.Row.DataKey("TipoFlete").ToEntero() == 2)
|
|
{
|
|
e.Row.FCLabel("LblTipoFlete").Text = "Externo";
|
|
}
|
|
|
|
if (e.Row.DataKey("CveOrdenCorte").ToEntero() == 0)
|
|
{
|
|
e.Row.Cells[1].Text = "N/D";
|
|
}
|
|
|
|
if (e.Row.DataKey("CveOrdenProduccion").ToEntero() == 0)
|
|
{
|
|
e.Row.Cells[0].Text = "N/D";
|
|
}
|
|
|
|
if (e.Row.DataKey("CveOrdenCorte").ToEntero() > 0)
|
|
{
|
|
String Css = "Texto";
|
|
String Liga = $"/CGame/RepOrdenCorteDetalle.aspx?&CveOrdenCorte={e.Row.DataKey("CveOrdenCorte")}";
|
|
e.Row.Cells[1].Text = "<a class=" + "" + Css + "" + " href=" + "" + Liga + "" + ">" + e.Row.Cells[1].Text + "</a>";
|
|
}
|
|
|
|
if (e.Row.DataKey("CveOrdenProduccion").ToEntero() > 0)
|
|
{
|
|
String Css = "Texto";
|
|
String Liga = $"/CGame/OrdenProduccion.aspx?&CveOrdenProduccion={e.Row.DataKey("CveOrdenProduccion")}";
|
|
e.Row.Cells[0].Text = "<a class=" + "" + Css + "" + " href=" + "" + Liga + "" + ">" + e.Row.Cells[0].Text + "</a>";
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
protected void GuardarAdjunto()
|
|
{
|
|
if (TxtModalAdjuntoArchivo.getfiles().Archivos.Count < 1)
|
|
{
|
|
return;
|
|
}
|
|
Archivo ArchivoAdjunto = TxtModalAdjuntoArchivo.getfiles().Archivos[0];
|
|
if (ArchivoAdjunto.filenameO.Length > 114)
|
|
{
|
|
Alert("El nombre del archivo excede los 115 caracteres permitidos. Por favor rectifique y vuelva a intentar.", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
return;
|
|
}
|
|
try
|
|
{
|
|
String Path = String.Format("{0}\\{1}", UsuarioActual.Empresa.Ruta, "AdjuntosHuertaEmpaque");
|
|
ModExtensiones.DirectoryExistsCreate(ref Path);
|
|
String ArchivoDestino = String.Format("{0}\\{1}", Path, ArchivoAdjunto.filenameO);
|
|
if (System.IO.File.Exists(ArchivoDestino))
|
|
{
|
|
System.IO.File.Delete(ArchivoDestino);
|
|
}
|
|
System.IO.File.Move(ArchivoAdjunto.FileUrl, ArchivoDestino);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
Alert("Ocurrió un error al guardar el archivo Adjunto. Por favor vuelva a intentar.", TipoMensaje.MsgError);
|
|
}
|
|
}
|
|
|
|
protected void LnkDescargar_Click(object sender, EventArgs e)
|
|
{
|
|
string filename = GvFlete.Rows[Index].DataKey("Adjunto").ToString();
|
|
|
|
if (!String.IsNullOrEmpty(filename))
|
|
{
|
|
String rutaAplicacion = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath);
|
|
|
|
String Path = String.Format("{0}\\{1}", UsuarioActual.Empresa.Ruta, "AdjuntosHuertaEmpaque");
|
|
String ArchivoDestino = String.Format("{0}\\{1}", Path, GvFlete.Rows[Index].DataKey("Adjunto").ToString());
|
|
System.IO.FileInfo toDownload =
|
|
new System.IO.FileInfo(ArchivoDestino);
|
|
if (toDownload.Exists)
|
|
{
|
|
Response.ClearContent();
|
|
Response.ClearHeaders();
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
|
|
Response.ContentType = "application/octet-stream";
|
|
Response.WriteFile(ArchivoDestino);
|
|
Response.Flush();
|
|
Response.Close();
|
|
Response.End();
|
|
HttpContext.Current.ApplicationInstance.CompleteRequest();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void MandaCorreo(String Para, String Asunto, String Body)
|
|
{
|
|
ClsSisMail Mail = new ClsSisMail();
|
|
Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body);
|
|
}
|
|
|
|
private void EnviarCorreo(int CveOrdenCorte, String Body, String Descripcion)
|
|
{
|
|
var Asunto = "";
|
|
if (DdlTipo.SelectedValue.ToEntero() == 1)
|
|
{
|
|
Asunto = "SIG - Asignacion de flete " + Descripcion;
|
|
}
|
|
else
|
|
{
|
|
Asunto = "SIG - Asignacion de flete " + DdlOrdenProduccion.SelectedItem.Text;
|
|
}
|
|
//var Para = "julian@adsistemas.mx";
|
|
//var Para = "dany_pimi@hotmail.com";
|
|
var Para = "eduardo@citrusgame.com.mx;monica@citrusgame.com.mx;rene@citrusgame.com.mx;sergio@citrusgame.com.mx";
|
|
|
|
try
|
|
{
|
|
var Hilo = new System.Threading.Thread(() => MandaCorreo(Para, Asunto, Body));
|
|
Hilo.Start();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Alert("Ocurrio un error al mandar el mail " + ex);
|
|
}
|
|
}
|
|
|
|
|
|
#region - CONSULTAR -
|
|
protected void BtnConsultar_Click(object sender, EventArgs e)
|
|
{
|
|
CargaFletes();
|
|
}
|
|
#endregion
|
|
|
|
|
|
protected void DdlOrdenCorte_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
CargaFleteHuertaEmpaque();
|
|
}
|
|
|
|
protected void ChkCalculaImporte_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (ChkCalculaImporte.Checked)
|
|
{
|
|
TxtImporte.Text = "";
|
|
TxtImporte.Enabled=false;
|
|
RFVImporte.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
TxtImporte.Enabled = true;
|
|
RFVImporte.Enabled = true;
|
|
}
|
|
}
|
|
|
|
protected void LbkExportarExcel_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//GvFlete.ExportToExcelX("Fletes");
|
|
ExportToExcelG(GvFlete,"Fletes", "Fletes", UsuarioActual);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Alert(ex.ToString(), TipoMensaje.MsgError);
|
|
}
|
|
|
|
}
|
|
public override void VerifyRenderingInServerForm(Control control)
|
|
{
|
|
|
|
}
|
|
|
|
public void ExportToExcelG(GridView Gv, string NombreArchivoXLSx, string Titulo = "Reporte", Usuario Usuario = null/* TODO Change to default(_) if this is not a reference type */)
|
|
{
|
|
Gv.Columns[GvFlete.Columns.Count - 1].Visible = false;
|
|
|
|
StringWriter sw = new StringWriter();
|
|
HtmlTextWriter htw = new HtmlTextWriter(sw);
|
|
|
|
Gv.RenderControl(htw);
|
|
GemBox.Spreadsheet.SpreadsheetInfo.SetLicense("ESWN-4QFD-26JF-1SZ8");
|
|
|
|
GemBox.Spreadsheet.ExcelFile excel;
|
|
var options = GemBox.Spreadsheet.LoadOptions.HtmlDefault;
|
|
using (var htmlStream = new MemoryStream(options.Encoding.GetBytes(sw.ToString())))
|
|
{
|
|
excel = GemBox.Spreadsheet.ExcelFile.Load(htmlStream, options);
|
|
if (Usuario != null)
|
|
{
|
|
var worksheet = excel.Worksheets[0];
|
|
worksheet.Rows.InsertEmpty(0, 6);
|
|
|
|
System.IO.FileInfo Imagen = new System.IO.FileInfo(string.Format("{0}/Logo.png", Usuario.Empresa.Ruta));
|
|
var logouri = string.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, Usuario.CveEmpresa);
|
|
|
|
if (Imagen.Exists)
|
|
worksheet.Pictures.Add(logouri.ToString(), "A1", "B4");
|
|
|
|
var celdasConTexto = worksheet.GetUsedCellRange(true);
|
|
celdasConTexto.Style.Font.Name = "Calibri Light";
|
|
|
|
var RangoNombreEmpresa = worksheet.Cells.GetSubrangeAbsolute(1, celdasConTexto.FirstColumnIndex, 1, celdasConTexto.LastColumnIndex);
|
|
RangoNombreEmpresa.Merged = true;
|
|
RangoNombreEmpresa.Value = Usuario.Empresa.Empresa;
|
|
RangoNombreEmpresa.Style.Font.Size = 18 * 20;
|
|
RangoNombreEmpresa.Style.Font.Name = "Calibri Light";
|
|
RangoNombreEmpresa.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center;
|
|
RangoNombreEmpresa.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center;
|
|
|
|
var RangoTitulo = worksheet.Cells.GetSubrangeAbsolute(3, celdasConTexto.FirstColumnIndex, 3, celdasConTexto.LastColumnIndex);
|
|
RangoTitulo.Merged = true;
|
|
RangoTitulo.Value = Titulo;
|
|
RangoTitulo.Style.Font.Size = 20 * 20;
|
|
RangoTitulo.Style.Font.Name = "Calibri Light";
|
|
RangoTitulo.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center;
|
|
RangoTitulo.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center;
|
|
|
|
for (var i = celdasConTexto.FirstColumnIndex; i <= celdasConTexto.LastColumnIndex; i++)
|
|
{
|
|
worksheet.Rows[6].Cells[i].Style.Font.Size = 12 * 20;
|
|
worksheet.Rows[6].Cells[i].Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center;
|
|
worksheet.Rows[6].Cells[i].Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center;
|
|
worksheet.Rows[6].Cells[i].Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255));
|
|
worksheet.Rows[6].Cells[i].Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255);
|
|
if (i > 0)
|
|
{
|
|
try
|
|
{
|
|
worksheet.Columns[i].AutoFit(1);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Alert(ex.ToString(), TipoMensaje.MsgError);
|
|
}
|
|
}
|
|
}
|
|
|
|
int IndexEndTable = Gv.Rows.Count + 8;
|
|
|
|
worksheet.Rows[IndexEndTable].Cells[2].Value = "Usuario Imprimió";
|
|
worksheet.Rows[IndexEndTable + 1].Cells[2].Value = Usuario.Nombre;
|
|
|
|
worksheet.Rows[IndexEndTable].Cells[6].Value = "Fecha Impresión";
|
|
worksheet.Rows[IndexEndTable + 1].Cells[6].Value = DateTime.Now.ToString("dd/MM/yyyy");
|
|
}
|
|
}
|
|
htw.Dispose();
|
|
|
|
excel.Save(HttpContext.Current.Response, $"{NombreArchivoXLSx}.xls");
|
|
}
|
|
//Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
|
|
//End Sub
|
|
} |