public string ModificarGastos(Gastos gasto)
 {
     string gastoModificado = string.Empty;
     string fichaInsertada = string.Empty;
     string fechaAEnviar = gasto.FechaGastos.Year + "-" + gasto.FechaGastos.Month + "-" + gasto.FechaGastos.Day;
     //{"indice":1,"idPersona":1,"conceptoGasto":"Colacion","montoGasto":2000,"descuentoGasto":0,"fechaGasto":"2013-11-23"}
     this.JsonParam = "send={\"indice\":2,\"idGasto\":" + gasto.IdGastos + ",\"idPersona\":" + gasto.IdPersona + ",\"conceptoGasto\":\"" + gasto.ConceptodeGastos + " \",\"montoGasto\":" + gasto.MontoGastos + ",\"descuentoGasto\":" + gasto.DescuentoGastos + ",\"fechaGasto\":\"" + fechaAEnviar + "\"}";
     try
     {
         String result = netclient.NetPost("ws-gastos.php", this.JsonParam);
         var jobject = JObject.Parse(result);
         //{"code":7,"Modificado":"Modificado"}
         gastoModificado = jobject.SelectToken("idGastoModificado").ToString();
     }
     catch (Exception e)
     {
         throw new Exception(e + "| Error al Modificar Gasto");
     }
     return gastoModificado;
 }
        public List<Gastos> ListarGastos()
        {
            List<Gastos> list = new List<Gastos>();
            try
            {
                this.JsonParam = "{\"indice\":6}";
                String result = netclient.NetPost("ws-area-insumo-listas.php", this.JsonParam);
                var jobject = JObject.Parse(result);
                var token = jobject.SelectToken("listaGastos").ToList();
                foreach (var item in token)
                {
                    Gastos gastos = new Gastos();
                    //{"idGasto":1,"concepto":""}
                    gastos.IdGastos = Convert.ToInt32(item.SelectToken("idGasto").ToString());
                    gastos.ConceptodeGastos = item.SelectToken("concepto").ToString();
                    list.Add(gastos);
                }

            }
            catch (Exception e)
            {
                throw new Exception(e + "| Error al Listar Gastos");
            }
            return list;
        }
        public List<Gastos> ListarGastosporFechas(DateTime fecha1, DateTime fecha2)
        {
            List<Gastos> list = new List<Gastos>();
            try
            {
                string fechaSend = fecha1.Year + "-" + fecha1.Month + "-" + fecha1.Day;
                string fechaSend2 = fecha2.Year + "-" + fecha2.Month + "-" + fecha2.Day;
                this.JsonParam = "{\"indice\":7,\"fechaInicio\":\"" + fechaSend + "\",\"fechaTermino\":\"" + fechaSend2 + "\"}";
                String result = netclient.NetPost("ws-reportes.php", this.JsonParam);
                var jobject = JObject.Parse(result);
                var token = jobject.SelectToken("abonos").ToList();
                Gastos gasto = new Gastos();
                foreach (var item in token)
                {
                    //{"idGastos":2,"idPersona":1,"conceptoGasto":"Colacion casa","montoGastos":2000,"descuentoGastos":0,"nomPersona":"","apellidoPersona":"","fechaGasto":"2013-11-16"}

                    gasto.IdGastos = Convert.ToInt32(item.SelectToken("idGastos").ToString());
                    gasto.IdPersona = Convert.ToInt32(item.SelectToken("idPersona").ToString());
                    gasto.ConceptodeGastos = item.SelectToken("conceptoGasto").ToString();
                    gasto.MontoGastos = Convert.ToInt32(item.SelectToken("montoGastos").ToString());
                    gasto.DescuentoGastos = Convert.ToInt32(item.SelectToken("descuentoGastos").ToString());
                    gasto.FechaGastos = Convert.ToDateTime(item.SelectToken("fechaGasto").ToString());
                    list.Add(gasto);
                }

            }
            catch (Exception e)
            {
                throw new Exception(e + "| Error al Listar Gastos");
            }
            return list;
        }
Example #4
0
        private void btnNuevo_Click(object sender, EventArgs e)
        {
            if (btnNuevo.Text.ToString().Trim() == "Ingresar Gastos")
            {
                Gastos gasto = new Gastos();
                gasto.IdPersona = Convert.ToInt32(cmbxpersona.SelectedValue);
                gasto.ConceptodeGastos = txtConcept.Text.ToString();
                gasto.MontoGastos = int.Parse(txtMonto.Text.ToString());
                gasto.DescuentoGastos = int.Parse(txtDescuento.Text.ToString());
                gasto.FechaGastos = MntCalendarGastos.SelectionStart;
                this.client_gastos.InsertarGatos(gasto);
                this.dataGridGastos.DataSource = this.client_gastos.ListarGastos();
                this.LimpiarControles();
                MessageBox.Show("Gasto registrado satisfactoriamente", "SFH Administración de Clínica - Administración de Área insumos", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            else if (btnNuevo.Text.ToString().Trim() == "Guardar Cambios")
            {
                Gastos gasto = new Gastos();
                gasto.IdGastos = this.Id_gastos;
                gasto.IdPersona = Convert.ToInt32(cmbxpersona.SelectedValue);
                gasto.ConceptodeGastos = txtConcept.Text.ToString();
                gasto.MontoGastos = int.Parse(txtMonto.Text.ToString());
                gasto.DescuentoGastos = int.Parse(txtDescuento.Text.ToString());
                gasto.FechaGastos = MntCalendarGastos.SelectionStart;
                this.client_gastos.ModificarGastos(gasto);
                this.dataGridGastos.DataSource = this.client_gastos.ListarGastos();
                this.LimpiarControles();
                MessageBox.Show("Gasto modificado satisfactoriamente", "SFH Administración de Clínica - Administración de Área insumos", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
        public List<Gastos> ListarGastos()
        {
            List<Gastos> list = new List<Gastos>();
            try
            {
                this.JsonParam = "send={\"indice\":3}";
                String result = netclient.NetPost("ws-gastos.php", this.JsonParam);
                var jobject = JObject.Parse(result);
                var token = jobject.SelectToken("listaGastos").ToList();
                foreach (var item in token)
                {
                    Gastos gasto = new Gastos();
                    //{"idGastos":2,"idPersona":1,"conceptoGasto":"","montoGastos":30000,"descuentoGastos":40000,"nomPersona":"Ada","apellidoPersona":"Tatus"}

                    gasto.IdGastos = Convert.ToInt32(item.SelectToken("idGastos").ToString());
                    gasto.IdPersona = Convert.ToInt32(item.SelectToken("idPersona").ToString());
                    gasto.ConceptodeGastos = item.SelectToken("conceptoGasto").ToString();
                    gasto.MontoGastos = Convert.ToInt32(item.SelectToken("montoGastos").ToString());
                    gasto.DescuentoGastos = Convert.ToInt32(item.SelectToken("descuentoGastos").ToString());
                    gasto.Nombre = item.SelectToken("nomPersona").ToString();
                    gasto.Apellido = item.SelectToken("apellidoPersona").ToString();
                    gasto.FechaGastos = Convert.ToDateTime(item.SelectToken("fechaGasto").ToString());
                    list.Add(gasto);
                }

            }
            catch (Exception e)
            {
                throw new Exception(e + "| Error al Listar Gastos");
            }
            return list;
        }
Example #6
0
 private void btnNuevo_Click(object sender, EventArgs e)
 {
     if (btnNuevo.Text.ToString().Trim() == "Ingresar Gastos")
     {
         try
         {
             if (this.validarformulario() == true)
             {
                 String resultadoI = string.Empty;
                 Gastos gasto = new Gastos();
                 gasto.IdPersona = Convert.ToInt32(cmbxpersona.SelectedValue);
                 gasto.ConceptodeGastos = txtConcept.Text.ToString();
                 gasto.MontoGastos = int.Parse(txtMonto.Text.ToString());
                 gasto.DescuentoGastos = int.Parse(txtDescuento.Text.ToString());
                 gasto.FechaGastos = MntCalendarGastos.SelectionStart;
                 resultadoI = this.client_gastos.InsertarGatos(gasto);
                 if (resultadoI != string.Empty)
                 {
                     this.dataGridGastos.DataSource = this.client_gastos.ListarGastos();
                     this.LimpiarControles();
                     MessageBox.Show("Gasto ingresado correctamente.", "SFH Administración de Clínica - Administración de Gastos", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     MessageBox.Show("Se produjo un error, vuelva a intentarlo.", "SFH Administración de Clínica - Administración de Gastos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
         catch
         {
             MessageBox.Show("Se produjo un error, vuelva a intentarlo.", "SFH Administración de Clínica - Administración de Gastos", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else if (btnNuevo.Text.ToString().Trim() == "Guardar Cambios")
     {
         try
         {
             if (this.validarformulario() == true)
             {
                 String resultadoM = string.Empty;
                 Gastos gasto = new Gastos();
                 gasto.IdGastos = this.Id_gastos;
                 gasto.IdPersona = Convert.ToInt32(cmbxpersona.SelectedValue);
                 gasto.ConceptodeGastos = txtConcept.Text.ToString();
                 gasto.MontoGastos = int.Parse(txtMonto.Text.ToString());
                 gasto.DescuentoGastos = int.Parse(txtDescuento.Text.ToString());
                 gasto.FechaGastos = MntCalendarGastos.SelectionStart;
                 resultadoM = this.client_gastos.ModificarGastos(gasto);
                 if (resultadoM != string.Empty)
                 {
                     this.dataGridGastos.DataSource = this.client_gastos.ListarGastos();
                     this.LimpiarControles();
                     MessageBox.Show("Gasto modificado correctamente.", "SFH Administración de Clínica - Administración de Gastos", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     MessageBox.Show("Se produjo un error, vuelva a intentarlo.", "SFH Administración de Clínica - Administración de Gastos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
         catch
         {
             MessageBox.Show("Se produjo un error, vuelva a intentarlo.", "SFH Administración de Clínica - Administración de Gastos", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }