示例#1
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         using (Profit_RGEntities context = new Profit_RGEntities())
         {
             if (Nuevo == true)
             {
                 context.pInsertarMetas_Vtas(cboGrupo.Text, txtDesde.Value, txtHasta.Value, Convert.ToDecimal(txtMeta.Value), Convert.ToDecimal(txtTasa.Value));
                 Int32?Id = context.Metas_Vtas.OrderByDescending(p => p.id_meta).FirstOrDefault().id_meta;
                 foreach (var item in Le)
                 {
                     context.pInsertarEst_Diaria(item.fecha, Id, cboGrupo.SelectedText, item.porc, item.tasa_aju, item.diaria_aju);
                 }
             }
             else
             {
                 context.pActualizarMetas_Vtas(cboGrupo.Text, txtDesde.Value, txtHasta.Value, Convert.ToDecimal(txtMeta.Value), Convert.ToDecimal(txtTasa.Value), Meta.rowguid);
                 context.pEliminarEst_Diaria(Meta.id_meta);
                 foreach (var item in Le)
                 {
                     context.pInsertarEst_Diaria(item.fecha, Meta.id_meta, cboGrupo.Text, item.porc, item.tasa_aju, item.diaria_aju);
                 }
             }
         }
         MessageBox.Show(this, "Se ha guardado la información satisfactoriamente.", "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Information);
         Navegar(5);
     }
     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);
     }
 }