public bool guardarDB(ct_distribucion_gastos_x_periodo_det_Info info) { try { using (EntitiesContabilidad_FJ Context = new EntitiesContabilidad_FJ()) { ct_distribucion_gastos_x_periodo_det Entity = new ct_distribucion_gastos_x_periodo_det(); Entity.IdEmpresa = info.IdEmpresa; Entity.IdDistribucion = info.IdDistribucion; Entity.Secuencia = info.Secuencia = get_id(info.IdEmpresa, info.IdDistribucion); Entity.IdCtaCble = info.IdCtaCble; Entity.IdPunto_cargo = info.IdPunto_cargo; Entity.valor = info.valor; Context.ct_distribucion_gastos_x_periodo_det.Add(Entity); Context.SaveChanges(); } return(true); } catch (Exception ex) { string mensaje = ""; string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString(); throw new Exception(ex.ToString()); } }
public bool guardarDB(ct_distribucion_gastos_x_periodo_det_Info info) { try { return(oData.guardarDB(info)); } catch (Exception ex) { Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message); throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "get_list", ex.Message), ex) { EntityType = typeof(ct_distribucion_gastos_x_periodo_det_Bus) }; } }
private void gridView_distribucion_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Delete) { if (MessageBox.Show("¿Está seguro que desea eliminar este registro ?", param.Nombre_sistema, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ct_distribucion_gastos_x_periodo_det_Info row = (ct_distribucion_gastos_x_periodo_det_Info)gridView_distribucion.GetFocusedRow(); bus_distribucion_det.eliminarDB(row.IdEmpresa, row.IdDistribucion, row.Secuencia); gridView_distribucion.DeleteSelectedRows(); } } } catch (Exception ex) { string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; NameMetodo = NameMetodo + " - " + ex.ToString(); MessageBox.Show(NameMetodo + " " + param.Get_Mensaje_sys(enum_Mensajes_sys.Error_comunicarse_con_sistemas) , param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString()); } }
private bool distribuir() { try { splashScreenManager1.ShowWaitForm(); if (txt_IdDistribucion.Text == "") { get_info(); if (!GuardarDB()) { return(false); } } foreach (var cuenta in blst_gastos.Where(q => q.Checked == true).ToList()) { cuenta.valor_aux = Math.Abs(cuenta.valor); int contador = blst_punto_cargo.Where(q => q.Checked == true).Count(); int cont = 1; foreach (var punto_cargo in blst_punto_cargo.Where(q => q.Checked == true).ToList()) { ct_distribucion_gastos_x_periodo_det_Info new_det = new ct_distribucion_gastos_x_periodo_det_Info(); new_det.IdEmpresa = param.IdEmpresa; new_det.IdDistribucion = info_distribucion.IdDistribucion; new_det.IdCtaCble = cuenta.IdCtaCble; new_det.IdPunto_cargo = punto_cargo.IdPunto_cargo; if (Math.Abs((cuenta.valor * (punto_cargo.porcentaje / 100))) < 3) { new_det.valor = cuenta.valor; cuenta.valor_aux = 0; } else { if (cont == contador) { new_det.valor = cuenta.valor < 0 ? cuenta.valor_aux * -1 : cuenta.valor_aux; cuenta.valor_aux = 0; } else { new_det.valor = Math.Round(cuenta.valor * (punto_cargo.porcentaje / 100), 2, MidpointRounding.AwayFromZero); cuenta.valor_aux = Math.Abs(cuenta.valor_aux) < Math.Abs(new_det.valor) ? 0 : Math.Abs(cuenta.valor_aux) - Math.Abs(new_det.valor); } } bus_distribucion_det.guardarDB(new_det); cont++; if (cuenta.valor_aux == 0) { break; } } } Accion = Cl_Enumeradores.eTipo_action.actualizar; buscar(); Cargar_combo(); set_info_in_controls(); splashScreenManager1.CloseWaitForm(); return(true); } catch (Exception ex) { if (splashScreenManager1.IsSplashFormVisible) { splashScreenManager1.CloseWaitForm(); } string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; NameMetodo = NameMetodo + " - " + ex.ToString(); MessageBox.Show(NameMetodo + " " + param.Get_Mensaje_sys(enum_Mensajes_sys.Error_comunicarse_con_sistemas) , param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString()); return(false); } }