Example #1
0
        private void bunifuImageButton1_Click(object sender, EventArgs e)
        {
            int nro_ent = 0;

            nro_ent = Convert.ToInt32(DB_socios.entregas_mochilas.Max(x => x.numero_entrega).ToString() + 1);
            var im = from a in DB_socios.impresion_comprobante where a.nro_entrega >= 0 select a;

            //limpio la tabla de impresion
            foreach (var item in im)
            {
                DB_socios.impresion_comprobante.DeleteOnSubmit(item);
                DB_socios.SubmitChanges();
            }
            foreach (DataGridViewRow fila in dgv_familiar_a_cargo_mochilas.Rows)
            {
                if ((fila.Cells["entregar_mochila"].Value != null) && (Convert.ToInt32(fila.Cells["entregada"].Value.ToString()) == 1))
                {
                    //grabo en impresiones_comprobantes
                    impresion_comprobante imp_comp = new impresion_comprobante();
                    imp_comp.nro_entrega   = nro_ent;
                    imp_comp.nro_socio     = Convert.ToInt32(txt_nro_socio.Text);
                    imp_comp.socio_apenom  = txt_ape_nom.Text;
                    imp_comp.socio_dni     = txt_dni_socio.Text;
                    imp_comp.socio_empresa = txt_empresa.Text;
                    imp_comp.benef_apenom  = fila.Cells["ayn"].Value.ToString();
                    imp_comp.benef_dni     = fila.Cells["dni_beneficiario"].Value.ToString();
                    imp_comp.benef_edad    = Convert.ToInt32(fila.Cells["edad"].Value.ToString());
                    string mo = fila.Cells["mochila"].Value.ToString();
                    imp_comp.benef_tipo_mochila = mo.Substring(12, mo.Length - 12);
                    imp_comp.benef_sexo         = DB_soc_mysql.maeflia.Where(x => x.MAEFLIA_CODFLIAR == Convert.ToInt16(fila.Cells["codigo_familiar"].Value.ToString())).Single().MAEFLIA_SEXO.ToString();
                    imp_comp.benef_legajo       = DB_socios.entregas_mochilas.Where(x => x.cod_fliar == Convert.ToInt16(fila.Cells["codigo_familiar"].Value.ToString())).Single().legajo;
                    if (DB_socios.entregas_mochilas.Where(x => x.cod_fliar == Convert.ToInt16(fila.Cells["codigo_familiar"].Value.ToString())).Single().fondo_desempleo != null)
                    {
                        imp_comp.benef_fdo_desempleo = "SI";
                    }
                    else
                    {
                        imp_comp.benef_fdo_desempleo = "NO";
                    }
                    imp_comp.comentario = DB_socios.entregas_mochilas.Where(x => x.cod_fliar == Convert.ToInt16(fila.Cells["codigo_familiar"].Value.ToString())).Single().comentario;
                    DB_socios.impresion_comprobante.InsertOnSubmit(imp_comp);
                    DB_socios.SubmitChanges();
                    calcular_cant_entregas();
                    calcular_totales();
                }
            }
            reportes frm_reportes = new reportes();

            frm_reportes.ShowDialog();
        }
Example #2
0
        private void btn_entrgar_mochila_Click(object sender, EventArgs e)
        {
            int b       = 0;
            int nro_ent = 0;

            nro_ent = Convert.ToInt32(DB_socios.entregas_mochilas.Max(x => x.numero_entrega).ToString() + 1);
            var im = from a in DB_socios.impresion_comprobante where a.nro_entrega >= 0 select a;

            //limpio la tabla de impresion
            foreach (var item in im)
            {
                DB_socios.impresion_comprobante.DeleteOnSubmit(item);
                DB_socios.SubmitChanges();
            }
            foreach (DataGridViewRow fila in dgv_familiar_a_cargo_mochilas.Rows)
            {
                if ((fila.Cells["entregar_mochila"].Value != null) && (Convert.ToInt32(fila.Cells["entregada"].Value.ToString()) == 0))
                {
                    // busco en la tabla entregas_mochilas por codfliar y verifico si se encontro
                    var se_recibio_documentacion = DB_socios.entregas_mochilas.Where(x => x.cod_fliar == Convert.ToInt16(fila.Cells["codigo_familiar"].Value.ToString()));
                    if (se_recibio_documentacion.Count() > 0)
                    {
                        // Ya esta encontrada la mochila de ese beneficiario y verifico no fue entregada
                        var se_recibio_documentacion_1 = DB_socios.entregas_mochilas.Where(x => x.cod_fliar == Convert.ToInt16(fila.Cells["codigo_familiar"].Value.ToString())).Single();
                        if (se_recibio_documentacion_1.entrega_mochila is null)
                        {
                            //  se encontro el registro en la tabla de entregas_mochilas por que se recibio documentacion y no fue entragada aun, entonces cargo la entrega solamente
                            entregas_mochilas entrega_mochi_1 = DB_socios.entregas_mochilas.Where(x => x.cod_fliar == Convert.ToInt16(fila.Cells["codigo_familiar"].Value.ToString())).Single();
                            entrega_mochi_1.entrega_mochila       = true;
                            entrega_mochi_1.fecha_entrega_mochila = DateTime.Now;
                            DB_socios.SubmitChanges();
                        }
                    }
                    else
                    {
                        // NO se encontro el registro en la tabla de entregas_mochilas entonces cargo los datos necesarios
                        entregas_mochilas entrega_mochi = new entregas_mochilas();
                        entrega_mochi.cod_fliar                = Convert.ToInt16(fila.Cells["codigo_familiar"].Value.ToString());
                        entrega_mochi.nro_doc_fliar            = Convert.ToInt32(fila.Cells["dni_beneficiario"].Value.ToString());
                        entrega_mochi.recibe_docum             = true;
                        entrega_mochi.fecha_recepcion_docum    = DateTime.Now;
                        entrega_mochi.tipo_mochila             = Convert.ToInt16(fila.Cells["mochila"].Value.ToString().Substring(0, 1));
                        entrega_mochi.codigo_usuario_recepcion = 0;
                        entrega_mochi.legajo = txt_legajo.Text;
                        if (chk_fdo_desempleo.Checked)
                        {
                            entrega_mochi.fondo_desempleo = 1;
                        }
                        entrega_mochi.comentario            = txt_comentario.Text;
                        entrega_mochi.entrega_mochila       = true;
                        entrega_mochi.fecha_entrega_mochila = DateTime.Now;
                        DB_socios.entregas_mochilas.InsertOnSubmit(entrega_mochi);
                        DB_socios.SubmitChanges();
                        calcular_cant_entregas();
                    }

                    //grabo en impresiones_comprobantes
                    impresion_comprobante imp_comp = new impresion_comprobante();
                    imp_comp.nro_entrega        = nro_ent;
                    imp_comp.nro_socio          = Convert.ToInt32(txt_nro_socio.Text);
                    imp_comp.socio_apenom       = txt_ape_nom.Text;
                    imp_comp.socio_dni          = txt_dni_socio.Text;
                    imp_comp.socio_empresa      = txt_empresa.Text;
                    imp_comp.benef_apenom       = fila.Cells["ayn"].Value.ToString();
                    imp_comp.benef_dni          = fila.Cells["dni_beneficiario"].Value.ToString();
                    imp_comp.benef_edad         = Convert.ToInt32(fila.Cells["edad"].Value.ToString());
                    imp_comp.benef_tipo_mochila = fila.Cells["mochila"].Value.ToString().Substring(3);
                    imp_comp.benef_sexo         = DB_soc_mysql.maeflia.Where(x => x.MAEFLIA_CODFLIAR == Convert.ToInt16(fila.Cells["codigo_familiar"].Value.ToString())).Single().MAEFLIA_SEXO.ToString();
                    imp_comp.benef_legajo       = DB_socios.entregas_mochilas.Where(x => x.cod_fliar == Convert.ToInt16(fila.Cells["codigo_familiar"].Value.ToString())).Single().legajo;
                    if (DB_socios.entregas_mochilas.Where(x => x.cod_fliar == Convert.ToInt16(fila.Cells["codigo_familiar"].Value.ToString())).Single().fondo_desempleo != null)
                    {
                        imp_comp.benef_fdo_desempleo = "SI";
                    }
                    else
                    {
                        imp_comp.benef_fdo_desempleo = "NO";
                    }
                    imp_comp.comentario = DB_socios.entregas_mochilas.Where(x => x.cod_fliar == Convert.ToInt16(fila.Cells["codigo_familiar"].Value.ToString())).Single().comentario;
                    DB_socios.impresion_comprobante.InsertOnSubmit(imp_comp);
                    DB_socios.SubmitChanges();
                    calcular_cant_entregas();
                    b = 1;
                }
            }
            if (b == 1)
            {
                reportes frm_reportes = new reportes();
                frm_reportes.ShowDialog();
            }
        }