Example #1
0
        //public Profit_RGEntities buscar_mtto()
        // {
        //     try
        //     {
        //         using (var context = new Profit_RGEntities())
        //         {
        //             var a = from n in context.GIT_Mantenimiento where n.id_mtto == context.pSeleccionarGIT_IDmtto().Count() select n.id_mtto;
        //         }
        //         return buscar_mtto();
        //     }
        //     catch (Exception)
        //     {

        //         throw;
        //     }

        // }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                using (Profit_RGEntities context = new Profit_RGEntities())
                {
                    Boolean buscar99 = false;
                    foreach (var item in mtto55)
                    {
                        buscar99 = context.pSeleccionarGIT_Mantenimiento(item.idactivo.Trim()).Count(u => u.Rowguid.ToString().ToUpper() == item.Rowguid.ToUpper()) > 0;
                        //   buscar99 = context.GIT_Mantenimiento.Count(i => i.id_mtto == item.codigoM) > 0;
                        //  var a = from n in context.GIT_Mantenimiento where n.id_mtto == item.codigoM select n.id_mtto;


                        if (buscar99 == false)      //&& context.pSeleccionarGIT_Mantenimiento(lActivo).Select (x => x.Rowguid).Count() <= 0)
                        {
                            context.pGIT_MantenimientoInsertar(item.idactivo, item.fec_emis, item.observacion, Convert.ToDecimal(item.valor), item.asesor, item.consultor,
                                                               item.problema, item.solucion);
                        }
                        else
                        {
                            context.pGIT_MantenimientoActualizar(item.idactivo, item.fec_emis, item.observacion, Convert.ToDecimal(item.valor), item.asesor, item.consultor,
                                                                 item.problema, item.solucion, Guid.Parse(item.Rowguid));
                        }
                    }
                    //  CargarMantenimiento();
                }

                MessageBox.Show(this, "Se ha guardado la informaciĆ³n satisfactoriamente.", "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (EntityException ex)
            {
                MessageBox.Show(ex.InnerException.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }