Exemple #1
0
 public Boolean AnulaDB(tb_sis_impuesto_Info Info, ref string msg)
 {
     try
     {
         Boolean resultado = false;
         using (EntitiesGeneral context = new EntitiesGeneral())
         {
             var address = context.tb_sis_Impuesto.FirstOrDefault(q => q.IdCod_Impuesto == Info.IdCod_Impuesto);
             if (address != null)
             {
                 address.estado = false;
                 context.SaveChanges();
                 msg       = "Se ha procedido anular  #: " + Info.IdCod_Impuesto.ToString() + " exitosamente.";
                 resultado = true;
             }
         }
         return(resultado);
     }
     catch (Exception ex)
     {
         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() + " " + ex.Message;
         throw new Exception(ex.ToString());
     }
 }
Exemple #2
0
        public tb_sis_impuesto_Info Get_Info_impuesto(string IdCod_Impuesto)
        {
            try
            {
                tb_sis_impuesto_Info info = new tb_sis_impuesto_Info();

                EntitiesGeneral oEnti = new EntitiesGeneral();

                var bancos = from q in oEnti.tb_sis_Impuesto
                             where q.IdCod_Impuesto == IdCod_Impuesto
                             select q;
                foreach (var item in bancos)
                {
                    info.IdCod_Impuesto   = item.IdCod_Impuesto;
                    info.nom_impuesto     = item.nom_impuesto;
                    info.Usado_en_Ventas  = item.Usado_en_Ventas;
                    info.Usado_en_Compras = item.Usado_en_Compras;
                    info.porcentaje       = item.porcentaje;
                    info.IdCodigo_SRI     = item.IdCodigo_SRI;
                    info.estado           = item.estado;
                    info.IdTipoImpuesto   = item.IdTipoImpuesto;
                }
                return(info);
            }
            catch (Exception ex)
            {
                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() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
Exemple #3
0
        public Boolean ActualizarDB(tb_sis_impuesto_Info Info, ref string msg)
        {
            try
            {
                bool res = false;

                res = oData.ActualizarDB(Info, ref msg);

                if (res)
                {
                    tb_sis_Impuesto_x_ctacble_Data Bus_impu_x_cta = new tb_sis_Impuesto_x_ctacble_Data();
                    Bus_impu_x_cta.DeleteDB(Info.Info_sis_Impuesto_x_ctacble.IdEmpresa_cta, Info.IdCod_Impuesto);
                    Bus_impu_x_cta.GrabarDB(Info.Info_sis_Impuesto_x_ctacble, ref msg);
                }


                return(res);
            }
            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("", "ListaBancos", ex.Message), ex)
                      {
                          EntityType = typeof(tb_banco_Bus)
                      };
            }
        }
 public void SetInfo(tb_sis_impuesto_Info _Info_Impuesto)
 {
     try
     {
         Info_Impuesto = _Info_Impuesto;
     }
     catch (Exception ex)
     {
         Log_Error_bus.Log_Error(ex.ToString());
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #5
0
 public Boolean AnulaDB(tb_sis_impuesto_Info Info, ref string msg)
 {
     try
     {
         return(oData.AnulaDB(Info, ref msg));
     }
     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("", "ListaBancos", ex.Message), ex)
               {
                   EntityType = typeof(tb_banco_Bus)
               };
     }
 }
 void LimpiarDatos()
 {
     try
     {
         _Accion         = Cl_Enumeradores.eTipo_action.grabar;
         Info_Impuesto   = new tb_sis_impuesto_Info();
         txt_codigo.Text = "";
         txt_nombre.Text = "";
     }
     catch (Exception ex)
     {
         Log_Error_bus.Log_Error(ex.ToString());
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 public void gridViewConsultaCot_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
 {
     try
     {
         Info_Impuesto = new tb_sis_impuesto_Info();
         Info_Impuesto = GetSelectedRow((DevExpress.XtraGrid.Views.Grid.GridView)sender);
     }
     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());
     }
 }
Exemple #8
0
        public List <tb_sis_impuesto_Info> Get_List_impuesto_x_CtaCble(int IdEmpresa, string IdTipoImpuesto)
        {
            try
            {
                List <tb_sis_impuesto_Info> lst = new List <tb_sis_impuesto_Info>();

                EntitiesGeneral oEnti = new EntitiesGeneral();

                var bancos = from q in oEnti.tb_sis_Impuesto
                             join cta in oEnti.tb_sis_Impuesto_x_ctacble on q.IdCod_Impuesto equals cta.IdCod_Impuesto
                             where q.IdTipoImpuesto == IdTipoImpuesto &&
                             cta.IdEmpresa_cta == IdEmpresa
                             select new { cta.IdEmpresa_cta, q.IdCod_Impuesto, q.nom_impuesto, q.Usado_en_Ventas, q.Usado_en_Compras, q.porcentaje, q.IdCodigo_SRI, q.estado, q.IdTipoImpuesto
                                          , cta.IdCtaCble };

                foreach (var item in bancos)
                {
                    tb_sis_impuesto_Info info = new tb_sis_impuesto_Info();

                    info.IdCod_Impuesto   = item.IdCod_Impuesto;
                    info.nom_impuesto     = item.nom_impuesto;
                    info.Usado_en_Ventas  = item.Usado_en_Ventas;
                    info.Usado_en_Compras = item.Usado_en_Compras;
                    info.porcentaje       = item.porcentaje;
                    info.IdCodigo_SRI     = item.IdCodigo_SRI;
                    info.estado           = item.estado;
                    info.IdTipoImpuesto   = item.IdTipoImpuesto;
                    info.Info_sis_Impuesto_x_ctacble.IdCod_Impuesto = item.IdCod_Impuesto;
                    info.Info_sis_Impuesto_x_ctacble.IdCtaCble      = item.IdCtaCble;
                    info.Info_sis_Impuesto_x_ctacble.IdEmpresa_cta  = item.IdEmpresa_cta;

                    lst.Add(info);
                }
                return(lst);
            }
            catch (Exception ex)
            {
                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() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
 private void cmb_impuesto_EditValueChanged(object sender, EventArgs e)
 {
     try
     {
         if (cmb_impuesto.EditValue == null)
         {
             txt_porcentaje.Text = "0";
         }
         else
         {
             info_impuesto = lst_impuesto.FirstOrDefault(q => q.IdCod_Impuesto == cmb_impuesto.EditValue.ToString());
             if (info_impuesto != null)
             {
                 txt_porcentaje.Text = info_impuesto.porcentaje.ToString();
             }
         }
     }
     catch (Exception ex)
     {
         Log_Error_bus.Log_Error(ex.ToString());
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public void ucGe_Menu_Mantenimiento_x_usuario_event_btnAnular_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                Info_Impuesto = (tb_sis_impuesto_Info)gridView_Impuesto.GetFocusedRow();

                if (Info_Impuesto == null)
                {
                    MessageBox.Show(param.Get_Mensaje_sys(enum_Mensajes_sys.Por_favor_seleccione_item_a_consul), param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    Prepara_Formulario(Cl_Enumeradores.eTipo_action.Anular);
                }
            }
            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());
            }
        }
Exemple #11
0
        public Boolean ActualizarDB(tb_sis_impuesto_Info Info, ref string msg)
        {
            try
            {
                bool resultado = false;
                using (EntitiesGeneral context = new EntitiesGeneral())
                {
                    var address = context.tb_sis_Impuesto.FirstOrDefault(v => v.IdCod_Impuesto == Info.IdCod_Impuesto);
                    if (address != null)
                    {
                        address.nom_impuesto     = Info.nom_impuesto;
                        address.Usado_en_Ventas  = Info.Usado_en_Ventas;
                        address.Usado_en_Compras = Info.Usado_en_Compras;
                        address.porcentaje       = Info.porcentaje;
                        address.IdCodigo_SRI     = Info.IdCodigo_SRI;
                        address.estado           = Info.estado;
                        address.IdTipoImpuesto   = Info.IdTipoImpuesto;


                        context.SaveChanges();
                        msg       = "Se ha modificado el Banco #: " + address.IdCod_Impuesto.ToString() + " exitosamente.";
                        resultado = true;
                    }
                }
                return(resultado);
            }
            catch (Exception ex)
            {
                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() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
Exemple #12
0
        cl_parametrosGenerales_Bus()
        {
            try
            {
                try
                {
                    nom_pc = Dns.GetHostName();  //Obtengo el nombre de la PC solo aplica cuando el sistema corre dentro de la PC no para web
                    host   = Dns.GetHostEntry(Dns.GetHostName());
                    foreach (IPAddress ip_pc in host.AddressList)
                    {
                        if (ip_pc.AddressFamily.ToString() == "InterNetwork")
                        {
                            ip = ip_pc.ToString();
                        }
                    }
                }
                catch (Exception ex)
                {//continuar
                }


                BusMensaje.CompararEnum_vs_DB();

                listaMensaje   = BusMensaje.Get_List_sis_Mensajes_sys();
                listParametros = BusParametros.Get_List_parametro();

                Nombre_sistema = Get_Mensaje_sys(enum_Mensajes_sys.Nombre_sistema);
                string sIdIva = "";

                sIdIva = Convert.ToString(Get_Parametro_Info(tb_parametro_enum.P_IVA).Valor);


                tb_sis_impuesto_Bus  BusTipoImp   = new tb_sis_impuesto_Bus();
                tb_sis_impuesto_Info Info_TipoImp = new tb_sis_impuesto_Info();

                Info_TipoImp = BusTipoImp.Get_Info_impuesto(sIdIva);

                iva = Info_TipoImp;

                string SIdCliente_Vzen = "";


                try
                {
                    SIdCliente_Vzen = Convert.ToString(Get_Parametro_Info(tb_parametro_enum.P_CLIENTE_VZEN).Valor);
                }
                catch (Exception ex)
                {
                    BusParametros.GuardarDB(new tb_parametro_Info(tb_parametro_enum.P_CLIENTE_VZEN.ToString(), "string", Cl_Enumeradores.eCliente_Vzen.GENERAL.ToString()), ref mensaje);
                }

                if (SIdCliente_Vzen == null || SIdCliente_Vzen == "")
                {
                    IdCliente_Ven_x_Default = Cl_Enumeradores.eCliente_Vzen.GENERAL;
                }
                else
                {
                    IdCliente_Ven_x_Default = (Cl_Enumeradores.eCliente_Vzen)Enum.Parse(typeof(Cl_Enumeradores.eCliente_Vzen), SIdCliente_Vzen);
                }
            }
            catch (Exception ex)
            {
                // si se cae solo continuar
                //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("", "no se puede acceder a la base o ", ex.Message), ex) { EntityType = typeof(cl_parametrosGenerales_Bus) };
            }
        }
Exemple #13
0
        public Boolean Validar_objeto(com_ordencompra_local_Info Info, ref string msg)
        {
            try
            {
                if (Info.IdEmpresa == 0 || Info.IdSucursal == 0 || Info.IdProveedor == 0 || Info.IdDepartamento == 0)
                {
                    msg = "las variables estan en cero... Info.IdEmpresa == 0 || Info.IdSucursal == 0 || Info.IdProveedor == 0 || Info.IdDepartamento == 0 ";
                    return(false);
                }

                /*
                 * if (Info.IdMotivo == null || Info.IdMotivo == 0)
                 * {
                 *  msg = "Ingrese el motivo de la Compra";
                 *  com_Catalogo_Bus bUS = new com_Catalogo_Bus();
                 *  List<com_Catalogo_Info> listc = new List<com_Catalogo_Info>(bUS.Get_List_Catalogo());
                 *  return false;
                 *
                 * }*/

                if (Info.listDetalle.Count == 0)
                {
                    msg = "la OC no tiene items q grabar";
                    return(false);
                }

                int c = 0;

                foreach (var item in Info.listDetalle)
                {
                    if (item.do_Cantidad == 0)
                    {
                        msg = "Ingrese la cantidad al item : " + item.codproducto + "  ";
                        return(false);
                    }

                    if (item.do_precioCompra == 0)
                    {
                        msg = "Ingrese el costo al item : " + item.codproducto + "  ";
                        return(false);
                    }

                    if (item.IdUnidadMedida == "" || item.IdUnidadMedida == null)
                    {
                        in_producto_Bus  BusProducto  = new in_producto_Bus();
                        in_Producto_Info InfoProducto = new in_Producto_Info();
                        InfoProducto        = BusProducto.Get_info_Product(item.IdEmpresa, item.IdProducto);
                        item.IdUnidadMedida = InfoProducto.IdUnidadMedida;
                    }


                    if (item.IdCentroCosto == "")
                    {
                        item.IdCentroCosto = null;
                    }

                    if (item.IdCentroCosto_sub_centro_costo == "")
                    {
                        item.IdCentroCosto_sub_centro_costo = null;
                    }

                    if (item.IdCod_Impuesto == "" || item.IdCod_Impuesto == null) // Arreglando si no viene iva y codigo de iva
                    {
                        tb_sis_impuesto_Bus         BusImpuestoIva    = new tb_sis_impuesto_Bus();
                        List <tb_sis_impuesto_Info> ListInfo_Impuesto = new List <tb_sis_impuesto_Info>();
                        tb_sis_impuesto_Info        Info_Impuesto     = new tb_sis_impuesto_Info();
                        ListInfo_Impuesto = BusImpuestoIva.Get_List_impuesto_para_Compras("IVA");

                        Info_Impuesto       = ListInfo_Impuesto.FirstOrDefault();
                        item.IdCod_Impuesto = Info_Impuesto.IdCod_Impuesto;
                        item.Por_Iva        = Info_Impuesto.porcentaje;
                    }


                    //item.do_ManejaIva = (item.do_iva == 0) ? false : true;
                    c = c + 1;
                    item.Secuencia = c;


                    item.IdEmpresa     = Info.IdEmpresa;
                    item.IdSucursal    = Info.IdSucursal;
                    item.IdOrdenCompra = Info.IdOrdenCompra;
                }

                if (Info.IdMotivo == 0 && Info.IdMotivo == null)
                {
                    //consulta motivo compra
                    com_Motivo_Orden_Compra_Data        odataMoti = new com_Motivo_Orden_Compra_Data();
                    List <com_Motivo_Orden_Compra_Info> listMoti  = new List <com_Motivo_Orden_Compra_Info>();

                    listMoti = odataMoti.Get_List_Motivo_Orden_Compra(Info.IdEmpresa);
                    var itemMoti = listMoti.FirstOrDefault(q => q.IdMotivo == Info.IdMotivo);
                    Info.IdMotivo = itemMoti.IdMotivo;
                }


                if (Info.IdEstadoAprobacion_cat == "" || Info.IdEstadoAprobacion_cat == null)
                {
                    List <com_Catalogo_Info> listEstadoAproba = new List <com_Catalogo_Info>();
                    listEstadoAproba = CatCom.Get_ListEstadoAprobacion();
                    com_Catalogo_Info resEstadoApro = new com_Catalogo_Info();
                    resEstadoApro = listEstadoAproba.FirstOrDefault();
                    Info.IdEstadoAprobacion_cat = resEstadoApro.IdCatalogocompra;
                }

                if (Info.IdEstadoRecepcion_cat == "" || Info.IdEstadoRecepcion_cat == null)
                {
                    List <com_Catalogo_Info> listEstadoRecep = new List <com_Catalogo_Info>();
                    com_Catalogo_Info        resEstadoRece   = new com_Catalogo_Info();
                    listEstadoRecep            = CatCom.Get_ListEstadoRecepcion();
                    resEstadoRece              = listEstadoRecep.First();
                    Info.IdEstadoRecepcion_cat = resEstadoRece.IdCatalogocompra;
                }


                if (Info.IdTerminoPago == "" || Info.IdTerminoPago == null)
                {
                    List <com_TerminoPago_Info> listTerminoPago = new List <com_TerminoPago_Info>();
                    listTerminoPago = BusTerPago.Get_List_TerminoPago();
                    com_TerminoPago_Info TerminoPago = new com_TerminoPago_Info();
                    TerminoPago        = listTerminoPago.FirstOrDefault();
                    Info.IdTerminoPago = TerminoPago.IdTerminoPago;
                }


                if (Info.IdEstado_cierre == null || Info.IdEstado_cierre == "")
                {
                    com_estado_cierre_Bus busEstCierre = new com_estado_cierre_Bus();
                    com_parametro_Bus     paraBus      = new com_parametro_Bus();
                    string idestadoCierrexDefault      = "";
                    idestadoCierrexDefault = paraBus.Get_List_parametro(Info.IdEmpresa).FirstOrDefault().IdEstado_cierre;
                    Info.IdEstado_cierre   = busEstCierre.Get_List_estado_cierre().FirstOrDefault(v => v.IdEstado_cierre == idestadoCierrexDefault).IdEstado_cierre;
                }



                return(true);
            }
            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("", "Validar_objeto", ex.Message), ex)
                      {
                          EntityType = typeof(com_ordencompra_local_Bus)
                      };
            }
        }
        private void gridView_detalle_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                fa_proforma_det_Info row = (fa_proforma_det_Info)gridView_detalle.GetRow(e.RowHandle);
                if (row == null)
                {
                    return;
                }

                if (e.Column == col_IdProducto)
                {
                    in_Producto_Info row_producto = lst_producto.FirstOrDefault(q => q.IdProducto == row.IdProducto);
                    if (row_producto == null)
                    {
                        return;
                    }

                    #region Ver lote

                    if (row_producto.IdProducto_padre != null)
                    {
                        row_producto.IdSucursal = Convert.ToInt32(cmb_sucursal.EditValue);
                        row_producto.IdBodega   = Convert.ToInt32(cmb_bodega.EditValue);
                        FrmIn_producto_asignacion_lote frm = new FrmIn_producto_asignacion_lote();
                        frm.set_funcion(Cl_Enumeradores.eFuncion_pantalla_lote.SELECCIONAR);
                        frm.set_info(Convert.ToDecimal(row_producto.IdProducto_padre), row_producto.IdSucursal, row_producto.IdBodega);
                        frm.ShowDialog();
                        if (frm.Result == System.Windows.Forms.DialogResult.OK)
                        {
                            in_producto_lote info_retorno = frm.get_info_retorno();
                            if (info_retorno == null)
                            {
                                MessageBox.Show("No ha seleccionado ningún lote", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                return;
                            }
                            agregar_producto_en_combo(info_retorno.IdProducto == null ? 0 : Convert.ToDecimal(info_retorno.IdProducto));
                            int cont = lst_producto.Where(q => q.IdProducto == info_retorno.IdProducto).Count();
                            if (cont == 0)
                            {
                                MessageBox.Show("El producto seleccionado no esta habilitado para facturacion, comuníquese con sistemas", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                return;
                            }
                            row_producto   = lst_producto.FirstOrDefault(q => q.IdProducto == info_retorno.IdProducto);
                            row.IdProducto = info_retorno.IdProducto == null ? row_producto.IdProducto : Convert.ToDecimal(info_retorno.IdProducto);
                        }
                    }

                    #endregion

                    int nivel_precio = (cmb_cliente.get_ClienteInfo().NivelPrecio == null || cmb_cliente.get_ClienteInfo().NivelPrecio == 0) ? 1 : Convert.ToInt32(cmb_cliente.get_ClienteInfo().NivelPrecio);
                    switch (nivel_precio)
                    {
                    case 1:
                        row.pd_precio = row_producto.precio_1 == null ? 0 : Convert.ToDouble(row_producto.precio_1);
                        break;

                    case 2:
                        row.pd_precio = row_producto.precio_2 == null ? (row.pd_precio = row_producto.precio_1 == null ? 0 : Convert.ToDouble(row_producto.precio_1)) : Convert.ToDouble(row_producto.precio_2);
                        break;

                    case 3:
                        row.pd_precio = row_producto.precio_3 == null ? (row.pd_precio = row_producto.precio_1 == null ? 0 : Convert.ToDouble(row_producto.precio_1)) : Convert.ToDouble(row_producto.precio_3);
                        break;

                    case 4:
                        row.pd_precio = row_producto.precio_4 == null ? (row.pd_precio = row_producto.precio_1 == null ? 0 : Convert.ToDouble(row_producto.precio_1)) : Convert.ToDouble(row_producto.precio_4);
                        break;

                    case 5:
                        row.pd_precio = row_producto.precio_5 == null ? (row.pd_precio = row_producto.precio_1 == null ? 0 : Convert.ToDouble(row_producto.precio_1)) : Convert.ToDouble(row_producto.precio_5);
                        break;
                    }
                    row.IdCod_Impuesto = row_producto.IdCod_Impuesto_Iva;
                    tb_sis_impuesto_Info row_impuesto = lst_impuesto.FirstOrDefault(q => q.IdCod_Impuesto == row.IdCod_Impuesto);
                    if (row_impuesto != null)
                    {
                        row.pd_por_iva = row_impuesto.porcentaje;
                    }
                }

                if (e.Column == col_cantidad || e.Column == col_precio || e.Column == col_por_descuento)
                {
                    row.pd_descuento_uni = Math.Round((row.pd_precio * row.pd_por_descuento_uni) / 100, 2, MidpointRounding.AwayFromZero);
                    row.pd_precio_final  = row.pd_precio - row.pd_descuento_uni;
                    row.pd_subtotal      = row.pd_cantidad * row.pd_precio_final;
                    row.pd_iva           = Math.Round(Convert.ToDouble(row.pd_subtotal * (row.pd_por_iva / 100)), 2, MidpointRounding.AwayFromZero);
                    row.pd_total         = row.pd_subtotal + row.pd_iva;
                }

                if (e.Column == col_impuesto)
                {
                    tb_sis_impuesto_Info row_impuesto = lst_impuesto.FirstOrDefault(q => q.IdCod_Impuesto == row.IdCod_Impuesto);
                    if (row_impuesto != null)
                    {
                        row.pd_por_iva = row_impuesto.porcentaje;
                    }
                    row.pd_iva   = Math.Round(Convert.ToDouble(row.pd_subtotal * (row.pd_por_iva / 100)), 2, MidpointRounding.AwayFromZero);
                    row.pd_total = row.pd_subtotal + row.pd_iva;
                }
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.ToString(), param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #15
0
        private void gridView_factura_det_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                fa_factura_det_info row = (fa_factura_det_info)gridView_factura_det.GetRow(e.RowHandle);
                if (row == null)
                {
                    return;
                }
                if (e.Column == col_IdCod_Impuesto)
                {
                    tb_sis_impuesto_Info info_impuesto = lst_impuesto.FirstOrDefault(q => q.IdCod_Impuesto == row.IdCod_Impuesto_Iva);
                    if (info_impuesto == null)
                    {
                        row.IdCod_Impuesto_Iva = param.iva.IdCod_Impuesto;
                        row.vt_por_iva         = param.iva.porcentaje;
                    }
                    else
                    {
                        row.IdCod_Impuesto_Iva = info_impuesto.IdCod_Impuesto;
                        row.vt_por_iva         = info_impuesto.porcentaje;
                    }
                    row.vt_iva   = row.vt_Subtotal * (row.vt_por_iva == null ? 0 : Convert.ToDouble(row.vt_por_iva) / 100);
                    row.vt_total = row.vt_Subtotal + row.vt_iva;
                }

                if (e.Column == col_vt_cantidad || e.Column == col_vt_precio || e.Column == col_vt_por_des)
                {
                    row.vt_DescUnitario = (row.vt_cantidad * row.vt_Precio) * (row.vt_PorDescUnitario / 100);
                    row.vt_PrecioFinal  = row.vt_Precio - (row.vt_Precio * (row.vt_PorDescUnitario / 100));
                    row.vt_Subtotal     = (row.vt_cantidad * row.vt_Precio) - row.vt_DescUnitario;
                    row.vt_iva          = row.vt_Subtotal * (row.vt_por_iva == null ? 0 : Convert.ToDouble(row.vt_por_iva) / 100);
                    row.vt_total        = row.vt_Subtotal + row.vt_iva;
                }

                if (e.Column == col_IdPunto_cargo)
                {
                    ct_punto_cargo_Info info_punto_cargo = lst_punto_cargo.FirstOrDefault(q => q.IdPunto_cargo == row.IdPunto_cargo);
                    if (info_punto_cargo == null)
                    {
                        row.IdCentroCosto = null;
                        row.IdCentroCosto_sub_centro_costo = null;
                        row.IdPunto_cargo_grupo            = null;
                    }
                    else
                    {
                        row.IdCentroCosto = info_punto_cargo.IdCentroCosto_Scc;
                        row.IdCentroCosto_sub_centro_costo = info_punto_cargo.IdCentroCosto_sub_centro_costo_Scc;
                        row.IdPunto_cargo_grupo            = info_punto_cargo.IdPunto_cargo_grupo;
                    }
                }
            }
            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());
            }
        }
Exemple #16
0
        private void gridView_aprobacion_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                cp_Aprobacion_Ing_Bod_x_OC_det_Info row = (cp_Aprobacion_Ing_Bod_x_OC_det_Info)gridView_aprobacion.GetRow(e.RowHandle);
                if (row == null)
                {
                    return;
                }

                if (e.Column == col_IdProducto)
                {
                    if (row.IdProducto != null)
                    {
                        in_Producto_Info row_producto = lst_producto.FirstOrDefault(q => q.IdProducto == Convert.ToDecimal(row.IdProducto));
                        if (row_producto != null)
                        {
                            row.IdUnidadMedida     = row_producto.IdUnidadMedida;
                            row.IdCod_Impuesto_Iva = row_producto.IdCod_Impuesto_Iva;
                            tb_sis_impuesto_Info row_impuesto = lst_impuesto.FirstOrDefault(q => q.IdCod_Impuesto == row.IdCod_Impuesto_Iva);
                            if (row_impuesto != null)
                            {
                                row.PorIva = row_impuesto.porcentaje;
                            }
                            row.IdCtaCble_Gasto = row_producto.IdCtaCble_Gasto_x_cxp == null ? row_producto.IdCtaCble_Costo_categoria : row_producto.IdCtaCble_Gasto_x_cxp;
                            if (row.IdCtaCble_Gasto == null)
                            {
                                MessageBox.Show("El producto seleccionado no está parametrizado contablemente", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                gridView_aprobacion.DeleteSelectedRows();
                                return;
                            }
                        }
                    }
                }

                if (e.Column == col_cantidad || e.Column == col_costo || e.Column == col_por_descuento)
                {
                    row.Descuento      = Math.Round((row.Costo_uni * row.por_descuento) / 100, 2, MidpointRounding.AwayFromZero);
                    row.Cost_uni_final = Math.Round(row.Costo_uni - row.Descuento, 2, MidpointRounding.AwayFromZero);
                    row.SubTotal       = Math.Round(row.Cost_uni_final * row.Cantidad, 2, MidpointRounding.AwayFromZero);
                    row.valor_Iva      = Math.Round((row.SubTotal * row.PorIva) / 100, 2, MidpointRounding.AwayFromZero);
                    row.Total          = Math.Round(row.SubTotal + row.valor_Iva, 2, MidpointRounding.AwayFromZero);
                }

                if (e.Column == col_impuesto)
                {
                    tb_sis_impuesto_Info row_impuesto = lst_impuesto.FirstOrDefault(q => q.IdCod_Impuesto == row.IdCod_Impuesto_Iva);
                    if (row_impuesto != null)
                    {
                        row.PorIva = row_impuesto.porcentaje;
                    }
                    row.SubTotal  = Math.Round(row.Cost_uni_final * row.Cantidad, 2, MidpointRounding.AwayFromZero);
                    row.valor_Iva = Math.Round((row.SubTotal * row.PorIva) / 100, 2, MidpointRounding.AwayFromZero);
                    row.Total     = Math.Round(row.SubTotal + row.valor_Iva, 2, MidpointRounding.AwayFromZero);
                }
                calcular_totales();
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }