void FrmAnexosLoad(object sender, EventArgs e) { agenda = new cAgenda(); string codigo = edtCodigo.Text.Trim(); agenda.CarregaAnexos(dgvCadastro, usuario, data_agendamento); DesabilitaEdicao(); }
private void GetAgendaxCodigo(Int32 CodAgenda) { cFunciones fun = new cFunciones(); cAgenda agenda = new cAgenda(); DataTable trdo = agenda.GetAgendaxCodigo(CodAgenda); if (trdo.Rows.Count > 0) { txtCodAgenda.Text = trdo.Rows[0]["CodAgenda"].ToString(); txtNombre.Text = trdo.Rows[0]["Nombre"].ToString(); txtApellido.Text = trdo.Rows[0]["Apellido"].ToString(); txtModelo.Text = trdo.Rows[0]["Modelo"].ToString(); txtDescripcion.Text = trdo.Rows[0]["Descripcion"].ToString(); txtPatente.Text = trdo.Rows[0]["Patente"].ToString(); if (trdo.Rows[0]["CodMarca"].ToString() != "") { Int32 CodMarca = Convert.ToInt32(trdo.Rows[0]["CodMarca"].ToString()); cmbMarca.SelectedValue = CodMarca.ToString(); } if (trdo.Rows[0]["Fecha"].ToString() != "") { DateTime Fecha = Convert.ToDateTime(trdo.Rows[0]["Fecha"].ToString()); txtFechaDesde.Text = Fecha.ToShortDateString(); } TXTtELEFONO.Text = trdo.Rows[0]["Telefono"].ToString(); if (trdo.Rows[0]["Precio"].ToString() != "") { Double Precio = Convert.ToDouble(trdo.Rows[0]["Precio"].ToString()); txtImporte.Text = Precio.ToString(); txtImporte.Text = fun.FormatoEnteroMiles(txtImporte.Text); } if (trdo.Rows[0]["CodOpcion"].ToString() != "") { Int32 CodOpcion = Convert.ToInt32(trdo.Rows[0]["CodOpcion"].ToString()); if (CodOpcion == 1) { RadioComprador.Checked = true; RadioVendedor.Checked = false; } if (CodOpcion == 2) { RadioVendedor.Checked = true; RadioComprador.Checked = false; } if (trdo.Rows[0]["CodVendedor"].ToString() != "") { cmbVendedor.SelectedValue = trdo.Rows[0]["CodVendedor"].ToString(); } } } }
private void btnEliminar_Click(object sender, EventArgs e) { if (Grilla.CurrentRow == null) { MessageBox.Show("Debe seleccionar un registro"); return; } string msj = "Confirma eliminar el Cliente "; var result = MessageBox.Show(msj, "Información", MessageBoxButtons.YesNo, MessageBoxIcon.Question); // If the no button was pressed ... if (result == DialogResult.No) { return; } Int32 CodAgenda = Convert.ToInt32(Grilla.CurrentRow.Cells[0].Value); cAgenda agenda = new cAgenda(); agenda.BorrarAgenda(CodAgenda); Buscar(); }
private void Buscar() { cFunciones fun = new cFunciones(); if (fun.ValidarFecha(txtFechaDesde.Text) == false) { Mensaje("La fecha desde es incorrecta"); return; } if (fun.ValidarFecha(txtFechaHasta.Text) == false) { Mensaje("La fecha dehasta es incorrecta"); return; } DateTime FechaDesde = Convert.ToDateTime(txtFechaDesde.Text); DateTime FechaHasta = Convert.ToDateTime(txtFechaHasta.Text); cAgenda agenda = new cAgenda(); string Patente = ""; string Descripcion = txtDescripcion.Text; Double PrecioDesde = 0; Double PrecioHasta = 0; int IncluyePrecio = 0; Int32? CodOpcion = null; Int32? CodMarca = null; string Telefono = ""; string Modelo = ""; if (cmbMarca.SelectedIndex > 0) { CodMarca = Convert.ToInt32(cmbMarca.SelectedValue); } Modelo = txtModelo.Text; Telefono = txtTelefono.Text; if (cmbOpciones.SelectedIndex > 0) { CodOpcion = Convert.ToInt32(cmbOpciones.SelectedValue); } if (txtPrecioDesde.Text != "" && txtPrecioHasta.Text != "") { IncluyePrecio = 1; PrecioDesde = fun.ToDouble(txtPrecioDesde.Text); PrecioHasta = fun.ToDouble(txtPrecioHasta.Text); } string Cliente = ""; if (txtNombreCliente.Text != "") { Cliente = txtNombreCliente.Text; } DataTable trdo = agenda.GetAgenda(FechaDesde, FechaHasta, IncluyePrecio, PrecioDesde, PrecioHasta, CodOpcion, Patente, Descripcion, Cliente, Telefono, CodMarca, Modelo); trdo = fun.TablaaMiles(trdo, "Precio"); Grilla.DataSource = trdo; // Grilla.Columns[5].Width = 170; Grilla.Columns[1].Width = 150; Grilla.Columns[2].Width = 130; Grilla.Columns[0].Visible = false; Grilla.Columns[7].Visible = false; }
void FrmAgendaLoad(object sender, EventArgs e) { if (fromMain) { string sBanco = ""; string sUltimoUsuario = ""; string sUltimaFilial = ""; Globais.CarregaIni(ref sBanco, ref sUltimoUsuario, ref sUltimaFilial); string parametros = "User=SYSDBA;" + "Password=masterkey;" + "Database=" + sBanco; Globais.bd = new FbConnection(parametros); try { Log.Grava(Globais.sUsuario, parametros); Globais.bd.Open(); } catch (Exception err) { Log.Grava(Globais.sUsuario, "erro:" + err.Message); MessageBox.Show("Erro na conexão com o banco de dados:\n" + sBanco + "\n" + err.Message); Close(); return; } if (login) { frmLogin frm = new frmLogin(); frm.admin = false; frm.sUltimoUsuario = sUltimoUsuario; frm.sUltimaFilial = sUltimaFilial; frm.ShowDialog(); if (!frm.bOK) { Close(); return; } else { Globais.GravaIni(sBanco, sUltimoUsuario, sUltimaFilial); } cControleAcesso acesso = new cControleAcesso(); if (!Globais.bAdministrador && !acesso.PermissaoSistema(Globais.sUsuario, Globais.sFilial, 3)) { MessageBox.Show("Usuário sem permissão para esse Sistema", "Acesso negado", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); } } } agenda = new cAgenda(); cUsuarios usuarios = new cUsuarios(); this.Cursor = Cursors.WaitCursor; usuarios.Carrega(cbxFiltroUsuarios); this.Cursor = Cursors.Default; cbxFiltroUsuarios.Items.Add("Todos"); filtro_usuario = "Todos"; cbxFiltroUsuarios.Text = filtro_usuario; this.Cursor = Cursors.WaitCursor; usuarios.Carrega(cbxFiltroResponsaveis); this.Cursor = Cursors.Default; cbxFiltroResponsaveis.Items.Add("Todos"); if (Globais.bAdministrador) { filtro_responsavel = "Todos"; } else { filtro_responsavel = Globais.sUsuario.Trim(); } cbxFiltroResponsaveis.Text = filtro_responsavel; cbxPessoal.Items.Add("Todos"); cbxPessoal.Items.Add("Somente Pessoais"); cbxPessoal.Items.Add("Não Pessoais"); filtro_pessoal = "Não Pessoais"; cbxPessoal.Text = filtro_pessoal; filtro_data = System.DateTime.Today.ToString("M/d/yyyy"); cbxPrioridades.Items.Add("0 - Urgente"); cbxPrioridades.Items.Add("1 - Importante"); cbxPrioridades.Items.Add("2 - Normal"); cbxPrioridades.Text = "2 - Normal"; cNaturezas naturezas = new cNaturezas(); this.Cursor = Cursors.WaitCursor; naturezas.Carrega(cbxNaturezas); this.Cursor = Cursors.Default; this.Cursor = Cursors.WaitCursor; naturezas.Carrega(cbxFiltroNaturezas); this.Cursor = Cursors.Default; filtro_natureza = "Todas"; cbxFiltroNaturezas.Items.Add("Todas"); cbxFiltroNaturezas.Text = "Todas"; this.Cursor = Cursors.WaitCursor; usuarios.Carrega(cbxUsuarios); this.Cursor = Cursors.Default; cbxUsuarios.Text = Globais.sUsuario; InicializaCampos(); where = MontaFiltro(); acao = '?'; string usuario_agenda = ""; DateTime data_agenda = DateTime.Now; if (fornecedor.Length > 0) { where = " where 1=2"; trace.grava("procura agendamento: " + fornecedor + " " + data.ToString("d/M/yyyy") + " " + orcamento.ToString() + " " + pedido.ToString()); if (cPedidos.LeAgendamento(fornecedor, data, orcamento, pedido, ref usuario_agenda, ref data_agenda)) { trace.grava("agendamento recuperado"); acao = 'a'; //where = where + " or ((COD_USUARIO = '" + usuario_agenda +"') and (DAT_AGENDAMENTO = '" + data_agenda.ToString("M/d/yyyy") + "')) "; where = " where (COD_USUARIO = '" + usuario_agenda + "') and (DAT_AGENDAMENTO = '" + data_agenda.ToString("M/d/yyyy HH:mm:ss") + "') "; } else { trace.grava("novo agendamento"); acao = 'i'; } } if (seqAcao > 0) { if (usuarioAcao.Length > 0) { trace.grava("procura agendamento: " + usuarioAcao + " " + data.ToString("d/M/yyyy") + " " + orcamento.ToString() + " " + pedido.ToString()); acao = 'a'; usuario_agenda = usuarioAcao; data_agenda = data; where = " where (COD_USUARIO = '" + usuarioAcao + "') and (DAT_AGENDAMENTO = '" + data_agenda.ToString("M/d/yyyy HH:mm:ss") + "') "; trace.grava("procura agendamento: " + where); } else { trace.grava("novo agendamento"); acao = 'i'; } } this.Cursor = Cursors.WaitCursor; //agenda.Carrega(dgvCadastro, where); Carrega(); trace.grava("agendamentos carregados"); if ((fornecedor.Length > 0) && (acao == 'a') && (dgvCadastro.Rows.Count == 0)) { acao = 'i'; where = " where 1=2"; //agenda.Carrega(dgvCadastro, where); Carrega(); } this.Cursor = Cursors.Default; col_sorted = ""; ord_sorted = SortOrder.Ascending; Colore(); SetaEdicaoLocal(false); bool enable = (edtUsuario.Text.Trim().CompareTo(Globais.sUsuario.Trim()) == 0) || (cbxUsuarios.Text.Trim().CompareTo(Globais.sUsuario.Trim()) == 0) || Globais.bAdministrador; btnExclui.Enabled = enable; btnAltera.Enabled = enable; btnCadAnexos.Enabled = enable; btnAbreAnexo.Enabled = enable; if (fornecedor.Length > 0) { HabilitaEdicao(); SetaEdicaoLocal(true); if (acao == 'a') { foreach (DataGridViewRow row in dgvCadastro.Rows) { string u = row.Cells[0].Value.ToString(); DateTime d = DateTime.Parse(row.Cells[1].Value.ToString()); if ((u.CompareTo(usuario_agenda) == 0) && (d == data_agenda)) { row.Cells[0].Selected = true; break; } } dtpAgenda.Focus(); } else { edtDescricao.Text = ""; InicializaCampos(); edtPendencia.Text = "Montagem Pedido: " + fornecedor + " " + data.ToString("d/M/yyyy") + " " + orcamento.ToString() + " " + nro_pedido.ToString(); edtParceiro.Text = cliente; if (idt_data_prevista.Equals("S")) { dtpAgenda.Value = data_prevista; } cbxUsuarios.Text = Globais.sUsuario; edtPendencia.Focus(); } } if (seqAcao > 0) { if (seqAcao != 999999) { HabilitaEdicao(); SetaEdicaoLocal(true); } if (acao == 'a') { trace.grava("modo alteracao"); dtpAgenda.Focus(); } else { trace.grava("modo inclusao"); InicializaCampos(); cbxUsuarios.Text = Globais.sUsuario; edtParceiro.Text = edtFiltroParceiro.Text; edtPendencia.Focus(); } } }
private void btnGrabar_Click(object sender, EventArgs e) { cFunciones fun = new cFunciones(); cAgenda agenda = new cAgenda(); if (txtApellido.Text == "") { Mensaje("Debe ingresar un apellido"); return; } if (fun.ValidarFecha(txtFechaDesde.Text) == false) { Mensaje("La fecha ingresada es incorrecta"); return; } if (TXTtELEFONO.Text == "") { Mensaje("Debe ingresar un teléfono para continuar"); return; } if (cmbMarca.SelectedIndex < 1) { Mensaje("Debe seleccionar una marca para continuar"); return; } if (txtModelo.Text == "") { Mensaje("Debe ingresar un modelo"); return; } string Nombre = txtNombre.Text; string Apellido = txtApellido.Text; DateTime Fecha = Convert.ToDateTime(txtFechaDesde.Text); Double Importe = fun.ToDouble(txtImporte.Text); string Descripcion = txtDescripcion.Text; Int32? CodMarca = null; Double Precio = 0; int Vendedor = 0; int Comprador = 0; int CodOpcion = 0; string Opcion = ""; string Telefono = ""; Int32? CodVendedor = null; if (cmbVendedor.SelectedIndex > 0) { CodVendedor = Convert.ToInt32(cmbVendedor.SelectedValue); } if (RadioComprador.Checked == true) { CodOpcion = 1; Opcion = "Comprador"; } else { CodOpcion = 2; Opcion = "Vendedor"; } if (cmbMarca.SelectedIndex > 0) { CodMarca = Convert.ToInt32(cmbMarca.SelectedValue); } string Modelo = txtModelo.Text; string Patente = txtPatente.Text; Telefono = TXTtELEFONO.Text; if (txtCodAgenda.Text == "") { agenda.GrabarAgenda(Nombre, Apellido, CodMarca, Modelo, Importe, Descripcion, CodOpcion, Opcion, Fecha, Patente, CodVendedor, Telefono); } else { Int32 CodAgenda = Convert.ToInt32(txtCodAgenda.Text); agenda.ModificarAgenda(CodAgenda, Nombre, Apellido, CodMarca, Modelo, Importe, Descripcion, CodOpcion, Opcion, Fecha, Patente, CodVendedor, Telefono); } Mensaje("Datos grabados correctamente"); Limpiar(); }