protected void btnIncluir_Click(object sender, EventArgs e) { if (!btnIncluir.Text.Equals("Excluir")) { Response.Redirect("~/CadastroRelatorioVisita.aspx?IdRel=incluir"); } else { StringBuilder str = new StringBuilder(); str.Append("DELETE FROM LANCREL "); str.Append("WHERE (NR_LANC = '" + Request.QueryString["ID"].ToString().Substring(0, 7) + "')"); FbCommand cmdDelete = (FbCommand)HlpBancoDados.CommandSelect(str.ToString()); cmdDelete.Connection.Open(); int iSucesso = cmdDelete.ExecuteNonQuery(); cmdDelete.Connection.Close(); if (iSucesso > 0) { Response.Redirect("~/Default.aspx"); } else { Response.Redirect("~/Confirmacao.aspx?ID=" + Request.QueryString["ID"].ToString().Substring(0, 7) + ",N"); } } }
protected bool GetOrdemServico(string sCD_OS) { StringBuilder strOs = new StringBuilder(); bool bRet = false; strOs.Append("SELECT ORDEMSER.CD_OS, ORDEMSER.NM_GUERRA "); strOs.Append("FROM ORDEMSER "); strOs.Append("WHERE CD_OS = '" + sCD_OS + "' "); strOs.Append("ORDER BY ORDEMSER.CD_OS"); FbCommand fbSelect = (FbCommand)HlpBancoDados.CommandSelect(strOs.ToString()); fbSelect.Connection.Open(); FbDataReader drResultado = fbSelect.ExecuteReader(); if (drResultado.Read()) { bRet = true; } else { bRet = false; } drResultado.Close(); fbSelect.Connection.Close(); return(bRet); }
protected DataTable GetTecnico() { StringBuilder strTecnico = new StringBuilder(); strTecnico.Append("SELECT ACESSO.NM_OPERADO, ACESSO.CD_OPERADO "); strTecnico.Append("FROM ACESSO "); strTecnico.Append("ORDER BY ACESSO.NM_OPERADO"); FbCommand fbSelect = (FbCommand)HlpBancoDados.CommandSelect(strTecnico.ToString()); fbSelect.Connection.Open(); FbDataReader drTecnico = fbSelect.ExecuteReader(); DataTable dtTecnico = new DataTable("Tecnico"); dtTecnico.Columns.Add("Nome").AllowDBNull = true; dtTecnico.Columns.Add("Id").AllowDBNull = true; DataRow dr; while (drTecnico.Read()) { dr = dtTecnico.NewRow(); dr["Nome"] = drTecnico["NM_OPERADO"]; dr["Id"] = drTecnico["CD_OPERADO"]; dtTecnico.Rows.Add(dr); } drTecnico.Close(); fbSelect.Connection.Close(); return(dtTecnico); }
protected void btnOk_Click(object sender, EventArgs e) { bool bExisteUsuario = false; StringBuilder strSelect = new StringBuilder(); strSelect.Append("SELECT CD_OPERADO, CD_SENHA, DS_GRUPO, NM_OPERADO "); strSelect.Append("FROM ACESSO "); strSelect.Append("WHERE (CD_OPERADO = '" + HlpBancoDados.GetUsuario(TextBox1.Text.ToUpper()) + "')"); FbCommand fbSelect = (FbCommand)HlpBancoDados.CommandSelect(strSelect.ToString()); fbSelect.Connection.Open(); FbDataReader drUsuario = fbSelect.ExecuteReader(); bExisteUsuario = drUsuario.Read(); if (bExisteUsuario) { string sSenhaDB = Criptografia.Decripta(drUsuario["CD_SENHA"].ToString()).ToLower(); if (!TextBox2.Text.ToLower().Equals(sSenhaDB)) { bExisteUsuario = false; } string sGrupo = String.Empty; if (drUsuario["DS_GRUPO"] != null) { sGrupo = drUsuario["DS_GRUPO"].ToString().ToUpper(); } if (sGrupo.Equals(String.Empty)) { sGrupo = "USUARIO"; } Session["Grupo"] = sGrupo; Session["CodigoUsuario"] = drUsuario["CD_OPERADO"].ToString(); Session["Usuario"] = drUsuario["NM_OPERADO"].ToString(); } fbSelect.Connection.Close(); if (!bExisteUsuario) { lblMsg.Visible = true; lblMsg.Text = "Usuário ou senha incorreta!"; } else { lblMsg.Visible = true; lblMsg.Text = String.Empty; Response.Redirect("~/Default.aspx"); } }
protected DataTable GetSistema() { StringBuilder strSistema = new StringBuilder(); if (!RadioButtonList1.SelectedItem.Text.Equals("SIM")) { strSistema.Append("SELECT SISTEMA.DS_SISTEMA, SISTEMA.CD_SISTEMA "); strSistema.Append("FROM SISTEMA "); strSistema.Append("ORDER BY SISTEMA.DS_SISTEMA"); } else { strSistema.Append("SELECT SITCONTR.CD_SISTEMA, SISTEMA.DS_SISTEMA "); strSistema.Append("FROM SITCONTR "); strSistema.Append("INNER JOIN SISTEMA ON (SISTEMA.CD_SISTEMA = SITCONTR.CD_SISTEMA) "); strSistema.Append("WHERE (SITCONTR.CD_CLIFOR = '" + DDLCliente.SelectedItem.Value + "') "); strSistema.Append("ORDER BY SISTEMA.DS_SISTEMA"); } FbCommand fbSelect = (FbCommand)HlpBancoDados.CommandSelect(strSistema.ToString()); fbSelect.Connection.Open(); FbDataReader drSistema = fbSelect.ExecuteReader(); DataTable dtSistema = new DataTable("Sistema"); dtSistema.Columns.Add("Nome").AllowDBNull = true; dtSistema.Columns.Add("Id").AllowDBNull = true; DataRow dr; while (drSistema.Read()) { dr = dtSistema.NewRow(); dr["Nome"] = drSistema["DS_SISTEMA"]; dr["Id"] = drSistema["CD_SISTEMA"]; dtSistema.Rows.Add(dr); } drSistema.Close(); fbSelect.Connection.Close(); return(dtSistema); }
protected DataTable GetCliente() { StringBuilder strCliente = new StringBuilder(); strCliente.Append("SELECT DISTINCT CLIFOR.NM_GUERRA, CLIFOR.CD_CLIFOR "); strCliente.Append("FROM CLIFOR INNER JOIN SITCONTR ON (SITCONTR.CD_CLIFOR = CLIFOR.CD_CLIFOR) "); strCliente.Append("WHERE (CLIFOR.CD_CLIFOR IS NOT NULL) AND (CLIFOR.ST_INATIVO = 'N') "); strCliente.Append("GROUP BY CLIFOR.NM_GUERRA, CLIFOR.CD_CLIFOR, "); strCliente.Append("CLIFOR.ST_ATIVOSUPORTE, SITCONTR.ST_CONT_HORAS, SITCONTR.ST_MANUT "); strCliente.Append("HAVING (CASE WHEN CLIFOR.ST_ATIVOSUPORTE IS NULL THEN "); strCliente.Append("(CASE WHEN SITCONTR.ST_CONT_HORAS = 'N' THEN "); strCliente.Append("(CASE WHEN SITCONTR.ST_MANUT = 'S' THEN 'S' ELSE SITCONTR.ST_MANUT END) "); strCliente.Append("ELSE (CASE WHEN SITCONTR.ST_CONT_HORAS IS NULL THEN 'N' ELSE SITCONTR.ST_CONT_HORAS END) END) "); strCliente.Append("ELSE CLIFOR.ST_ATIVOSUPORTE END) = 'S' "); strCliente.Append("ORDER BY CLIFOR.NM_GUERRA"); FbCommand fbSelect = (FbCommand)HlpBancoDados.CommandSelect(strCliente.ToString()); fbSelect.Connection.Open(); FbDataReader drCliente = fbSelect.ExecuteReader(); DataTable dtCliente = new DataTable("Cliente"); dtCliente.Columns.Add("Nome").AllowDBNull = true; dtCliente.Columns.Add("Id").AllowDBNull = true; DataRow dr; while (drCliente.Read()) { dr = dtCliente.NewRow(); dr["Nome"] = drCliente["NM_GUERRA"]; dr["Id"] = drCliente["CD_CLIFOR"]; dtCliente.Rows.Add(dr); } drCliente.Close(); fbSelect.Connection.Close(); return(dtCliente); }
protected void Button1_Click(object sender, EventArgs e) { if (TextBox4.Text.Equals("__/__/____")) { TextBox4.Text = String.Empty; } if (TextBox5.Text.Equals("__/__/____")) { TextBox5.Text = String.Empty; } if ((TextBox4.Text.Equals(String.Empty)) && (!TextBox5.Text.Equals(String.Empty))) { TextBox4.Text = TextBox5.Text; } else if ((!TextBox4.Text.Equals(String.Empty)) && (TextBox5.Text.Equals(String.Empty))) { TextBox5.Text = TextBox4.Text; } if ((!TextBox1.Text.Equals(String.Empty)) || (!TextBox2.Text.Equals(String.Empty)) || (!TextBox3.Text.Equals(String.Empty)) || (!TextBox4.Text.Equals(String.Empty)) || (!TextBox5.Text.Equals(String.Empty)) || (!TextBox6.Text.Equals(String.Empty))) { Label7.Visible = false; Label7.Text = String.Empty; StringBuilder strVisita = new StringBuilder(); strVisita.Append("SELECT LANCREL.NR_LANC, LANCREL.HR_ENTRADA, LANCREL.HR_SAIDA, "); strVisita.Append("LANCREL.NM_GUERRA, LANCREL.DT_REL, LANCREL.CD_OPERADO, ACESSO.NM_OPERADO "); strVisita.Append("FROM LANCREL "); strVisita.Append("INNER JOIN ACESSO ON (ACESSO.CD_OPERADO = LANCREL.CD_OPERADO) "); strVisita.Append("WHERE "); if ((!TextBox1.Text.Equals(String.Empty))) { strVisita.Append("(LANCREL.NR_LANC = '" + HlpBancoDados.GetCodigo(TextBox1.Text.Trim()) + "') AND "); } if ((!TextBox2.Text.Equals(String.Empty))) { strVisita.Append("(LANCREL.NM_GUERRA LIKE '" + TextBox2.Text.ToUpper().Trim() + "%') AND "); } if (TextBox3.Visible) { if ((!TextBox3.Text.Equals(String.Empty))) { strVisita.Append("(ACESSO.NM_OPERADO = '" + TextBox3.Text.ToUpper().Trim() + "') AND "); } } else { string sUsu = (string)Session["CodigoUsuario"]; strVisita.Append("(LANCREL.CD_OPERADO = '" + sUsu + "') AND "); } if ((!TextBox6.Text.Equals(String.Empty))) { strVisita.Append("(LANCREL.CD_REL = '" + HlpBancoDados.GetCodigo(TextBox6.Text.Trim()) + "') AND "); } if ((!TextBox4.Text.Equals(String.Empty)) || (!TextBox5.Text.Equals(String.Empty))) { strVisita.Append("(LANCREL.DT_REL BETWEEN '" + HlpBancoDados.ConverterData(TextBox4.Text.Trim()) + "' AND '" + HlpBancoDados.ConverterData(TextBox5.Text.Trim()) + "') AND"); } strVisita.Append("(LANCREL.HR_ENTRADA IS NOT NULL) ORDER BY LANCREL.NR_LANC"); FbCommand cmdVisita = (FbCommand)HlpBancoDados.CommandSelect(strVisita.ToString()); cmdVisita.Connection.Open(); FbDataReader drVisita = cmdVisita.ExecuteReader(); DataTable dtVisita = new DataTable("ConsultaVisita"); dtVisita.Columns.Add("NR_LANC"); dtVisita.Columns.Add("HR_ENTRADA"); dtVisita.Columns.Add("HR_SAIDA"); dtVisita.Columns.Add("NM_GUERRA"); dtVisita.Columns.Add("DT_REL"); dtVisita.Columns.Add("NM_OPERADO"); dtVisita.Columns.Add("CD_OPERADO"); DataRow dr; while (drVisita.Read()) { dr = dtVisita.NewRow(); dr["NR_LANC"] = drVisita["NR_LANC"]; dr["HR_ENTRADA"] = drVisita["HR_ENTRADA"]; dr["HR_SAIDA"] = drVisita["HR_SAIDA"]; dr["NM_GUERRA"] = drVisita["NM_GUERRA"]; dr["DT_REL"] = GetFormataDataRetorno(drVisita["DT_REL"].ToString()); dr["NM_OPERADO"] = drVisita["NM_OPERADO"]; dr["CD_OPERADO"] = drVisita["CD_OPERADO"]; dtVisita.Rows.Add(dr); } drVisita.Close(); cmdVisita.Connection.Close(); int iResultado = dtVisita.Rows.Count; if (iResultado > 0) { Session["TabelaVisita"] = dtVisita; Response.Redirect("~/ResultadoConsultaVisita.aspx"); } else { Response.Redirect("~/Informacao.aspx?RET=Não foi encontrado os dados solicitados!"); } } else { Label7.Visible = true; Label7.Text = "Ao menos um dos campo precisa estar preenchido!"; } }
protected void Page_Load(object sender, EventArgs e) { if ((Session["Grupo"] == null) || (Session["CodigoUsuario"] == null)) { Response.Redirect("~/Login.aspx"); } if (Request.QueryString["ID"].ToString() != String.Empty) { string strID = Request.QueryString["ID"].ToString(); StringBuilder str = new StringBuilder(); str.Append("SELECT LANCREL.NR_LANC, LANCREL.DT_REL, LANCREL.NM_CONTATO, "); str.Append("LANCREL.CD_CLIENTE, LANCREL.CD_OPERADO, "); str.Append("LANCREL.CD_SISTEMA, LANCREL.CD_TIPOREL, "); str.Append("LANCREL.ST_FATURA, LANCREL.HR_ENTRADA, "); str.Append("LANCREL.HR_DESCONTO, LANCREL.HR_TOTAL, LANCREL.HR_SAIDA, "); str.Append("LANCREL.NM_GUERRA, LANCREL.DS_OBS, ACESSO.NM_OPERADO, SISTEMA.DS_SISTEMA, ST_MAQ, DS_MAQUINA "); str.Append("FROM LANCREL "); str.Append("INNER JOIN ACESSO ON (ACESSO.CD_OPERADO = LANCREL.CD_OPERADO) "); str.Append("LEFT JOIN SISTEMA ON (SISTEMA.CD_SISTEMA = LANCREL.CD_SISTEMA) "); str.Append("WHERE (NR_LANC = '" + strID + "')"); FbCommand cmdSelect = (FbCommand)HlpBancoDados.CommandSelect(str.ToString()); cmdSelect.Connection.Open(); FbDataReader drVisita = cmdSelect.ExecuteReader(); DataTable dtVisita = new DataTable("ConsultaVisita"); dtVisita.Columns.Add("NR_LANC"); dtVisita.Columns.Add("HR_ENTRADA"); dtVisita.Columns.Add("HR_SAIDA"); dtVisita.Columns.Add("HR_DESCONTO"); dtVisita.Columns.Add("NM_GUERRA"); dtVisita.Columns.Add("DT_REL"); dtVisita.Columns.Add("NM_OPERADO"); dtVisita.Columns.Add("TITULO"); dtVisita.Columns.Add("NM_CONTATO"); dtVisita.Columns.Add("DS_OBS"); dtVisita.Columns.Add("ST_MAQ"); dtVisita.Columns.Add("DS_MAQUINA"); DataRow dr; if (drVisita.Read()) { dr = dtVisita.NewRow(); dr["NR_LANC"] = drVisita["NR_LANC"]; dr["HR_ENTRADA"] = drVisita["HR_ENTRADA"]; dr["HR_SAIDA"] = drVisita["HR_SAIDA"]; dr["HR_DESCONTO"] = drVisita["HR_DESCONTO"]; dr["NM_GUERRA"] = drVisita["NM_GUERRA"]; dr["DT_REL"] = GetFormataDataRetorno(drVisita["DT_REL"].ToString()); dr["NM_OPERADO"] = drVisita["NM_OPERADO"]; dr["NM_CONTATO"] = drVisita["NM_CONTATO"]; if (drVisita["CD_TIPOREL"].ToString() == "4") { dr["TITULO"] = "SOFTWARE"; } else if (drVisita["CD_TIPOREL"].ToString() == "3") { dr["TITULO"] = "HARDWARE"; } if (!drVisita["DS_OBS"].ToString().Equals(String.Empty)) { byte[] bt = (byte[])drVisita["DS_OBS"]; dr["DS_OBS"] = ASCIIEncoding.Default.GetString(bt); } if (!drVisita["DS_MAQUINA"].ToString().Equals(String.Empty)) { byte[] bt = (byte[])drVisita["DS_MAQUINA"]; dr["DS_MAQUINA"] = ASCIIEncoding.Default.GetString(bt); } if (drVisita["ST_MAQ"].ToString() == "1") { dr["ST_MAQ"] = "Máquina em Perfeito Estado"; } else { dr["ST_MAQ"] = "Máquina com Problema"; } dtVisita.Rows.Add(dr); } drVisita.Close(); cmdSelect.Connection.Close(); StringBuilder strOs = new StringBuilder(); strOs.Append("SELECT CD_OS, NR_LANC FROM ITLANCREL "); strOs.Append("WHERE (NR_LANC = '" + strID + "') ORDER BY CD_OS"); FbCommand cmdOs = (FbCommand)HlpBancoDados.CommandSelect(strOs.ToString()); cmdOs.Connection.Open(); FbDataReader drOs = cmdOs.ExecuteReader(); DataTable dtOs = new DataTable("OS"); dtOs.Columns.Add("CD_OS"); dtOs.Columns.Add("NR_LANCREL"); DataRow drItensRel; while (drOs.Read()) { drItensRel = dtOs.NewRow(); drItensRel[0] = drOs[0]; drItensRel[1] = drOs[1]; dtOs.Rows.Add(drItensRel); } drOs.Close(); cmdOs.Connection.Close(); rpt.Load(Server.MapPath("crRelVisita.rpt")); rpt.SetDataSource(dtVisita); rpt.Subreports["crOsRelVisita.rpt"].SetDataSource(dtOs); RptVisita.ReportSource = rpt; RptVisita.Visible = true; } }
protected void btnGravar_Click(object sender, EventArgs e) { string strCodUsuario = (string)Session["CodigoUsuario"]; if (txtMemo.Text != String.Empty) { FbCommand SelectCodigoOS = (FbCommand)HlpBancoDados.CommandSelect("SELECT DS_RESULTADO FROM SP_FALINHA(Cast(GEN_ID(ORDEMSER, 1) as varchar(7)), 7)"); SelectCodigoOS.Connection.Open(); string sCodOS = SelectCodigoOS.ExecuteScalar().ToString(); SelectCodigoOS.Connection.Close(); ListBox lbCorrecao = new ListBox(); StringBuilder sbCorrecoes = new StringBuilder(); sbCorrecoes.AppendLine("1- LAYOUTS ALTERADOS"); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine("NOME ALTERACAO"); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine("__________________________________________________________________________________________________________________________"); sbCorrecoes.AppendLine("2-TELAS ALTERADAS"); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine("NOME ALTERACAO"); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine("__________________________________________________________________________________________________________________________"); sbCorrecoes.AppendLine("3-MUDANÇA DE ESTRUTURA"); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine("TABELA CAMPO ALTERACOES"); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine("__________________________________________________________________________________________________________________________"); sbCorrecoes.AppendLine("4-MUDANÇA DE CONCEITOS"); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine("__________________________________________________________________________________________________________________________"); sbCorrecoes.AppendLine("5-CORREÇÕES"); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine("__________________________________________________________________________________________________________________________"); sbCorrecoes.AppendLine("6-ACOES A SEREM TOMADAS NO CLIENTE"); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine(""); sbCorrecoes.AppendLine("__________________________________________________________________________________________________________________________"); sbCorrecoes.AppendLine("7-UPLOAD"); sbCorrecoes.AppendLine(""); byte[] bt = System.Text.Encoding.Default.GetBytes(sbCorrecoes.ToString()); StringBuilder str = new StringBuilder(); str.Append("INSERT INTO ORDEMSER (CD_OS, DT_OS, DT_ENTREGA, ST_OS, NR_ORDEM, ST_FATURA, "); str.Append("DT_CAD, CD_USUINC, DS_OS, CD_SISTEMA, TP_OS, CD_CLIENTE, NM_GUERRA, CD_PROGR, NM_PROGR, DS_CORRECOES) VALUES ('" + sCodOS.Trim() + "', '"); str.Append(GetDataCorreta().Replace("/", ".") + "', '" + GetDataCorreta().Replace("/", ".") + "', 'AG', '99', 'N', '" + GetDataCorreta().Replace("/", ".") + "', '"); str.Append(strCodUsuario + "', '" + txtMemo.Text.ToUpper().Trim() + "', '" + DDLSistema.SelectedItem.Value.Trim() + "', '"); str.Append(DDLTipoOs.SelectedItem.Value.Trim() + "', '" + DDLCliente.SelectedItem.Value.Trim() + "', '" + DDLCliente.SelectedItem.Text.Trim() + "', '0000MASTER', 'MASTER', '" + ASCIIEncoding.Default.GetString(bt) + "')"); FbCommand cmd = (FbCommand)HlpBancoDados.CommandSelect(str.ToString()); cmd.Connection.Open(); int iRetorno = cmd.ExecuteNonQuery(); cmd.Connection.Close(); if (iRetorno > 0) { MultiView1.ActiveViewIndex = 1; if (EnviarEmail(sCodOS)) { lblTitulo.Text = "Ordem de Serviço: " + sCodOS + " incluido com sucesso."; lblLancamento.Text = "Foi enviado um e-mail para a HLP!"; } else { lblTitulo.Text = "Ordem de Serviço: " + sCodOS + " incluido com sucesso."; lblLancamento.Text = "Não foi possível enviar um e-mail para a HLP!"; } } } }
protected void btnGravar_Click(object sender, EventArgs e) { string strCodUsuario = (string)Session["CodigoUsuario"]; string strLancRel = String.Empty; string strItLancRel = String.Empty; if (bCadastroValido()) { if (Request.QueryString["IdRel"].ToString() == "incluir") { FbCommand cmdProcedure = (FbCommand)HlpBancoDados.CommandProcedure("SP_INCLUI_LANCREL"); cmdProcedure.Connection.Open(); strLancRel = cmdProcedure.ExecuteScalar().ToString(); cmdProcedure.Connection.Close(); } else { strLancRel = Request.QueryString["IdRel"].ToString(); } StringBuilder strInserir = new StringBuilder(); strInserir.Append("UPDATE LANCREL SET "); strInserir.Append("DT_REL = '" + txtDataCadastro.Text.Replace("/", ".").Trim() + "', NM_CONTATO = '" + txtContato.Text.ToUpper().Trim() + "', "); if (DDLCliente.Visible) { strInserir.Append("CD_CLIENTE = '" + DDLCliente.SelectedValue + "', "); } strInserir.Append("CD_OPERADO = '"); if (DDLTecnico.Visible) { strInserir.Append(DDLTecnico.SelectedValue + "', "); } else { strInserir.Append(strCodUsuario + "', "); } strInserir.Append("CD_SISTEMA = '" + DDLSistema.SelectedValue + "', CD_TIPOREL = '"); if (DDLTipoRelatoio.SelectedValue.Equals("SOFTWARE")) { if (DDLVncLocal.SelectedValue.Equals("VNC")) { strInserir.Append("5" + "', "); } else { strInserir.Append("4" + "', "); } } else { strInserir.Append("3" + "', "); } strInserir.Append("ST_FATURA = '"); if (DDLFaturar.Visible) { if (DDLFaturar.SelectedValue.Equals("SIM")) { strInserir.Append("S" + "', "); } else { strInserir.Append("N" + "', "); } } else { if (DDLTituloRel.SelectedValue.Equals("GARANTIA")) { strInserir.Append("N" + "', "); } else { strInserir.Append("S" + "', "); } } strInserir.Append("ST_MAQ = '" + rdblEstMaqui.SelectedItem.Value + "', DS_MAQUINA = '" + txtDesMaqui.Text.ToUpper().Trim() + "', "); strInserir.Append("HR_ENTRADA = '" + txtHoraInicio.Text + "', HR_SAIDA = '" + txtHoraFinal.Text + "', "); strInserir.Append("HR_DESCONTO = '" + txtHoraDesc.Text + "', HR_TOTAL = '" + lblHoraTotal.Text + "', "); strInserir.Append("NM_GUERRA = '" + (DDLCliente.Visible ? DDLCliente.SelectedItem.Text : txtCliente.Text.ToUpper()) + "', "); strInserir.Append("DS_OBS = '" + DDLTituloRel.SelectedItem.Text + "(" + DDLVncLocal.SelectedItem.Text + ") - " + txtMemo.Text.ToUpper().Trim() + "' "); strInserir.Append("WHERE (NR_LANC = '" + strLancRel + "')"); FbCommand cmdIncluir = (FbCommand)HlpBancoDados.CommandSelect(strInserir.ToString()); cmdIncluir.Connection.Open(); int iIncluiSucesso = cmdIncluir.ExecuteNonQuery(); cmdIncluir.Connection.Close(); if (iIncluiSucesso > 0) { foreach (ListItem Item in LtbOs.Items) { FbCommand cmdSPItLancRel = (FbCommand)HlpBancoDados.CommandProcedure("SP_INCLUI_ITLANCREL"); cmdSPItLancRel.Connection.Open(); strItLancRel = cmdSPItLancRel.ExecuteScalar().ToString(); cmdSPItLancRel.Connection.Close(); if (!strItLancRel.Equals(String.Empty)) { StringBuilder strItLanc = new StringBuilder(); strItLanc.Append("UPDATE ITLANCREL SET CD_OS = '" + Item.Text + "', "); strItLanc.Append("NR_LANC = '" + strLancRel + "' "); strItLanc.Append("WHERE (NR_ITLANCREL = '" + strItLancRel + "')"); FbCommand cmdInserirOs = (FbCommand)HlpBancoDados.CommandSelect(strItLanc.ToString()); cmdInserirOs.Connection.Open(); iIncluiSucesso = cmdInserirOs.ExecuteNonQuery(); cmdInserirOs.Connection.Close(); } } if (iIncluiSucesso > 0) { Response.Redirect("~/Confirmacao.aspx?ID=" + strLancRel + ",I"); } else { Response.Redirect("~/Confirmacao.aspx?ID=0000000,X"); } } else { Response.Redirect("~/Confirmacao.aspx?ID=0000000,X"); } } else { lblErro.Text = "Todos os campos devem estar preenchidos!"; } }
protected void Page_Load(object sender, EventArgs e) { string strGrupo = (string)Session["Grupo"]; if (!strGrupo.Equals("ADMIN")) { lblFaturar.Visible = false; lblTecnico.Visible = false; DDLTecnico.Visible = false; DDLFaturar.Visible = false; } if (!IsPostBack) { DataTable Cliente = GetCliente(); DDLCliente.DataSource = Cliente; DDLCliente.DataMember = "Cliente"; DDLCliente.DataTextField = "Nome"; DDLCliente.DataValueField = "Id"; DDLCliente.DataBind(); DataTable Tecnico = GetTecnico(); DDLTecnico.DataSource = Tecnico; DDLTecnico.DataMember = "Tecnico"; DDLTecnico.DataTextField = "Nome"; DDLTecnico.DataValueField = "Id"; DDLTecnico.DataBind(); //DDLSistema.Items.Clear(); //DataTable Sistema = GetSistema(); //DDLSistema.DataSource = Sistema; //DDLSistema.DataMember = "Sistema"; //DDLSistema.DataTextField = "Nome"; //DDLSistema.DataValueField = "Id"; //DDLSistema.DataBind(); if (Request.QueryString["IdRel"].ToString() != String.Empty) { if (Request.QueryString["IdRel"].ToString() == "incluir") { Label15.Text = "Inclusão de novo Cadastro de Visita"; txtDataCadastro.Text = GetDataCorreta(); txtHoraInicio.Text = "00:00"; txtHoraFinal.Text = GetHoraCorreta(); txtHoraDesc.Text = "00:00"; lblHoraTotal.Text = "00:00"; } else { Label15.Text = "Alterar Cadastro de Visita: " + Request.QueryString["IdRel"].ToString(); string strCodRelatorio = Request.QueryString["IdRel"].ToString(); StringBuilder strSelect = new StringBuilder(); strSelect.Append("SELECT LANCREL.DT_REL, LANCREL.NM_CONTATO, "); strSelect.Append("LANCREL.CD_CLIENTE, LANCREL.CD_OPERADO, "); strSelect.Append("LANCREL.CD_SISTEMA, LANCREL.CD_TIPOREL, "); strSelect.Append("LANCREL.ST_FATURA, LANCREL.HR_ENTRADA, "); strSelect.Append("LANCREL.HR_DESCONTO, LANCREL.HR_TOTAL, LANCREL.HR_SAIDA, "); strSelect.Append("LANCREL.NM_GUERRA, LANCREL.DS_OBS, ACESSO.NM_OPERADO, SISTEMA.DS_SISTEMA "); strSelect.Append("FROM LANCREL "); strSelect.Append("INNER JOIN ACESSO ON (ACESSO.CD_OPERADO = LANCREL.CD_OPERADO) "); strSelect.Append("INNER JOIN SISTEMA ON (SISTEMA.CD_SISTEMA = LANCREL.CD_SISTEMA) "); strSelect.Append("WHERE (NR_LANC = '" + strCodRelatorio + "')"); FbCommand cmdAutRel = (FbCommand)HlpBancoDados.CommandSelect(strSelect.ToString()); cmdAutRel.Connection.Open(); FbDataReader drRel = cmdAutRel.ExecuteReader(); if (drRel.Read()) { txtDataCadastro.Text = GetFormataDataRetorno(drRel["DT_REL"].ToString().Replace(".", "/")); txtContato.Text = drRel["NM_CONTATO"].ToString(); DDLCliente.SelectedValue = drRel["NM_GUERRA"].ToString(); DDLTecnico.SelectedValue = drRel["NM_OPERADO"].ToString(); DDLSistema.SelectedValue = drRel["DS_SISTEMA"].ToString(); if (drRel["CD_TIPOREL"].ToString().Equals("4")) { DDLTipoRelatoio.Text = "SOFTWARE"; } else { DDLTipoRelatoio.Text = "HARDWARE"; } if (drRel["ST_FATURA"].ToString().Equals("S")) { DDLFaturar.Text = "SIM"; } else { DDLFaturar.Text = "NÃO"; } txtHoraInicio.Text = drRel["HR_ENTRADA"].ToString(); txtHoraFinal.Text = drRel["HR_SAIDA"].ToString(); txtHoraDesc.Text = drRel["HR_DESCONTO"].ToString(); lblHoraTotal.Text = drRel["HR_TOTAL"].ToString(); if (!drRel["DS_OBS"].ToString().Equals(String.Empty)) { byte[] bt = (byte[])drRel["DS_OBS"]; txtMemo.Text = ASCIIEncoding.Default.GetString(bt); } } drRel.Close(); cmdAutRel.Connection.Close(); } } DDLTituloRel.Items.Clear(); DDLTituloRel.Items.Add("MANUTENCAO"); DDLTituloRel.Items.Add("ORCAMENTO"); DDLTituloRel.Items.Add("GARANTIA"); DDLTituloRel.Items.Add("OUTROS"); DDLTituloRel.DataBind(); } }