Upload com erro estranho
Olá pessoal. Sou novato em programação delphi. Peguei um projeto meio grande e estou apanhando bastante para dar manutenção nele. Um dos problemas que venho passando é por um upload de arquivo. É um arquivo xls que contém uma série de informações que são tratadas e inseridas no sqlserver.
Esse arquivo quando tem abaixo de 131 linhas é lido normalmente, mas quando ultrapassa essa quantidade de linhas, simplesmente dá erro. Só até a 131 linha é que o sistema lê, o resto simplesmente é perdido.
Essa é a rotina para o upload da planilha e inserção no bd.
unit pgPlanilha_Prod;
interface
uses
System.Collections, System.ComponentModel,
System.Data, System.Drawing, System.Web, System.Web.SessionState,
System.Web.UI, System.Web.UI.WebControls, System.Web.UI.HtmlControls,
C1.Web.C1Command, System.IO, Borland.Vcl.Classes, Borland.Data.Provider,
uConstantes, ControleMessageBox, Borland.Vcl.XmlDoc, System.Xml;
type
TWebForm1 = class(System.Web.UI.Page)
{$REGION 'Designer Managed Code'}
strict private
procedure InitializeComponent;
procedure btnCarregarPlanilha_Click(sender: System.Object; e: System.EventArgs);
procedure btnGravarDados_Click(sender: System.Object; e: System.EventArgs);
procedure ddlUsinas_SelectedIndexChanged(sender: System.Object; e: System.EventArgs);
procedure txtCodUsina_TextChanged(sender: System.Object; e: System.EventArgs);
procedure MB1_YesChoosed(sender: System.Object; Key: string);
procedure Button1_Click(sender: System.Object; e: System.EventArgs);
{$ENDREGION}
strict private
procedure Page_Load(sender: System.Object; e: System.EventArgs);
strict protected
lblCabecalhoPagina: System.Web.UI.WebControls.Label;
lblCabecalhoIdentificacao: System.Web.UI.WebControls.Label;
lblCodUsina: System.Web.UI.WebControls.Label;
ddlSafra: System.Web.UI.WebControls.DropDownList;
ddlMes: System.Web.UI.WebControls.DropDownList;
lblSafra: System.Web.UI.WebControls.Label;
pnlIdentificacao: System.Web.UI.WebControls.Panel;
pnlPrincipalCima: System.Web.UI.WebControls.Panel;
Label3: System.Web.UI.WebControls.Label;
lblChuva: System.Web.UI.WebControls.Label;
pnlComplementoMoagem: System.Web.UI.WebControls.Panel;
lblInicioMoagem: System.Web.UI.WebControls.Label;
lblFimMoagem: System.Web.UI.WebControls.Label;
pnlDatasMoagem: System.Web.UI.WebControls.Panel;
Label9: System.Web.UI.WebControls.Label;
pnlPrincipalBaixo: System.Web.UI.WebControls.Panel;
txtCodUsina: System.Web.UI.WebControls.TextBox;
imgBuscaUsinas: System.Web.UI.WebControls.ImageButton;
lblNomeUsina: System.Web.UI.WebControls.Label;
lblAno: System.Web.UI.WebControls.Label;
txtAno: System.Web.UI.WebControls.TextBox;
lblMes: System.Web.UI.WebControls.Label;
txtInicioMoagem: System.Web.UI.WebControls.TextBox;
txtFimMoagem: System.Web.UI.WebControls.TextBox;
txtChuva: System.Web.UI.WebControls.TextBox;
lblEficienciaIndustrial: System.Web.UI.WebControls.Label;
txtEficienciaIndustrial: System.Web.UI.WebControls.TextBox;
lblCorteManual: System.Web.UI.WebControls.Label;
txtCorteManual: System.Web.UI.WebControls.TextBox;
lblCorteMec: System.Web.UI.WebControls.Label;
txtCorteMec: System.Web.UI.WebControls.TextBox;
lblCabecalhoCanaProcessadaMoida: System.Web.UI.WebControls.Label;
lblFornecedoresMoida: System.Web.UI.WebControls.Label;
lblNumeroMedioCorte: System.Web.UI.WebControls.Label;
txtOutrasMoida: System.Web.UI.WebControls.TextBox;
txtTotalGeralMoida: System.Web.UI.WebControls.TextBox;
pnlDadosNumeroIdadeCorte: System.Web.UI.WebControls.Panel;
txtPropriaMoida: System.Web.UI.WebControls.TextBox;
lblTotalPropriaMoida: System.Web.UI.WebControls.Label;
lblMensagemCanaMoida: System.Web.UI.WebControls.Label;
lblOutrasMoida: System.Web.UI.WebControls.Label;
lblTotalGeralMoida: System.Web.UI.WebControls.Label;
pnlCanaProcessadaMoida: System.Web.UI.WebControls.Panel;
lblIdadeMediaCorte: System.Web.UI.WebControls.Label;
txtNumeroMedioCorte: System.Web.UI.WebControls.TextBox;
txtIdadeMediaCorte: System.Web.UI.WebControls.TextBox;
txtFornecedores: System.Web.UI.WebControls.TextBox;
Panel3: System.Web.UI.WebControls.Panel;
Panel8: System.Web.UI.WebControls.Panel;
lblMensagemCamposAzuis: System.Web.UI.WebControls.Label;
Panel9: System.Web.UI.WebControls.Panel;
Panel10: System.Web.UI.WebControls.Panel;
lblCabecalhoCanaMoida: System.Web.UI.WebControls.Label;
lblCrua: System.Web.UI.WebControls.Label;
txtCanaCrua: System.Web.UI.WebControls.TextBox;
pnlCanaMoida: System.Web.UI.WebControls.Panel;
Panel12: System.Web.UI.WebControls.Panel;
lblCabecalhoImpurezas: System.Web.UI.WebControls.Label;
lblImpurezaMineral: System.Web.UI.WebControls.Label;
lblImpurezaVegetal: System.Web.UI.WebControls.Label;
txtImpurezaMineralManual: System.Web.UI.WebControls.TextBox;
txtImpurezaMineralMecanica: System.Web.UI.WebControls.TextBox;
pnlImpurezas: System.Web.UI.WebControls.Panel;
Panel2: System.Web.UI.WebControls.Panel;
lblImpurezaManual: System.Web.UI.WebControls.Label;
Panel6: System.Web.UI.WebControls.Panel;
Panel11: System.Web.UI.WebControls.Panel;
lblImpurezaMecanica: System.Web.UI.WebControls.Label;
Panel13: System.Web.UI.WebControls.Panel;
Panel14: System.Web.UI.WebControls.Panel;
txtImpurezaVegetalMecanica: System.Web.UI.WebControls.TextBox;
txtImpurezaVegetalManual: System.Web.UI.WebControls.TextBox;
Panel1: System.Web.UI.WebControls.Panel;
Panel15: System.Web.UI.WebControls.Panel;
lblMensagemCamposVerdes: System.Web.UI.WebControls.Label;
Panel16: System.Web.UI.WebControls.Panel;
lblCabecalhoCanaMoidaTempoQueima: System.Web.UI.WebControls.Label;
lblTotalPropriaMoidaTempoQueima: System.Web.UI.WebControls.Label;
txt01a24h: System.Web.UI.WebControls.TextBox;
lbl01a24h: System.Web.UI.WebControls.Label;
lbl24a48h: System.Web.UI.WebControls.Label;
txt48a72h: System.Web.UI.WebControls.TextBox;
txtTotalMoidaTempoQueima: System.Web.UI.WebControls.TextBox;
txt24a48h: System.Web.UI.WebControls.TextBox;
pnlCanaMoidaTempoQueima: System.Web.UI.WebControls.Panel;
Panel18: System.Web.UI.WebControls.Panel;
lbl48a72h: System.Web.UI.WebControls.Label;
Panel19: System.Web.UI.WebControls.Panel;
Panel20: System.Web.UI.WebControls.Panel;
lblMais72h: System.Web.UI.WebControls.Label;
txtMais72h: System.Web.UI.WebControls.TextBox;
Panel21: System.Web.UI.WebControls.Panel;
Panel22: System.Web.UI.WebControls.Panel;
lblTempoMedio: System.Web.UI.WebControls.Label;
txtTempoMedio: System.Web.UI.WebControls.TextBox;
Panel5: System.Web.UI.WebControls.Panel;
Panel23: System.Web.UI.WebControls.Panel;
lblCabecalhoColheita: System.Web.UI.WebControls.Label;
Label2: System.Web.UI.WebControls.Label;
txtColheitaManualSQueimar: System.Web.UI.WebControls.TextBox;
lblManualSQueimar: System.Web.UI.WebControls.Label;
lblManualQueimada: System.Web.UI.WebControls.Label;
txtColheitaMecanicaSQueimar: System.Web.UI.WebControls.TextBox;
txtTotalColheita: System.Web.UI.WebControls.TextBox;
txtColheitaManualQueimada: System.Web.UI.WebControls.TextBox;
lblMecanicaSQueimar: System.Web.UI.WebControls.Label;
lblMecanicaQueimada: System.Web.UI.WebControls.Label;
txtColheitaMecanicaQueimada: System.Web.UI.WebControls.TextBox;
lblProducao: System.Web.UI.WebControls.Label;
pnlCilheita: System.Web.UI.WebControls.Panel;
Panel17: System.Web.UI.WebControls.Panel;
lblColheitaManual: System.Web.UI.WebControls.Label;
lblColheitaMecanica: System.Web.UI.WebControls.Label;
Panel7: System.Web.UI.WebControls.Panel;
Panel24: System.Web.UI.WebControls.Panel;
lblCabecalhoCanaColhidaMes: System.Web.UI.WebControls.Label;
lblHeaderEstagio: System.Web.UI.WebControls.Label;
txt1AmArea: System.Web.UI.WebControls.TextBox;
lblBis: System.Web.UI.WebControls.Label;
lbl1Ano: System.Web.UI.WebControls.Label;
txt1AnoArea: System.Web.UI.WebControls.TextBox;
lbl1Am: System.Web.UI.WebControls.Label;
txtBisArea: System.Web.UI.WebControls.TextBox;
Panel25: System.Web.UI.WebControls.Panel;
Panel26: System.Web.UI.WebControls.Panel;
lblHeaderArea: System.Web.UI.WebControls.Label;
Panel27: System.Web.UI.WebControls.Panel;
Panel28: System.Web.UI.WebControls.Panel;
lblHeaderTCH: System.Web.UI.WebControls.Label;
Panel29: System.Web.UI.WebControls.Panel;
Panel30: System.Web.UI.WebControls.Panel;
lbl4C: System.Web.UI.WebControls.Label;
lbl3C: System.Web.UI.WebControls.Label;
lbl2C: System.Web.UI.WebControls.Label;
Panel31: System.Web.UI.WebControls.Panel;
Panel32: System.Web.UI.WebControls.Panel;
lblTotalMediaMes: System.Web.UI.WebControls.Label;
lbl6C: System.Web.UI.WebControls.Label;
lbl5C: System.Web.UI.WebControls.Label;
Panel33: System.Web.UI.WebControls.Panel;
Panel34: System.Web.UI.WebControls.Panel;
txt4CArea: System.Web.UI.WebControls.TextBox;
txt3CArea: System.Web.UI.WebControls.TextBox;
txt2CArea: System.Web.UI.WebControls.TextBox;
Panel35: System.Web.UI.WebControls.Panel;
Panel36: System.Web.UI.WebControls.Panel;
txtTotalMediaArea: System.Web.UI.WebControls.TextBox;
txt6CArea: System.Web.UI.WebControls.TextBox;
txt5CArea: System.Web.UI.WebControls.TextBox;
Panel37: System.Web.UI.WebControls.Panel;
Panel38: System.Web.UI.WebControls.Panel;
txtTotalMediatch: System.Web.UI.WebControls.TextBox;
txt6ctch: System.Web.UI.WebControls.TextBox;
txt5ctch: System.Web.UI.WebControls.TextBox;
txt4ctch: System.Web.UI.WebControls.TextBox;
txt3ctch: System.Web.UI.WebControls.TextBox;
txt2ctch: System.Web.UI.WebControls.TextBox;
txt1Amtch: System.Web.UI.WebControls.TextBox;
txt1anotch: System.Web.UI.WebControls.TextBox;
txtbistch: System.Web.UI.WebControls.TextBox;
Panel39: System.Web.UI.WebControls.Panel;
Panel40: System.Web.UI.WebControls.Panel;
lblCabecalhoDadosTecnologicos: System.Web.UI.WebControls.Label;
lblSubPolCana: System.Web.UI.WebControls.Label;
lblSubATR: System.Web.UI.WebControls.Label;
lblSubFibraCana: System.Web.UI.WebControls.Label;
lblMaisFornecedores: System.Web.UI.WebControls.Label;
txtPolCanaManual: System.Web.UI.WebControls.TextBox;
txtATRMecanica: System.Web.UI.WebControls.TextBox;
txtPolCanaTotal: System.Web.UI.WebControls.TextBox;
txtATRTotal: System.Web.UI.WebControls.TextBox;
txtATRManual: System.Web.UI.WebControls.TextBox;
txtPolCanaMecanica: System.Web.UI.WebControls.TextBox;
Panel41: System.Web.UI.WebControls.Panel;
Panel42: System.Web.UI.WebControls.Panel;
lblManualPolCana: System.Web.UI.WebControls.Label;
lblMecanicaPolCana: System.Web.UI.WebControls.Label;
Panel43: System.Web.UI.WebControls.Panel;
Panel44: System.Web.UI.WebControls.Panel;
lblTotalPolCana: System.Web.UI.WebControls.Label;
Panel45: System.Web.UI.WebControls.Panel;
Panel46: System.Web.UI.WebControls.Panel;
lblManualATR: System.Web.UI.WebControls.Label;
lblMecanicaATR: System.Web.UI.WebControls.Label;
lblTotalATR: System.Web.UI.WebControls.Label;
Panel47: System.Web.UI.WebControls.Panel;
Panel48: System.Web.UI.WebControls.Panel;
txtFibraCanaTotal: System.Web.UI.WebControls.TextBox;
txtFibraCanaMecanica: System.Web.UI.WebControls.TextBox;
txtFibraCanaManual: System.Web.UI.WebControls.TextBox;
Panel49: System.Web.UI.WebControls.Panel;
Panel50: System.Web.UI.WebControls.Panel;
lblManualFibraCana: System.Web.UI.WebControls.Label;
lblMecanicaFibraCana: System.Web.UI.WebControls.Label;
lblTotalFibraCana: System.Web.UI.WebControls.Label;
Panel51: System.Web.UI.WebControls.Panel;
Panel52: System.Web.UI.WebControls.Panel;
lblMensagemAsterisco: System.Web.UI.WebControls.Label;
Panel53: System.Web.UI.WebControls.Panel;
Panel54: System.Web.UI.WebControls.Panel;
lblMensagem7corte: System.Web.UI.WebControls.Label;
Panel55: System.Web.UI.WebControls.Panel;
lblMensagemMaisFornecedor: System.Web.UI.WebControls.Label;
Panel56: System.Web.UI.WebControls.Panel;
btnGravarDados: C1.Web.C1Command.C1WebToolBarButton;
tblGravarDados: C1.Web.C1Command.C1WebToolBar;
Panel4: System.Web.UI.WebControls.Panel;
btnCarregarPlanilha: C1.Web.C1Command.C1WebToolBarButton;
tblCarregarPlanilha: C1.Web.C1Command.C1WebToolBar;
Panel57: System.Web.UI.WebControls.Panel;
Label1: System.Web.UI.WebControls.Label;
File1: System.Web.UI.HtmlControls.HtmlInputFile;
ddlUsinas: System.Web.UI.WebControls.DropDownList;
Panel58: System.Web.UI.WebControls.Panel;
Panel59: System.Web.UI.WebControls.Panel;
lblTxtNomeImportado: System.Web.UI.WebControls.Label;
Panel60: System.Web.UI.WebControls.Panel;
Panel61: System.Web.UI.WebControls.Panel;
lblNomeImportado: System.Web.UI.WebControls.Label;
Panel62: System.Web.UI.WebControls.Panel;
Panel63: System.Web.UI.WebControls.Panel;
ckbSobrepor: System.Web.UI.WebControls.CheckBox;
Panel64: System.Web.UI.WebControls.Panel;
lblMensagemCelulas: System.Web.UI.WebControls.Label;
Panel65: System.Web.UI.WebControls.Panel;
Panel66: System.Web.UI.WebControls.Panel;
lblMajorMessage: System.Web.UI.WebControls.Label;
lblMajorMessage02: System.Web.UI.WebControls.Label;
Label4: System.Web.UI.WebControls.Label;
MB1: ControleMessageBox.MessageBox;
Panel67: System.Web.UI.WebControls.Panel;
Panel68: System.Web.UI.WebControls.Panel;
Panel69: System.Web.UI.WebControls.Panel;
procedure OnInit(e: EventArgs); override;
private
procedure LimpaCampos;
procedure GravarDados;
procedure ImportarXLSOriginal(ps_nomearquivo: string);
procedure ImportarTXT(ps_nomearquivo: string);
public
{ Public Declarations }
end;
implementation
uses UTiposDados, uDM, uBiblioteca, C1.C1Excel;
{$REGION 'Designer Managed Code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure TWebForm1.InitializeComponent;begin
Include(Self.ddlUsinas.SelectedIndexChanged, Self.ddlUsinas_SelectedIndexChanged);
end;
procedure TWebForm1.LimpaCampos;
var c,ct :Control;begin
for c in (pnlPrincipalBaixo.Controls) do
if (c is System.Web.UI.WebControls.Panel) then
for ct in (c.Controls) do
if (ct is System.Web.UI.WebControls.TextBox) then
System.Web.UI.WebControls.TextBox(ct).Text := '';
end;
{$ENDREGION}
procedure TWebForm1.Page_Load(sender: System.Object; e: System.EventArgs);
var dtr: BdpDataReader;
DM: TDataModule;
lo_controleinterno :TControlesInternos;
begin
if not IsPostBack then
begin
Session['Mensagem1'] := 'Total própria da CANA PROCESSADA "MOÍDA" (t) por Tempo de Queima não confere com a Cana Própria acima - Cana Processada "moída" (t).....Continuar mesmo assim?';
Session['Mensagem2'] := 'Total própria da Colheita (tipos de corte e condição de corte) não confere com a Cana Própria acima - Cana Processada "moída" (t).....Continuar mesmo assim?';
Session['Mensagem3'] := 'O valor de Impureza Mineral Manual (%) está fora dos parâmetros normais..... Continua mesmo assim?';
Session['Mensagem4'] := 'O valor de Impureza Mineral Mecânica (%) está fora dos parâmetros normais..... Continua mesmo assim?';
Session['Mensagem5'] := 'O valor de Impureza Vegetal Manual (%) está fora dos parâmetros normais..... Continua mesmo assim?';
Session['Mensagem6'] := 'O valor de Impureza Vegetal Mecânica (%) está fora dos parâmetros normais..... Continua mesmo assim?';
Session['Mensagem7'] := 'O valor de Pol % Cana Manual está fora dos parâmetros normais..... Continua assim mesmo?';
Session['Mensagem8'] := 'O valor de Pol % Cana Mecânica está fora dos parâmetros normais..... Continua assim mesmo?';
Session['Mensagem9'] := 'O valor de ATR (Kg/t) Manual está fora dos parâmetros normais..... Continua assim mesmo?';
Session['Mensagem10'] := 'O valor de ATR (Kg/t) Mecânica está fora dos parâmetros normais..... Continua assim mesmo?';
Session['Mensagem11'] := 'O valor de Fibra % Cana Manual está fora dos parâmetros normais..... Continua assim mesmo?';
Session['Mensagem12'] := 'O valor de Fibra % Cana Mecânica está fora dos parâmetros normais..... Continua assim mesmo?';
Session['Mensagem13'] := 'O valor da Idade Média de Corte está fora dos parâmetros normais..... Continua assim mesmo?';
Session['Mensagem14'] := 'O valor do Número Médio de Corte está fora dos parâmetros normais..... Continua assim mesmo?';
Session['Mensagem15'] := 'O valor da Eficiência Industrial (%) está fora dos parâmetros normais..... Continua assim mesmo?';
Session['Mensagem16'] := 'O valor de Corte Manual (t/homem/dia) está fora dos parâmetros normais..... Continua assim mesmo?';
Session['Mensagem17'] := 'O valor de Corte Mecanizado (t/máq/dia) está fora dos parâmetros normais..... Continua assim mesmo?';
Session['Mensagem18'] := 'O valor do Tempo Médio de Queima (h) está fora dos parâmetros normais..... Continua assim mesmo?';
ControleInterfaceBotaoOK(tblGravarDados,true);
ControleInterfaceBotaoRelatorio(tblCarregarPlanilha,true);
//tblGravarDados.Visible := false;
DM := TDataModule.Create;
try
//dtr := DM.GetSafras(ddlSafra,cn_Safras);
dtr := DM.GetTodasSafras(ddlSafra);
ddlSafra.Items.Clear;
while dtr.Read do
begin
ddlSafra.Items.Add(dtr.Item['SAFRA'].ToString);
end;
dtr.Close;
RetornaControlesInternos(Self,Perfil(Session.Item['PerfilUser'].ToString), lo_controleinterno);
CarregarUsinasComCodigo(ddlUsinas,DM.GetUsinas(ddlUsinas,lo_controleinterno,true));
finally
DM.CloseConnection;
end;
end;
end;
procedure TWebForm1.OnInit(e: EventArgs);
begin
//
// Required for Designer support
//
InitializeComponent;
inherited OnInit(e);
end;
procedure TWebForm1.txtCodUsina_TextChanged(sender: System.Object; e: System.EventArgs);
var l:ListItem;
begin
l := ddlUsinas.Items.FindByValue(txtCodUsina.Text);
if (l <> nil) then
begin
with ddlUsinas do
SelectedIndex := Items.IndexOf(Items.FindByValue(l.Value));
end
else
begin
ExibeMensagem(Page,'Não existe Usina cadastrada com esse código');
txtCodUsina.Text := ddlUsinas.Items[ddlUsinas.SelectedIndex].Value;
end;
end;
procedure TWebForm1.ddlUsinas_SelectedIndexChanged(sender: System.Object; e: System.EventArgs);
begin
txtCodUsina.Text := ddlUsinas.Items[ddlUsinas.SelectedIndex].Value;
end;
procedure TWebForm1.ImportarXLSOriginal(ps_nomearquivo :string);
const
Letras = ['a'..'z'];
var
bookN: C1XLBook;
aux :string;
l :ListItem;
T :TDateTime;
begin
//trazendo os dados do arquivo "baixado" para a tela...
bookN := C1XLBook.Create;
bookN.Load(Server.MapPath('uploads\' + ps_nomearquivo));
with bookN.Sheets[0] do
begin
// txtUsina.Text := ValorCelulaPlanilha(GetCell(8,1));
txtAno.Text := ValorCelulaPlanilha(GetCell(8,5));
//tratamento do mês
aux := ValorCelulaPlanilha(GetCell(12,5)).ToLower;
if length(aux) > 0 then
if aux[1] in Letras then
aux := chr(ord(aux[1])-32) + copy(aux,2,length(aux));
l := ddlMes.Items.FindByText(aux);
if (l.Value <> nil) then
with ddlMes do
SelectedIndex := Items.IndexOf(Items.FindByValue(l.Value));
//tratamento da safra, já que vem com o ano '2007/2008' e tem que selecionar '07/08'
aux := ValorCelulaPlanilha(GetCell(10,5));
if Length(aux) >= 9 then
begin
aux := copy(aux,3,2) + '/' + copy(aux,8,2); //só dois últimos digitos do primeiro ano
l := ddlSafra.Items.FindByText(aux);
if (l.Value.ToString <> '') then
with ddlSafra do
SelectedIndex := Items.IndexOf(Items.FindByText(l.Value));
end;
T := Convert.ToDateTime(ValorCelulaPlanilha(GetCell(11,2)));
txtInicioMoagem.Text := CompletaString(T.Day.ToString,2,'0') + '/' + CompletaString(T.Month.ToString,2,'0') + '/' + T.Year.ToString;
T := Convert.ToDateTime(ValorCelulaPlanilha(GetCell(12,2)));
txtFimMoagem.Text := CompletaString(T.Day.ToString,2,'0') + '/' + CompletaString(T.Month.ToString,2,'0') + '/' + T.Year.ToString;
// txtChuva.Text := ValorCelulaPlanilha(GetCell(14,1),'0');
txtChuva.Text := ValorCelulaPlanilha(GetCell(14,1));
txtEficienciaIndustrial.Text := ValorCelulaPlanilha(GetCell(14,5),'0');
txtCorteManual.Text := ValorCelulaPlanilha(GetCell(16,5),'0');
txtCorteMec.Text := ValorCelulaPlanilha(GetCell(16,1),'0');
txtPropriaMoida.Text := ValorCelulaPlanilha(GetCell(20,0),'0');
txtFornecedores.Text := ValorCelulaPlanilha(GetCell(20,1),'0');
txtOutrasMoida.Text := ValorCelulaPlanilha(GetCell(20,2),'0');
txtTotalGeralMoida.Text := ValorCelulaPlanilha(GetCell(20,3),'0');
txtNumeroMedioCorte.Text := ValorCelulaPlanilha(GetCell(18,5),'0');
txtIdadeMediaCorte.Text := ValorCelulaPlanilha(GetCell(20,5),'0');
txtCanaCrua.Text := ValorCelulaPlanilha(GetCell(26,1),'0');
txtImpurezaMineralManual.Text := ValorCelulaPlanilha(GetCell(25,4),'0');
txtImpurezaMineralMecanica.Text := ValorCelulaPlanilha(GetCell(25,5),'0');
txtImpurezaVegetalManual.Text := ValorCelulaPlanilha(GetCell(26,4),'0');
txtImpurezaVegetalMecanica.Text := ValorCelulaPlanilha(GetCell(26,5),'0');
txt01a24h.Text := ValorCelulaPlanilha(GetCell(31,0),'0');
txt24a48h.Text := ValorCelulaPlanilha(GetCell(31,1),'0');
txt48a72h.Text := ValorCelulaPlanilha(GetCell(31,2),'0');
txtMais72h.Text := ValorCelulaPlanilha(GetCell(31,3),'0');
txtTotalMoidaTempoQueima.Text := ValorCelulaPlanilha(GetCell(31,4),'0');
txtTempoMedio.Text := ValorCelulaPlanilha(GetCell(31,5),'0');
txtColheitaManualSQueimar.Text := ValorCelulaPlanilha(GetCell(37,1),'0');
txtColheitaManualQueimada.Text := ValorCelulaPlanilha(GetCell(37,2),'0');
txtColheitaMecanicaSQueimar.Text := ValorCelulaPlanilha(GetCell(37,3),'0');
txtColheitaMecanicaQueimada.Text := ValorCelulaPlanilha(GetCell(37,4),'0');
txtTotalColheita.Text := ValorCelulaPlanilha(GetCell(37,5),'0');
txtBisArea.Text := ValorCelulaPlanilha(GetCell(42,1),'0');
txt1AnoArea.Text := ValorCelulaPlanilha(GetCell(43,1),'0');
txt1AmArea.Text := ValorCelulaPlanilha(GetCell(44,1),'0');
txt2CArea.Text := ValorCelulaPlanilha(GetCell(45,1),'0');
txt3CArea.Text := ValorCelulaPlanilha(GetCell(46,1),'0');
txt4CArea.Text := ValorCelulaPlanilha(GetCell(47,1),'0');
txt5CArea.Text := ValorCelulaPlanilha(GetCell(48,1),'0');
txt6CArea.Text := ValorCelulaPlanilha(GetCell(49,1),'0');
txtTotalMediaArea.Text := ValorCelulaPlanilha(GetCell(50,1),'0');
txtbistch.Text := ValorCelulaPlanilha(GetCell(42,2),'0');
txt1anotch.Text := ValorCelulaPlanilha(GetCell(43,2),'0');
txt1Amtch.Text := ValorCelulaPlanilha(GetCell(44,2),'0');
txt2ctch.Text := ValorCelulaPlanilha(GetCell(45,2),'0');
txt3ctch.Text := ValorCelulaPlanilha(GetCell(46,2),'0');
txt4ctch.Text := ValorCelulaPlanilha(GetCell(47,2),'0');
txt5ctch.Text := ValorCelulaPlanilha(GetCell(48,2),'0');
txt6ctch.Text := ValorCelulaPlanilha(GetCell(49,2),'0');
txtTotalMediatch.Text := ValorCelulaPlanilha(GetCell(50,2),'0');
txtPolCanaManual.Text := ValorCelulaPlanilha(GetCell(44,3),'0');
txtPolCanaMecanica.Text := ValorCelulaPlanilha(GetCell(44,4),'0');
txtPolCanaTotal.Text := ValorCelulaPlanilha(GetCell(44,5),'0');
txtATRManual.Text := ValorCelulaPlanilha(GetCell(47,3),'0');
txtATRMecanica.Text := ValorCelulaPlanilha(GetCell(47,4),'0');
txtATRTotal.Text := ValorCelulaPlanilha(GetCell(47,5),'0');
txtFibraCanaManual.Text := ValorCelulaPlanilha(GetCell(50,3),'0');
txtFibraCanaMecanica.Text := ValorCelulaPlanilha(GetCell(50,4),'0');
txtFibraCanaTotal.Text := ValorCelulaPlanilha(GetCell(50,5),'0');
lblNomeImportado.Text := ValorCelulaPlanilha(GetCell(8,1)) +
' (selecione na lista acima a Usina correta)';
lblTxtNomeImportado.Visible := true;
lblNomeImportado.Visible := true;
end;
bookN.Free;
end;
procedure TWebForm1.ImportarTXT(ps_nomearquivo :string);
var st :TStringList;
s :string;
begin
st := TStringList.Create;
st.LoadFromFile(Server.MapPath('uploads\' + ps_nomearquivo));
try
try
s := st[0];
except
exit;
end;
//pegando dados da string s e jogando nos componentes visuais, segundo layout
ddlSafra.SelectedValue := LeDadoLayoutProducao(s,51,5); //safra
txtAno.Text := LeDadoLayoutProducao(s,56,4); //ano
ddlMes.SelectedIndex := convert.ToInt32(LeDadoLayoutProducao(s,60,2))-1; //mês
txtInicioMoagem.Text := LeDadoLayoutProducao(s,62,10); //inicio moagem
txtFimMoagem.Text := LeDadoLayoutProducao(s,72,10); //fim moagem
txtChuva.Text := LeDadoLayoutProducao(s,82,6); //chuva
txtEficienciaIndustrial.Text := LeDadoLayoutProducao(s,88,5); //eficiência industrial
txtCorteMec.Text := LeDadoLayoutProducao(s,93,6); //corte mec.
txtCorteManual.Text := LeDadoLayoutProducao(s,99,6); //corte man.
txtPropriaMoida.Text := LeDadoLayoutProducao(s,105,11); //cana proc. moida (total própria)
txtFornecedores.Text := LeDadoLayoutProducao(s,116,11); //cana proc. moida (fornecedores)
txtOutrasMoida.Text := LeDadoLayoutProducao(s,127,11); //cana proc. moida (outras)
txtTotalGeralMoida.Text := convert.ToString(
Convert.ToDouble(txtPropriaMoida.Text) +
Convert.ToDouble(txtFornecedores.Text) +
Convert.ToDouble(txtOutrasMoida.Text)
);
txtNumeroMedioCorte.Text := LeDadoLayoutProducao(s,138,4); //n. médio corte
txtIdadeMediaCorte.Text := LeDadoLayoutProducao(s,142,4); //idade media corte
txtCanaCrua.Text := LeDadoLayoutProducao(s,146,11); //cana moida crua
txtImpurezaMineralManual.Text := LeDadoLayoutProducao(s,157,4); //imp. min. man.
txtImpurezaMineralMecanica.Text := LeDadoLayoutProducao(s,161,4); //imp. min. mec.
txtImpurezaVegetalManual.Text := LeDadoLayoutProducao(s,165,4); //imp. veg. man.
txtImpurezaVegetalMecanica.Text := LeDadoLayoutProducao(s,169,4); //imp. veg. mec.
txt01a24h.Text := LeDadoLayoutProducao(s,173,10); //cana proc moida tempo queima 0-24h
txt24a48h.Text := LeDadoLayoutProducao(s,183,10); //cana proc moida tempo queima 24-48h
txt48a72h.Text := LeDadoLayoutProducao(s,193,10); //cana proc moida tempo queima 48-72h
txtMais72h.Text := LeDadoLayoutProducao(s,203,10); //cana proc moida tempo queima +72h
txtTotalMoidaTempoQueima.Text := convert.ToString(
Convert.ToDouble(txt01a24h.Text) +
Convert.ToDouble(txt24a48h.Text) +
Convert.ToDouble(txt48a72h.Text) +
Convert.ToDouble(txtMais72h.Text)
);
txtTempoMedio.Text := LeDadoLayoutProducao(s,213,5); //tempo médio
txtColheitaManualSQueimar.Text := LeDadoLayoutProducao(s,218,10); //colheita manual s/ queimar
txtColheitaManualQueimada.Text := LeDadoLayoutProducao(s,228,10); //colheita manual queimada
txtColheitaMecanicaSQueimar.Text := LeDadoLayoutProducao(s,238,10); //colheita mecanica s/ queimar
txtColheitaMecanicaQueimada.Text := LeDadoLayoutProducao(s,248,10); //colheita mecanica queimada
txtTotalColheita.Text := convert.ToString(
Convert.ToDouble(txtColheitaManualSQueimar.Text) +
Convert.ToDouble(txtColheitaManualQueimada.Text) +
Convert.ToDouble(txtColheitaMecanicaSQueimar.Text) +
Convert.ToDouble(txtColheitaMecanicaQueimada.Text)
);
txtBisArea.Text := LeDadoLayoutProducao(s,258,8); //Cana Colhida no mês – Área (Cana Bis)
txt1AnoArea.Text := LeDadoLayoutProducao(s,266,8); //Cana Colhida no mês – Área (Cana 1ano)
txt1AmArea.Text := LeDadoLayoutProducao(s,274,8); //Cana Colhida no mês – Área (Cana 1am)
txt2CArea.Text := LeDadoLayoutProducao(s,282,8); //Cana Colhida no mês – Área (Cana 2c)
txt3CArea.Text := LeDadoLayoutProducao(s,290,8); //Cana Colhida no mês – Área (Cana 3c)
txt4CArea.Text := LeDadoLayoutProducao(s,298,8); //Cana Colhida no mês – Área (Cana 4c)
txt5CArea.Text := LeDadoLayoutProducao(s,306,8); //Cana Colhida no mês – Área (Cana 5c)
txt6CArea.Text := LeDadoLayoutProducao(s,314,8); //Cana Colhida no mês – Área (Cana 6c+)
txtTotalMediaArea.Text := convert.ToString(
Convert.ToDouble(txtBisArea.Text) +
Convert.ToDouble(txt1AnoArea.Text) +
Convert.ToDouble(txt1AmArea.Text) +
Convert.ToDouble(txt2CArea.Text) +
Convert.ToDouble(txt3CArea.Text) +
Convert.ToDouble(txt4CArea.Text) +
Convert.ToDouble(txt5CArea.Text) +
Convert.ToDouble(txt6CArea.Text)
);
txtbistch.Text := LeDadoLayoutProducao(s,322,8); //Cana Colhida no mês – TCH (Cana Bis)
txt1anotch.Text := LeDadoLayoutProducao(s,330,8); //Cana Colhida no mês – TCH (Cana 1ano)
txt1Amtch.Text := LeDadoLayoutProducao(s,338,8); //Cana Colhida no mês – TCH (Cana 1am)
txt2ctch.Text := LeDadoLayoutProducao(s,346,8); //Cana Colhida no mês – TCH (Cana 2c)
txt3ctch.Text := LeDadoLayoutProducao(s,354,8); //Cana Colhida no mês – TCH (Cana 3c)
txt4ctch.Text := LeDadoLayoutProducao(s,362,8); //Cana Colhida no mês – TCH (Cana 4c)
txt5ctch.Text := LeDadoLayoutProducao(s,370,8); //Cana Colhida no mês – TCH (Cana 5c)
txt6ctch.Text := LeDadoLayoutProducao(s,378,8); //Cana Colhida no mês – TCH (Cana 6c+)
txtTotalMediatch.Text := convert.ToString(
Convert.ToDouble(txtbistch.Text) +
Convert.ToDouble(txt1anotch.Text) +
Convert.ToDouble(txt1Amtch.Text) +
Convert.ToDouble(txt2ctch.Text) +
Convert.ToDouble(txt3ctch.Text) +
Convert.ToDouble(txt4ctch.Text) +
Convert.ToDouble(txt5ctch.Text) +
Convert.ToDouble(txt6ctch.Text)
);
txtPolCanaManual.Text := LeDadoLayoutProducao(s,386,5); //pol % cana man
txtPolCanaMecanica.Text := LeDadoLayoutProducao(s,391,5); //pol % cana mec
txtPolCanaTotal.Text := LeDadoLayoutProducao(s,396,5); //pol % cana tot
txtATRManual.Text := LeDadoLayoutProducao(s,401,6); //atr man
txtATRMecanica.Text := LeDadoLayoutProducao(s,407,6); //atr mec
txtATRTotal.Text := LeDadoLayoutProducao(s,413,6); //atr tot
txtFibraCanaManual.Text := LeDadoLayoutProducao(s,419,5); //fibra % cana man
txtFibraCanaMecanica.Text := LeDadoLayoutProducao(s,424,5); //fibra % cana mec
txtFibraCanaTotal.Text := LeDadoLayoutProducao(s,429,5); //fibra % cana tot
lblNomeImportado.Text := LeDadoLayoutProducao(s,1,50) + ' (selecione na lista acima a Usina correta)';
lblTxtNomeImportado.Visible := true;
lblNomeImportado.Visible := true;
finally
st.Free;
end;
end;
procedure TWebForm1.Button1_Click(sender: System.Object; e: System.EventArgs);
var doc: TXMLDocument;
Elem: XmlElement;
begin
doc := TXMLDocument.Create();
doc.LoadFromFile('c:\CTC_VARIEDADES.XML');
// Elem := doc.DocumentElement;
end;
procedure TWebForm1.btnCarregarPlanilha_Click(sender: System.Object; e: System.EventArgs);
var
T :TDateTime;
nomearquivo: string;
function TipoArquivo(ps_nomearq :string) :string;
begin
if pos('.xls',ps_nomearq) > 0 then
result := '.xls'
else
result := '.txt';
end;
begin
//fazendo upload do arquivo selecionado
if (File1.PostedFile.FileName = '') then
begin
ExibeMensagem(Page,'Selecione um arquivo válido para importação');
exit;
end
else
begin
if Assigned(File1.PostedFile) then
begin
T := System.DateTime.get_Now;
nomearquivo := CompletaString(T.Day.ToString,2,'0') +
CompletaString(T.Month.ToString,2,'0') +
CompletaString(T.Year.ToString,2,'0') +
CompletaString(T.Hour.ToString,2,'0') +
CompletaString(T.Minute.ToString,2,'0') +
CompletaString(T.Second.ToString,2,'0') +
CompletaString(T.MilliSecond.ToString,3,'0') + TipoArquivo(File1.PostedFile.FileName); //'.xls';
try
File1.PostedFile.SaveAs(Server.MapPath('uploads\' + nomearquivo));
ExibeMensagem(Page,'Arquivo transferido com sucesso !');
except
ExibeMensagem(Page,'Falha ao transferir Arquivo');
exit;
end;
end;
end;
//puxando os dados dos respectivos arquivos
if TipoArquivo(nomearquivo) = '.xls' then
ImportarXLSOriginal(nomearquivo)
else
ImportarTXT(nomearquivo);
tblGravarDados.Visible := true;
nomearquivo := Server.MapPath('uploads\' + nomearquivo);
&File.Delete(nomearquivo);
end;
procedure TWebForm1.GravarDados;
var lo_DadosPlanilhaProducao :TDadosPlanilhaProducao;
DM: TDataModule;
lr_aux :Real;begin
with lo_DadosPlanilhaProducao do
begin
CodUsina := txtCodUsina.Text;
Safra := ddlSafra.SelectedItem.Text;
Ano := txtAno.Text;
Mes := ddlMes.SelectedItem.Value;
DtIniMoagem := txtInicioMoagem.Text;
DtFimMoagem := txtFimMoagem.Text;
Chuva := txtChuva.Text;
Efind := txtEficienciaIndustrial.Text;
CorteManual := txtCorteManual.Text;
CorteMec := txtCorteMec.Text;
CanaPropria := txtPropriaMoida.Text;
CanaFornec := txtFornecedores.Text;
CanaOutras := txtOutrasMoida.Text;
CanaTotal := txtTotalGeralMoida.Text;
NumMedCorte := txtNumeroMedioCorte.Text;
IdadeMedCorte := txtIdadeMediaCorte.Text;
CanaMoidaCrua := txtCanaCrua.Text;
ImpMinMan := txtImpurezaMineralManual.Text;
ImpMinMec := txtImpurezaMineralMecanica.Text;
ImpVegMan := txtImpurezaVegetalManual.Text;
ImpVegMec := txtImpurezaVegetalMecanica.Text;
CanaMoida0124 := txt01a24h.Text;
CanaMoida2448 := txt24a48h.Text;
CanaMoida4872 := txt48a72h.Text;
CanaMoida72 := txtMais72h.Text;
CanaMoidaTotal := txtTotalMoidaTempoQueima.Text;
TempoMedio := txtTempoMedio.Text;
ColheitaMan := txtColheitaManualSQueimar.Text;
ColheitaManQueimada := txtColheitaManualQueimada.Text;
ColheitaMec := txtColheitaMecanicaSQueimar.Text;
ColheitaMecQueimada := txtColheitaMecanicaQueimada.Text;
TotalColheita := txtTotalColheita.Text;
AreaBis := txtBisArea.Text;
AreaAno := txt1AnoArea.Text;
AreaAm := txt1AmArea.Text;
Area2c := txt2CArea.Text;
Area3c := txt3CArea.Text;
Area4c := txt4CArea.Text;
Area5c := txt5CArea.Text;
Area6c := txt6CArea.Text;
AreaTotal := txtTotalMediaArea.Text;
TchBis := txtbistch.Text;
TchAno := txt1anotch.Text;
TchAm := txt1Amtch.Text;
Tch2c := txt2ctch.Text;
Tch3c := txt3ctch.Text;
Tch4c := txt4ctch.Text;
Tch5c := txt5ctch.Text;
Tch6c := txt6ctch.Text;
Tch := txtTotalMediatch.Text;
PolCanaMan := txtPolCanaManual.Text;
PolCanaMec := txtPolCanaMecanica.Text;
PolCanaTotal := txtPolCanaTotal.Text;
AtrMan := txtATRManual.Text;
AtrMec := txtATRMecanica.Text;
AtrTotal := txtATRTotal.Text;
FibraCanaMan := txtFibraCanaManual.Text;
FibraCanaMec := txtFibraCanaMecanica.Text;
FibraCanaTotal := txtFibraCanaTotal.Text;
//****** campos calculados ********//
//POLCANAPRÓPRIA - MEDIA ARITMETICA
if (txtColheitaManualSQueimar.Text = '0') and (txtColheitaManualQueimada.Text = '0') and
(txtColheitaMecanicaSQueimar.Text = '0') and (txtColheitaMecanicaQueimada.Text = '0') then
lr_aux := (Convert.toDouble(PolCanaMan) + Convert.toDouble(PolCanaMec))/2
//POLCANAPRÓPRIA - MEDIA PONDERADA
else
lr_aux := (((Convert.toDouble(ColheitaMan) + Convert.toDouble(ColheitaManQueimada))
* Convert.toDouble(PolCanaMan))
+
((Convert.toDouble(ColheitaMec) + Convert.toDouble(ColheitaMecQueimada))
* Convert.toDouble(PolCanaMec)))
/
(Convert.toDouble(TotalColheita));
PolCanaPropria := Convert.ToString(lr_aux);
//ATRPRÓPRIA - MEDIA ARITMETICA
if (txtColheitaManualSQueimar.Text = '0') and (txtColheitaManualQueimada.Text = '0') and
(txtColheitaMecanicaSQueimar.Text = '0') and (txtColheitaMecanicaQueimada.Text = '0') then
lr_aux := (Convert.toDouble(AtrMan) + Convert.toDouble(AtrMec))/2
//ATRPRÓPRIA - MEDIA PONDERADA
else
lr_aux := (((Convert.toDouble(ColheitaMan) + Convert.toDouble(ColheitaManQueimada))
* Convert.toDouble(AtrMan))
+
((Convert.toDouble(ColheitaMec) + Convert.toDouble(ColheitaMecQueimada))
* Convert.toDouble(AtrMec)))
/
(Convert.toDouble(TotalColheita));
AtrPropria := Convert.ToString(lr_aux);
//FIBRACANAPRÓPRIA - MEDIA ARITMETICA
if (txtColheitaManualSQueimar.Text = '0') and (txtColheitaManualQueimada.Text = '0') and
(txtColheitaMecanicaSQueimar.Text = '0') and (txtColheitaMecanicaQueimada.Text = '0') then
lr_aux := (Convert.toDouble(FibraCanaMan) + Convert.toDouble(FibraCanaMec))/2
//FIBRACANAPRÓPRIA - MEDIA PONDERADA
else
lr_aux := (((Convert.toDouble(ColheitaMan) + Convert.toDouble(ColheitaManQueimada))
* Convert.toDouble(FibraCanaMan))
+
((Convert.toDouble(ColheitaMec) + Convert.toDouble(ColheitaMecQueimada))
* Convert.toDouble(FibraCanaMec)))
/
(Convert.toDouble(TotalColheita));
FibraCanaPropria := Convert.ToString(lr_aux);
TPolPropria := Convert.ToString(Convert.toDouble(PolCanaPropria) * Convert.toDouble(TotalColheita));
TFibraPropria := Convert.ToString(Convert.toDouble(FibraCanaPropria) * Convert.toDouble(TotalColheita));
TAtrPropria := Convert.ToString(Convert.toDouble(AtrPropria) * Convert.toDouble(TotalColheita));
TonBis := Convert.ToString(Convert.toDouble(AreaBis) * Convert.toDouble(TchBis));
TonAno := Convert.ToString(Convert.toDouble(AreaAno) * Convert.toDouble(TchAno));
TonAm := Convert.ToString(Convert.toDouble(AreaAm) * Convert.toDouble(TchAm));
Ton2c := Convert.ToString(Convert.toDouble(Area2c) * Convert.toDouble(Tch2c));
Ton3c := Convert.ToString(Convert.toDouble(Area3c) * Convert.toDouble(Tch3c));
Ton4c := Convert.ToString(Convert.toDouble(Area4c) * Convert.toDouble(Tch4c));
Ton5c := Convert.ToString(Convert.toDouble(Area5c) * Convert.toDouble(Tch5c));
Ton6c := Convert.ToString(Convert.toDouble(Area6c) * Convert.toDouble(Tch6c));
TonTotal := Convert.ToString(Convert.toDouble(AreaTotal) * Convert.toDouble(Tch));
end;
DM := TDataModule.Create;
try
if DM.PlanilhaProducaoCadastrada(txtCodUsina,lo_DadosPlanilhaProducao) then
begin
if ckbSobrepor.Checked then
begin
if not DM.DeletePlanilhaProducao(lo_DadosPlanilhaProducao) then
begin
ExibeMensagem(Page,'Erro ao excluir Planilha. Operação abortada.');
exit;
end;
end
else
begin
ExibeMensagem(Page,'Planilha já cadastrada');
exit;
end;
end;
//se chegou aqui, é pq o Banco já está pronto para inserção
case DM.SetPlanilhaProducao(lo_DadosPlanilhaProducao) of
false: begin
ExibeMensagem(Page,'Erro ao inserir Planilha no Banco de Dados');
exit;
end;
end;//case
finally
DM.CloseConnection;
DM.Free;
end;
ExibeMensagem(Page,'Planilha cadastrada com sucesso !');
LimpaCampos;
tblGravarDados.Visible := false;
end;
procedure TWebForm1.MB1_YesChoosed(sender: System.Object; Key: string);
function fl_InRange(ps_key :string; ps_LimInf,ps_LimSup :string) :boolean;
var li_key, li_LimInf, li_LimSup :integer;
// i :integer;begin
li_key := Convert.ToInt32(ps_key);
li_LimInf := Convert.ToInt32(ps_LimInf);
li_LimSup := Convert.ToInt32(ps_LimSup);
result := (li_key >= li_LimInf) and (li_key <= li_LimSup);
// result := false;// for i := li_LimInf to li_LimSup do
// if li_key = i then
// begin
// result := true;
// break;
// end;
end;
begin
if fl_InRange(key,'1','1') and (txtPropriaMoida.Text <> txtTotalColheita.Text) then
MB1.ShowConfirmation(Session['Mensagem2'].ToString,
'2',
true,false)
else
if fl_InRange(key,'1','2') and (txtPropriaMoida.Text <> txtFornecedores.Text) then
MB1.ShowConfirmation(Session['Mensagem3'].ToString,
'3',
true,false)
else
if fl_InRange(key,'1','3') and (txtPropriaMoida.Text <> txtOutrasMoida.Text) then
MB1.ShowConfirmation(Session['Mensagem4'].ToString,
'4',
true,false)
else
if fl_InRange(key,'1','4') and (txtPropriaMoida.Text <> txtTotalColheita.Text) then
MB1.ShowConfirmation(Session['Mensagem5'].ToString,
'5',
true,false)
else
if fl_InRange(key,'1','5') and (txtPropriaMoida.Text <> txtFornecedores.Text) then
MB1.ShowConfirmation(Session['Mensagem6'].ToString,
'6',
true,false)
else
if fl_InRange(key,'1','6') and (txtPropriaMoida.Text <> txtOutrasMoida.Text) then
MB1.ShowConfirmation(Session['Mensagem7'].ToString,
'7',
true,false)
else
if fl_InRange(key,'1','7') and (txtPropriaMoida.Text <> txtTotalColheita.Text) then
MB1.ShowConfirmation(Session['Mensagem8'].ToString,
'8',
true,false)
else
if fl_InRange(key,'1','8') and (txtPropriaMoida.Text <> txtFornecedores.Text) then
MB1.ShowConfirmation(Session['Mensagem9'].ToString,
'9',
true,false)
else
if fl_InRange(key,'1','9') and (txtPropriaMoida.Text <> txtOutrasMoida.Text) then
MB1.ShowConfirmation(Session['Mensagem10'].ToString,
'2',
true,false)
else
if fl_InRange(key,'1','10') and (txtPropriaMoida.Text <> txtTotalColheita.Text) then
MB1.ShowConfirmation(Session['Mensagem11'].ToString,
'11',
true,false)
else
if fl_InRange(key,'1','11') and (txtPropriaMoida.Text <> txtFornecedores.Text) then
MB1.ShowConfirmation(Session['Mensagem12'].ToString,
'12',
true,false)
else
if fl_InRange(key,'1','12') and (txtPropriaMoida.Text <> txtOutrasMoida.Text) then
MB1.ShowConfirmation(Session['Mensagem13'].ToString,
'13',
true,false)
else
if fl_InRange(key,'1','13') and (txtPropriaMoida.Text <> txtTotalColheita.Text) then
MB1.ShowConfirmation(Session['Mensagem14'].ToString,
'14',
true,false)
else
if fl_InRange(key,'1','14') and (txtPropriaMoida.Text <> txtFornecedores.Text) then
MB1.ShowConfirmation(Session['Mensagem15'].ToString,
'15',
true,false)
else
if fl_InRange(key,'1','15') and (txtPropriaMoida.Text <> txtOutrasMoida.Text) then
MB1.ShowConfirmation(Session['Mensagem16'].ToString,
'16',
true,false)
else
if fl_InRange(key,'1','16') and (txtPropriaMoida.Text <> txtTotalColheita.Text) then
MB1.ShowConfirmation(Session['Mensagem17'].ToString,
'17',
true,false)
else
if fl_InRange(key,'1','17') and (txtPropriaMoida.Text <> txtFornecedores.Text) then
MB1.ShowConfirmation(Session['Mensagem18'].ToString,
'18',
true,false)
else
gravardados;
end;
(*
if (key='1') and (txtPropriaMoida.Text <> txtTotalColheita.Text) then
MB1.ShowConfirmation('Total própria da Colheita (tipos de corte e condição de corte) não confere com a Cana Própria acima - Cana Processada "moída" (t).....Continua mesmo assim?',
'2',
true,false)
else
if ((key='1') or (key='2')) and (txtPropriaMoida.Text <> txtFornecedores.Text) then
MB1.ShowConfirmation('FORNECEDORES.....Continua mesmo assim?',
'3',
true,false)
else
if ((key='1') or (key='2') or (key='3')) and (txtPropriaMoida.Text <> txtOutrasMoida.Text) then
MB1.ShowConfirmation('OUTRAS MOIDA.....Continua mesmo assim?',
'4',
true,false)
else
gravardados;
*)
(*
if key = '1' then
begin
if txtPropriaMoida.Text <> txtTotalColheita.Text then
begin
MB1.ShowConfirmation('Total própria da Colheita (tipos de corte e condição de corte) não confere com a Cana Própria acima - Cana Processada "moída" (t).....Continua mesmo assim?',
'2',
true,false)
end
else
if txtPropriaMoida.Text <> txtFornecedores.Text then
begin
MB1.ShowConfirmation('FORNECEDORES.....Continua mesmo assim?',
'3',
true,false)
end
else
if txtPropriaMoida.Text <> txtOutrasMoida.Text then
begin
MB1.ShowConfirmation('OUTRAS MOIDA.....Continua mesmo assim?',
'4',
true,false)
end
else
GravarDados;
end
else
if key = '2' then
begin
if txtPropriaMoida.Text <> txtFornecedores.Text then
begin
MB1.ShowConfirmation('FORNECEDORES.....Continua mesmo assim?',
'3',
true,false)
end
else
if txtPropriaMoida.Text <> txtOutrasMoida.Text then
begin
MB1.ShowConfirmation('OUTRAS MOIDA.....Continua mesmo assim?',
'4',
true,false)
end
else
GravarDados;
end
else
if key = '3' then
begin
if txtPropriaMoida.Text <> txtOutrasMoida.Text then
begin
MB1.ShowConfirmation('OUTRAS MOIDA.....Continua mesmo assim?',
'4',
true,false)
end
else
GravarDados;
end
else
if key = '4' then
begin
GravarDados;
end;*)
procedure TWebForm1.btnGravarDados_Click(sender: System.Object; e: System.EventArgs);
//var lo_DadosPlanilhaProducao :TDadosPlanilhaProducao;
// DM: TDataModule;
// lr_aux :Real;
begin
if txtCodUsina.Text = '' then
begin
ExibeMensagem(Page,'Selecione um código de Usina válido antes de Gravar');
SetFocus(txtCodUsina);
exit;
end;
// testando campus de acordo com as regras contidas na Macro da Planilha original
// para liberar os testes, colocar valor 1 na respectiva variável em Global.pas
if Session.Item['TestaMacros'].ToString = '1' then
begin
//totais de cana Própria
if txtPropriaMoida.Text <> txtTotalMoidaTempoQueima.Text then
MB1.ShowConfirmation(Session['Mensagem1'].ToString,
'1',
true,false)
else //totais de cana Própria da Colheita
if txtPropriaMoida.Text <> txtTotalColheita.Text then
MB1.ShowConfirmation(Session['Mensagem2'].ToString,
'2',
true,false)
else
if (Convert.ToDouble(txtImpurezaMineralManual.Text) < 0.1) or (Convert.ToDouble(txtImpurezaMineralManual.Text) > 5) then
MB1.ShowConfirmation(Session['Mensagem3'].ToString,
'3',
true,false)
else
if (Convert.ToDouble(txtImpurezaVegetalManual.Text) < 0.1) or (Convert.ToDouble(txtImpurezaVegetalManual.Text) > 5) then
MB1.ShowConfirmation(Session['Mensagem4'].ToString,
'4',
true,false)
else
if (Convert.ToDouble(txtImpurezaMineralMecanica.Text) < 1) or (Convert.ToDouble(txtImpurezaMineralMecanica.Text) > 15) then
MB1.ShowConfirmation(Session['Mensagem5'].ToString,
'5',
true,false)
else
if (Convert.ToDouble(txtImpurezaVegetalMecanica.Text) < 1) or (Convert.ToDouble(txtImpurezaVegetalMecanica.Text) > 15) then
MB1.ShowConfirmation(Session['Mensagem6'].ToString,
'6',
true,false)
else
if (Convert.ToDouble(txtPolCanaManual.Text) < 8) or (Convert.ToDouble(txtPolCanaManual.Text) > 20) then
MB1.ShowConfirmation(Session['Mensagem7'].ToString,
'7',
true,false)
else
if (Convert.ToDouble(txtPolCanaMecanica.Text) < 8) or (Convert.ToDouble(txtPolCanaMecanica.Text) > 20) then
MB1.ShowConfirmation(Session['Mensagem8'].ToString,
'8',
true,false)
else
if (Convert.ToDouble(txtATRManual.Text) < 100) or (Convert.ToDouble(txtATRManual.Text) > 180) then
MB1.ShowConfirmation(Session['Mensagem9'].ToString,
'9',
true,false)
else
if (Convert.ToDouble(txtATRMecanica.Text) < 100) or (Convert.ToDouble(txtATRMecanica.Text) > 180) then
MB1.ShowConfirmation(Session['Mensagem10'].ToString,
'10',
true,false)
else
if (Convert.ToDouble(txtFibraCanaManual.Text) < 9) or (Convert.ToDouble(txtFibraCanaManual.Text) > 19) then
MB1.ShowConfirmation(Session['Mensagem11'].ToString,
'11',
true,false)
else
if (Convert.ToDouble(txtFibraCanaMecanica.Text) < 9) or (Convert.ToDouble(txtFibraCanaMecanica.Text) > 19) then
MB1.ShowConfirmation(Session['Mensagem12'].ToString,
'12',
true,false)
else
if (Convert.ToDouble(txtIdadeMediaCorte.Text) < 9) or (Convert.ToDouble(txtIdadeMediaCorte.Text) > 20) then
MB1.ShowConfirmation(Session['Mensagem13'].ToString,
'13',
true,false)
else
if (Convert.ToDouble(txtNumeroMedioCorte.Text) < 1) or (Convert.ToDouble(txtNumeroMedioCorte.Text) > 6) then
MB1.ShowConfirmation(Session['Mensagem14'].ToString,
'14',
true,false)
else
if (Convert.ToDouble(txtEficienciaIndustrial.Text) < 50) or (Convert.ToDouble(txtEficienciaIndustrial.Text) > 99) then
MB1.ShowConfirmation(Session['Mensagem15'].ToString,
'15',
true,false)
else
if (Convert.ToDouble(txtCorteManual.Text) < 5) or (Convert.ToDouble(txtCorteManual.Text) > 15) then
MB1.ShowConfirmation(Session['Mensagem16'].ToString,
'16',
true,false)
else
if (Convert.ToDouble(txtCorteMec.Text) < 150) or (Convert.ToDouble(txtCorteMec.Text) > 900) then
MB1.ShowConfirmation(Session['Mensagem17'].ToString,
'17',
true,false)
else
if (Convert.ToDouble(txtTempoMedio.Text) < 20) or (Convert.ToDouble(txtTempoMedio.Text) > 100) then
MB1.ShowConfirmation(Session['Mensagem18'].ToString,
'18',
true,false)
else
GravarDados;
end
else //if Session.TestaMacros
GravarDados;
end;
//antes de fazer upload, havia um edit que recebia o nome do arquivo selecionado
//em File1. no "onchange" do file1 tinha: this.form.elements.txtArquivo.value = this.value
end.
Acho pelo eu vi, a rotina está normal mas por ser novato em delphi eu não sei se há alguma "manha" que eu não esteja vendo e que esteja impactando no sistema. Como esse programa roda via web eu acho que uma das possíveis causas é o estouro no tempo de execução do servidor.
Discussão (8)
Carregando comentários...