-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)
51 lines
5.8 KiB
C#
51 lines
5.8 KiB
C#
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI.WebControls;
|
|
using Extensiones;
|
|
|
|
public partial class CATHuerta :ClsPaginas
|
|
{
|
|
|
|
#region Propiedades
|
|
private int CveHuerta
|
|
{
|
|
get{return (ViewState["CveHuerta"] == null) ? 0 : Convert.ToInt32(ViewState["CveHuerta"]);}
|
|
set{ViewState["CveHuerta"] =value;}
|
|
}
|
|
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack){
|
|
CargaProveedor();
|
|
CargaHuerta();
|
|
}
|
|
}
|
|
protected void CargaHuerta()
|
|
{
|
|
ClsCGame ObjHuer =new ClsCGame();
|
|
if (ObjHuer.GetHuerta(UsuarioActual.CveEmpresa))
|
|
{
|
|
GVHuerta.DataSource = ObjHuer.DtResultados;
|
|
GVHuerta.DataBind();
|
|
}
|
|
ObjHuer.Dispose();
|
|
upDatosHuer.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();
|
|
|
|
}
|
|
protected void LimpiaHuerta()
|
|
{
|
|
TxtHuerhuerta.Text= "";
|
|
TxtImporte.Text = "";
|
|
TxtCostoXTonelada.Text = "";
|
|
DdlProveedor.SelectedIndex = 0;
|
|
DdlTipoCobro.SelectedIndex = 0;
|
|
UPModalHuer.Update();
|
|
}
|
|
protected void LnkEditarHuer_Click(object sender, EventArgs e)
|
|
{
|
|
LimpiaHuerta();
|
|
GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
CveHuerta = gvRow.DataKey("CveHuerta").ToEntero();
|
|
TxtHuerhuerta.Text = gvRow.DataKey("Huerta");
|
|
TxtImporte.Text = gvRow.DataKey("Importe");
|
|
TxtCostoXTonelada.Text = gvRow.DataKey("CostoXTonelada");
|
|
DdlProveedor.SelectedValueExist(gvRow.DataKey("CveProveedor").ToEntero());
|
|
DdlTipoCobro.SelectedValueExist(gvRow.DataKey("TipoCobro").ToEntero());
|
|
ChkHuerestatus.Checked= Convert.ToBoolean(gvRow.DataKey("Estatus"));
|
|
RegistraScript("$('#DModalHuerta').modal();");
|
|
BtnHuerADD.Visible=false;
|
|
BtnHuerEdit.Visible=true;
|
|
DivEstatus.Visible = true;
|
|
UPModalHuer.Update();
|
|
}
|
|
protected void LnkAgregarHuer_Click(object sender, EventArgs e)
|
|
{
|
|
RegistraScript("$('#DModalHuerta').modal();");
|
|
LimpiaHuerta();
|
|
BtnHuerADD.Visible=true;
|
|
BtnHuerEdit.Visible=false;
|
|
DivEstatus.Visible = false;
|
|
UPModalHuer.Update();
|
|
}
|
|
protected void BtnHuerADD_Click(object sender, EventArgs e)
|
|
{
|
|
if (DdlProveedor.SelectedValue=="-1")
|
|
{
|
|
Alert("Tiene que seleccionar un proveedor.");
|
|
return;
|
|
|
|
}
|
|
ClsCGame ObjHuer =new ClsCGame();
|
|
bool Continuar = ObjHuer.AddHuerta(TxtHuerhuerta.Text, DdlProveedor.SelectedValue.ToEntero(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa,DdlTipoCobro.SelectedValue.ToEntero(),TxtImporte.Text.ToDouble(), TxtCostoXTonelada.Text.ToDouble());
|
|
ObjHuer.Dispose();
|
|
if(Continuar)
|
|
{
|
|
RegistraScript("$('#DModalHuerta').modal('hide');");
|
|
LimpiaHuerta();
|
|
UPModalHuer.Update();
|
|
Alert("La Huerta se ha agregado");
|
|
CargaHuerta();
|
|
}
|
|
}
|
|
protected void BtnHuerEdit_Click(object sender, EventArgs e)
|
|
{
|
|
ClsCGame ObjHuer =new ClsCGame();
|
|
bool Continuar = ObjHuer.UpdateHuerta(CveHuerta, TxtHuerhuerta.Text, DdlProveedor.SelectedValue.ToEntero(), ChkHuerestatus.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlTipoCobro.SelectedValue.ToEntero(), TxtImporte.Text.ToDouble(), TxtCostoXTonelada.Text.ToDouble());
|
|
ObjHuer.Dispose();
|
|
if(Continuar)
|
|
{
|
|
RegistraScript("$('#DModalHuerta').modal('hide');");
|
|
LimpiaHuerta();
|
|
UPModalHuer.Update();
|
|
Alert("La Huerta se ha actualizado");
|
|
CargaHuerta();
|
|
}
|
|
}
|
|
protected void LnkEliminarHuer_Click(object sender, EventArgs e)
|
|
{
|
|
GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
|
ClsCGame ObjHuer = new ClsCGame();
|
|
bool Continuar = ObjHuer.RemoveHuerta(gvRow.DataKey("CveHuerta").ToEntero());
|
|
ObjHuer.Dispose();
|
|
if(Continuar)
|
|
{
|
|
CargaHuerta();
|
|
Alert("La Huerta se ha eliminado");
|
|
}
|
|
}
|
|
|
|
protected void GvHuerta_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.DBCampo("TipoCobro").ToEntero()==1)
|
|
{
|
|
e.Row.FCLabel("LblTipoCobro").Text = "Costo X Tonelada";
|
|
}
|
|
else if (e.Row.DBCampo("TipoCobro").ToEntero() == 2)
|
|
{
|
|
e.Row.FCLabel("LblTipoCobro").Text = "Viaje";
|
|
}
|
|
else
|
|
{
|
|
e.Row.FCLabel("LblTipoCobro").Text = "No Asignado";
|
|
}
|
|
|
|
e.Row.FCLabel("LblImporte").Text = e.Row.FCLabel("LblImporte").Text.FormatoNumero();
|
|
e.Row.FCLabel("LblCostoXTonelada").Text = e.Row.FCLabel("LblCostoXTonelada").Text.FormatoNumero();
|
|
|
|
if (Convert.ToBoolean(e.Row.DBCampo("Estatus"))==true)
|
|
{
|
|
e.Row.FCLabel("lblestatus").Text = "Activo";
|
|
e.Row.FCLabel("lblestatus").ForeColor = System.Drawing.Color.Green;
|
|
}
|
|
else
|
|
{
|
|
e.Row.FCLabel("lblestatus").Text = "Inactivo";
|
|
e.Row.FCLabel("lblestatus").ForeColor = System.Drawing.Color.Red;
|
|
}
|
|
}
|
|
}
|
|
}
|