private static IEnumerable <Motivo> GetMotivos(int cliente) { var list = new List <Motivo>(); var sq = new SQLiteDataSet(); sq.read(String.Concat("SELECT * FROM motivos where cliente is null or cliente = ", cliente, " order by orden")); if (sq.dataSet.Tables != null) { DataTable table = sq.dataSet.Tables[0]; foreach (DataRow row in table.Rows) { var item = new Motivo { Text = (string)row["descripcion"], Value = (int)row["id"], EsEntrega = Convert.ToBoolean(row["es_entrega"]) }; list.Add(item); } } return(list); /*return new List<Item> * { new Item{ Text = "Entregada", Value = 0 }, * new Item { Text ="Bajo Puerta" , Value = 1 }, * new Item { Text = "Se Mudo", Value = 2 }, * new Item { Text = "No Responde", Value = 3} * };*/ }
public void TomarGps(bool preguntar) { var sq = new SQLiteDataSet(); bool hacer = false; if (preguntar) { var mbFoto = MessageBox.Show(@"¿Desea tomar la posición GPS ahora?", string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (mbFoto == DialogResult.Yes) { hacer = true; } } else { hacer = true; } if (hacer) { try { using (var gps = new GPS()) { gps.ShowDialog(); if (gps.gotFix) { _service.TieneGPS = true; _service.Latitud = gps.lastPosition.dblLatitude; _service.Longitud = gps.lastPosition.dblLongitude; sq.UpdateGPS(_services); if (_multiple) { foreach (Ruta r in _services) { r.Latitud = _service.Latitud; r.Longitud = _service.Longitud; r.CalcularEstados(); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public UserInformation(SQLiteDataSet.UserInformationRow row) { this.userId = row.UserID; this.userName = row.UserName; this.password = row.Password; using (SQLiteDataSet ds = new SQLiteDataSet()) { using (SQLiteDataSetTableAdapters.AuthMasterTableAdapter ta = new sqliteTest.SQLiteDataSetTableAdapters.AuthMasterTableAdapter()) { ta.FillByAuthNo(ds.AuthMaster, row.AuthNo); } SQLiteDataSet.AuthMasterRow authRow = ds.AuthMaster[0]; this.isAccessable = authRow.IsAccessable; this.isUpdatable = authRow.IsUpdatable; this.isDetelable = authRow.IsDeletable; } }
private void btAceptar_Click(object sender, EventArgs e) { if (_motivoSeleccionado == null) { MessageBox.Show("Debe seleccionar un motivo"); return; } _service.Motivo = _motivoSeleccionado; if (_service.Estado == EstadoServicio.Terminado) { IrALista(); } if (_motivoEnabled) { if (_service.Confirma.Validate(_service.Motivo.EsEntrega)) { var mbConfirmar = MessageBox.Show(@"¿Esta usted seguro que desea ejecutar la acción " + _motivoSeleccionado.Text + @"?", string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (mbConfirmar == DialogResult.No) { Focus(); return; } } //Rutas.AddRuta(_service); var sq = new SQLiteDataSet(); sq.executeSQL(String.Concat("UPDATE rutas set estado = 2, fecha_motivo = current_timestamp, motivo = ", _motivoSeleccionado.Value, " where id = ", _service.Id)); } TomarDatos(true); IrALista(); }
public static void Init() { _rutas.Clear(); SQLiteDataSet sq = new SQLiteDataSet(); //sq.read("select rutas.*, tipos_de_servicio.*, tipos_de_servicio.descripcion as tiposerviciodescripcion, tipos_de_servicio.descripcion_corta as tiposerviciodescripcioncorta from rutas,tipos_de_servicio where tipos_de_servicio.id = tipo_de_servicio"); sq.read("select rutas.*, tipos_de_servicio.*, tipos_de_servicio.descripcion as tiposerviciodescripcion, tipos_de_servicio.descripcion_corta as tiposerviciodescripcioncorta, motivos.descripcion as motivodescripcion, motivos.es_entrega as motivoesentrega from rutas,tipos_de_servicio left join motivos on motivos.id = motivo where tipos_de_servicio.id = tipo_de_servicio order by numero_de_item"); if (sq.dataSet.Tables != null) { DataTable table = sq.dataSet.Tables[0]; foreach (DataRow row in table.Rows) { Ruta ruta = new Ruta(); ruta.Id = (int)row["id"]; ruta.Direccion = (string)row["direccion"]; ruta.Estado = EstadoServicioExtenssions.GetState(Convert.ToInt32(row["estado"])); ruta.Cliente = (int)row["cliente"]; ruta.ClienteDesc = ""; ruta.Destinatario = (string)row["destinatario"]; ruta.Pieza = (string)row["pieza"]; ruta.TipoServicio = (int)row["tipo_de_servicio"]; ruta.TipoServicioDesc = (string)row["tiposerviciodescripcion"]; ruta.TipoServicioDescCorta = (string)row["tiposerviciodescripcioncorta"]; ruta.Selected = false; if (row["motivo"] != DBNull.Value) { var m = new Motivo(); m.Value = (int)row["motivo"]; m.EsEntrega = (bool)row["motivoesentrega"]; m.Text = (string)row["motivodescripcion"]; ruta.Motivo = m; } if (row["lateral1"] != DBNull.Value) { ruta.Lateral1 = (string)row["lateral1"]; } else { ruta.Lateral1 = ""; } if (row["lateral2"] != DBNull.Value) { ruta.Lateral2 = (string)row["lateral2"]; } else { ruta.Lateral2 = ""; } if (row["referencia"] != DBNull.Value) { ruta.Referencia = (string)row["referencia"]; } else { ruta.Referencia = ""; } ruta.Longitud = row["longitud"] != DBNull.Value ? (double?)Convert.ToDouble(row["longitud"]) : null; ruta.Latitud = row["latitud"] != DBNull.Value ? (double?)Convert.ToDouble(row["latitud"]) : null; ruta.Confirma = TipoValidacionExtenssions.GetType(Convert.ToInt32(row["confirma"])); ruta.ConFoto = TipoValidacionExtenssions.GetType(Convert.ToInt32(row["con_foto"])); ruta.ConLaterales = TipoValidacionExtenssions.GetType(Convert.ToInt32(row["con_laterales"])); ruta.ConReferencia = TipoValidacionExtenssions.GetType(Convert.ToInt32(row["con_Referencia"])); ruta.ConGPS = TipoValidacionExtenssions.GetType(Convert.ToInt32(row["con_GPS"])); if (row["foto"] != DBNull.Value) { ruta.Foto = (Byte[])row["foto"]; } else { ruta.Foto = new Byte[0]; } ruta.CalcularEstados(); _rutas.Add(ruta); } } /* * _rutas.AddRange(new List<Ruta>{ * new Ruta{ Id = 0, * Direccion="Chacabuco 1580, Capital", * Estado=EstadoServicio.Pendiente, * Cliente =1, * Destinatario="Juan Castro", * Pieza="LPA", * TipoServicio = 3, * TipoServicioDesc="Acuse con GeoFoto", * Lateral1="", * Lateral2="" * }, * new Ruta{ Id = 1, * Direccion="Rivadavia 4260, Capital", * Estado=EstadoServicio.Pendiente, * Motivo = 1, * Cliente =1, * TipoServicio = 3, * Destinatario="Pedro Bonini", * Pieza="LPB", * TipoServicioDesc="Acuse con GeoFoto", * Lateral1="", * Lateral2="", * Referencia = "" * }, * new Ruta{ Id = 2, * Direccion="Brasil 969, Capital", * Estado=EstadoServicio.Terminado, * Motivo = 1, * Cliente =1, * TipoServicio = 3, * Destinatario="Jose Alvarez Unzué", * Pieza="LPC", * TipoServicioDesc="Acuse con GeoFoto", * Lateral1="967", * Lateral2="971", * Referencia = "Puerta verde" * }, * new Ruta{ Id = 3, * Direccion="Mario Bravo 14, Banfield", * Estado=EstadoServicio.Pendiente, * Motivo = 1, * Cliente =1, * TipoServicio = 3, * Destinatario="Pablo Marmol", * Pieza="LPD", * TipoServicioDesc="Simple", * Lateral1="", * Lateral2="", * Referencia = "" * }} * ); */ }
public void TomarLateralesReferencia(bool preguntar, bool forzarLaterales, bool forzarReferencia) { var sq = new SQLiteDataSet(); bool hacer = false; if (preguntar) { var mbLatRef = MessageBox.Show(@"¿Desea cargar la información adicional ahora?", string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (mbLatRef == DialogResult.Yes) { hacer = true; } } else { hacer = true; } if (hacer) { try { using (var lateralesReferencia = new LateralesReferencia()) { lateralesReferencia.Referencia = _service.Referencia; lateralesReferencia.Lateral1 = _service.Lateral1; lateralesReferencia.Lateral2 = _service.Lateral2; if (forzarReferencia || forzarLaterales) { lateralesReferencia.UsaReferencia = forzarReferencia; lateralesReferencia.UsaLaterales = forzarLaterales; } else { lateralesReferencia.UsaReferencia = _service.ConReferencia.Validate(_service.Motivo.EsEntrega); // || forzarReferencia; lateralesReferencia.UsaLaterales = _service.ConLaterales.Validate(_service.Motivo.EsEntrega); // || forzarLaterales; } lateralesReferencia.Opcionales = (forzarReferencia && forzarLaterales); lateralesReferencia.ShowDialog(); if (lateralesReferencia.acepto) { if (lateralesReferencia.UsaReferencia) { _service.Referencia = lateralesReferencia.Referencia; } if (lateralesReferencia.UsaLaterales) { _service.Lateral1 = lateralesReferencia.Lateral1; _service.Lateral2 = lateralesReferencia.Lateral2; } _service.CalcularEstados(); if (_multiple) { foreach (Ruta r in _services) { if (lateralesReferencia.UsaReferencia) { r.Referencia = _service.Referencia; } if (lateralesReferencia.UsaLaterales) { r.Lateral1 = _service.Lateral1; r.Lateral2 = _service.Lateral2; } r.CalcularEstados(); } } sq.UpdateLateralesReferencia(_services); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public void TomarFoto(bool preguntar) { var sq = new SQLiteDataSet(); bool hacer = false; if (preguntar) { var mbFoto = MessageBox.Show(@"¿Desea sacar la foto ahora?", string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (mbFoto == DialogResult.Yes) { hacer = true; } } else { hacer = true; } if (hacer && Configuration.PhotoNeedsGps) { if (_services.Any(s => s.LlevaGPS && !s.TieneGPS)) { TomarGps(false); if (_services.Any(s => s.LlevaGPS && !s.TieneGPS)) { MessageBox.Show("No puede tomar la foto porque no tiene señal de GPS"); hacer = false; } } } if (hacer) { try { using (var camara = new Camara()) { camara.ShowDialog(); if (camara.Acepto) { _service.TieneFoto = true; _service.Foto = camara.Image; sq.UpdateFoto(_services); if (_multiple) { foreach (Ruta r in _services) { r.Foto = _service.Foto; r.CalcularEstados(); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }