private void ucGe_Menu_Mantenimiento_MotivoVenta_event_btnAnular_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { //asigna un valor a una variable para realizar la busqueda MotivoVenta_Info = (fa_motivo_venta_Info)this.gridViewMotivoVenta.GetFocusedRow(); //Pregunta si esta seleccionado un registro if (MotivoVenta_Info == null) { MessageBox.Show("Por Favor seleccione un registro.", "Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (MotivoVenta_Info.Estado != "I") { Preparar_Formulario(Cl_Enumeradores.eTipo_action.Anular); } else { MessageBox.Show("El registro seleccionado ya se encuentra anulado.\n\n Por favor seleccione otro registro.", "Sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); MessageBox.Show("Error comunicarse con Sistemas " + ex.Message + " ", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Boolean Get_List_fa_motivo_venta_Existe(fa_motivo_venta_Info Info, ref string mensaje) { try { using (EntitiesFacturacion context = new EntitiesFacturacion()) { var select = from q in context.fa_motivo_venta where q.codMotivo_Vta == Info.codMotivo_Vta select q; if (select.Count() > 0) { return(false); } return(true); } } catch (Exception ex) { string arreglo = ToString(); string MensajeError = string.Empty; 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); MensajeError = ex.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref MensajeError); throw new Exception(ex.ToString()); } }
public Boolean AnularDB(fa_motivo_venta_Info Info, ref string msg) { try { using (EntitiesFacturacion context = new EntitiesFacturacion()) { var motivo = context.fa_motivo_venta.FirstOrDefault(v => v.IdMotivo_Vta == Info.IdMotivo_Vta); if (motivo != null) { motivo.Estado = "I"; motivo.UsuarioAnulacion = Info.UsuarioAnulacion; motivo.FechaAnulacion = DateTime.Now; motivo.MotivoAnulacion = Info.MotivoAnulacion; context.SaveChanges(); msg = "Se ha eliminado el registro: " + Info.IdMotivo_Vta.ToString() + " con exito"; } return(true); } } 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); msg = ex.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref msg); msg = "Se ha producido el siguiente error: " + ex.Message; throw new Exception(ex.ToString()); } }
public Boolean Anular() { try { if (MotivoVenta_Info.Estado == "I") { MessageBox.Show("El registro ya se encuentra anulado", "Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { if (MessageBox.Show("¿Está seguro que desea anular el Tipo de Rubro #:" + txt_IdMotivo.Text.Trim() + " ?", "Anulación de Mantenimiento Tipo Rubro", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { FrmGe_MotivoAnulacion fr = new FrmGe_MotivoAnulacion(); fr.ShowDialog(); fa_motivo_venta_Bus neg = new fa_motivo_venta_Bus(); fa_motivo_venta_Info moInfo = new fa_motivo_venta_Info(); string mensaje = string.Empty; moInfo = Get_Motivo_Venta(ref mensaje); if (mensaje != "") { MessageBox.Show("Error " + mensaje, "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Information); } moInfo.UsuarioAnulacion = param.IdUsuario; moInfo.MotivoAnulacion = fr.motivoAnulacion; bool resultado = neg.Anular(moInfo, ref mensaje); if (resultado) { MessageBox.Show(mensaje, "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Information); this.ucGe_Menu_Superior_Mant1.Visible_bntGuardar_y_Salir = false; this.ucGe_Menu_Superior_Mant1.Visible_btnGuardar = false; } else { Log_Error_bus.Log_Error(mensaje.ToString()); MessageBox.Show("Error " + mensaje, "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(true); } else { return(false); } } } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); MessageBox.Show(ex.Message); return(false); } }
public void Set_Motivo_Venta(fa_motivo_venta_Info Motivo) { try { MotivoVenta_Info = Motivo; } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); MessageBox.Show(ex.ToString()); } }
public Boolean Guardar() { bool resultado = false; try { fa_motivo_venta_Info InfoMotivo = new fa_motivo_venta_Info(); fa_motivo_venta_Bus BusMotivo = new fa_motivo_venta_Bus(); mensaje = ""; int id = 0; InfoMotivo = Get_Motivo_Venta(ref mensaje); if (mensaje != "") { MessageBox.Show(mensaje); return(false); } if (BusMotivo.Get_List_fa_motivo_venta_Existe(InfoMotivo, ref mensaje)) { resultado = BusMotivo.Grabar(InfoMotivo, ref id, ref mensaje); txt_IdMotivo.Text = id.ToString(); } else { MessageBox.Show("el codigo ingresado: " + InfoMotivo.codMotivo_Vta.ToString() + " ya existe.\nPor favor ingrese un codigo diferente"); } if (resultado == true) { MessageBox.Show(mensaje, " Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Information); this.ucGe_Menu_Superior_Mant1.Visible_bntGuardar_y_Salir = true; this.ucGe_Menu_Superior_Mant1.Visible_btnGuardar = true; } else { Log_Error_bus.Log_Error(mensaje.ToString()); MessageBox.Show("Error " + mensaje, "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(resultado); } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); MessageBox.Show(ex.Message); return(false); } }
public Boolean Anular(fa_motivo_venta_Info Info, ref string msg) { try { return(Data.AnularDB(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("", "Anular", ex.Message), ex) { EntityType = typeof(fa_motivo_venta_Bus) }; } }
public Boolean Get_List_fa_motivo_venta_Existe(fa_motivo_venta_Info Info, ref string mensaje) { try { return(Data.Get_List_fa_motivo_venta_Existe(Info, ref mensaje)); } 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("", "Grabar", ex.Message), ex) { EntityType = typeof(fa_motivo_venta_Bus) }; } }
public fa_motivo_venta_Info get_Info() { try { Info = new fa_motivo_venta_Info(); if (cmbMotivo_Vta.EditValue != null) { Info = listMotivo.FirstOrDefault(v => v.IdMotivo_Vta == Convert.ToDecimal(cmbMotivo_Vta.EditValue)); } return(Info); } catch (Exception ex) { string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; MessageBox.Show(NameMetodo + " - " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString()); return(new fa_motivo_venta_Info()); } }
public List <fa_motivo_venta_Info> Get_List_fa_motivo_venta(int IdEmpresa) { try { List <fa_motivo_venta_Info> Lst = new List <fa_motivo_venta_Info>(); EntitiesFacturacion oEnti = new EntitiesFacturacion(); var Query = from q in oEnti.fa_motivo_venta where q.IdEmpresa == IdEmpresa select q; foreach (var item in Query) { fa_motivo_venta_Info Obj = new fa_motivo_venta_Info(); Obj.IdEmpresa = item.IdEmpresa; Obj.IdMotivo_Vta = item.IdMotivo_Vta; Obj.codMotivo_Vta = item.codMotivo_Vta; Obj.Estado = item.Estado; Obj.descripcion_motivo_vta = item.descripcion_motivo_vta; Obj.FechaModificacion = Convert.ToDateTime(item.FechaModificacion); Obj.FechaCreacion = Convert.ToDateTime(item.FechaCreacion); Obj.UsuarioModificacion = item.UsuarioModificacion; Obj.UsuarioCreacion = item.UsuarioCreacion; Obj.FechaAnulacion = Convert.ToDateTime(item.FechaAnulacion); Obj.UsuarioAnulacion = item.UsuarioAnulacion; Obj.MotivoAnulacion = item.MotivoAnulacion; Lst.Add(Obj); } 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); mensaje = ex.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.ToString()); } }
public Boolean GrabarDB(fa_motivo_venta_Info Info, ref int idMotivo, ref string msg) { try { using (EntitiesFacturacion context = new EntitiesFacturacion()) { var lst = from q in context.fa_motivo_venta where q.IdEmpresa == Info.IdEmpresa && q.IdMotivo_Vta == Info.IdMotivo_Vta select q; if (lst.Count() == 0) { fa_motivo_venta address = new fa_motivo_venta(); idMotivo = GetId_Motivo_Venta(Info.IdEmpresa); address.IdEmpresa = Info.IdEmpresa; address.IdMotivo_Vta = idMotivo; address.codMotivo_Vta = string.IsNullOrEmpty(Info.codMotivo_Vta) ? Convert.ToString(idMotivo) : Info.codMotivo_Vta.Trim(); address.descripcion_motivo_vta = Info.descripcion_motivo_vta.Trim(); address.Estado = Info.Estado; address.FechaCreacion = DateTime.Now; address.UsuarioCreacion = Info.UsuarioCreacion; context.fa_motivo_venta.Add(address); context.SaveChanges(); msg = "El nuevo registro: " + address.IdMotivo_Vta.ToString() + " se grabo satisfactoriamente"; } } return(true); } 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); msg = ex.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref msg); msg = "Se ha producido el siguiente error: " + ex.Message; throw new Exception(ex.ToString()); } }
public Boolean Modificar() { bool resultado = false; try { fa_motivo_venta_Info InfoMotivo = new fa_motivo_venta_Info(); fa_motivo_venta_Bus BusMotivo = new fa_motivo_venta_Bus(); mensaje = ""; InfoMotivo = Get_Motivo_Venta(ref mensaje); if (mensaje != "") { MessageBox.Show(mensaje); return(false); } resultado = BusMotivo.Modificar(InfoMotivo, ref mensaje); if (resultado == true) { MessageBox.Show(mensaje, "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Information); this.ucGe_Menu_Superior_Mant1.Visible_btnGuardar = false; this.ucGe_Menu_Superior_Mant1.Visible_bntGuardar_y_Salir = false; } else { Log_Error_bus.Log_Error(mensaje.ToString()); MessageBox.Show("Error " + mensaje, "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(resultado); } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); MessageBox.Show(ex.Message); return(false); } }
public fa_motivo_venta_Info Get_Motivo_Venta(ref string mensaje) { try { fa_motivo_venta_Info Info = new fa_motivo_venta_Info(); Info.IdEmpresa = param.IdEmpresa; Info.IdMotivo_Vta = Convert.ToInt32(txt_IdMotivo.Text); Info.codMotivo_Vta = txtCodigo.Text; Info.descripcion_motivo_vta = txtDescripcion.Text; Info.FechaCreacion = DateTime.Now; Info.UsuarioCreacion = param.IdUsuario; if (Accion == Cl_Enumeradores.eTipo_action.grabar) { chkEstado.Checked = true; } Info.Estado = (chkEstado.Checked == true)? "A" : "I"; if (chkEstado.Checked) { lbl_Estado.Visible = false; } else { lbl_Estado.Visible = true; } return(Info); } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); mensaje = ex.Message.ToString(); MessageBox.Show("Error " + mensaje, "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Information); throw; } }
private Boolean Proceso_Grabacion() { Boolean respuesta = false; int c = 1; int Total_Reg = 0; string SIdProducto = ""; string nom_producto = ""; BindingList <cl_estado_grabacion> ListEstadoGrabacion = new BindingList <cl_estado_grabacion>(); try { string MensajeLog = "Ingreso Exitoso."; string MensajeWarning = ""; string listaLog = ""; this.rtbLog.Text = ""; bool B_Proceso_anulacion = true; lblMensaje.Text = ""; lblMensaje.Visible = false; decimal IdProducto = 0; int IdLinea = 0; int IdGrupo = 0; int IdSubGrupo = 0; int idMotivo = 0; gridControlProceGrabado.DataSource = ListEstadoGrabacion; if (gridControlProductos.DataSource != null) { if (rgImportar.SelectedIndex == 0) { MensajeWarning = "Atención esta a punto de eliminar toda la información actual, y reemplazarla con la nueva. Está seguro de continuar?"; } else { MensajeWarning = "Atención esta a punto de proceder. Está seguro de continuar?"; } lblmsg3.Visible = true; if (MessageBox.Show(MensajeWarning, "SISTEMAS", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { if (rgImportar.SelectedIndex == 0) { //splashScreenManager.ShowWaitForm(); B_Proceso_anulacion = _Bus_producto_x_bodega.Delete_Todos_Producto_x_bodega(param.IdEmpresa, ref MensajeError); B_Proceso_anulacion = _ProductoBus.Delete_Todos_Producto(param.IdEmpresa, ref MensajeError); if (B_Proceso_anulacion) { ListEstadoGrabacion.Add(new cl_estado_grabacion(0, "", "Eliminado productos", "", "OK", "Eliminado Ok")); gridControlProceGrabado.Refresh(); } //splashScreenManager.CloseWaitForm(); } if (B_Proceso_anulacion == true) { //splashScreenManager.ShowWaitForm(); Total_Reg = _ListProductoInfo.Count(); progressBar.Maximum = Total_Reg; progressBar.Minimum = 1; progressBar.Step = 1; lblNumRegistros.Text = "0 registros de " + Total_Reg; c = 1; #region Listas foreach (var item in list_Categoria) { respuesta = Categoria_Bus.GrabarDB(param.IdEmpresa, item, ref MensajeError); } if (!respuesta) { MessageBox.Show("La Hoja de Categoria no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } foreach (var item in list_Linea) { respuesta = Linea_bus.GrabarDB(item, ref IdLinea, ref MensajeError); } if (!respuesta) { MessageBox.Show("La Hoja de Línea no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } foreach (var item in list_Grupo) { respuesta = Grupo_bus.GrabarDB(item, ref IdGrupo, ref MensajeError); } if (!respuesta) { MessageBox.Show("La Hoja de Grupo no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } foreach (var item in list_SubGrupo) { respuesta = SubGrupo_bus.GrabarDB(item, ref IdSubGrupo, ref MensajeError); } if (!respuesta) { MessageBox.Show("La Hoja de SubGrupo no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } foreach (var item in list_Marca) { respuesta = Marca_bus.GrabarDB(item, ref MensajeError); } if (!respuesta) { MessageBox.Show("La Hoja de Marca no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } _Motivo_venta_Info = new fa_motivo_venta_Info(); _Motivo_venta_Info.IdEmpresa = param.IdEmpresa; _Motivo_venta_Info.IdMotivo_Vta = 1; _Motivo_venta_Info.codMotivo_Vta = "1"; _Motivo_venta_Info.descripcion_motivo_vta = "no definido"; _Motivo_venta_Info.Estado = "A"; _Motivo_venta_Info.FechaCreacion = param.Fecha_Transac; _Motivo_venta_Info.UsuarioCreacion = param.IdUsuario; respuesta = Motivo_venta_bus.Grabar(_Motivo_venta_Info, ref idMotivo, ref MensajeError); if (!respuesta) { MessageBox.Show("La Hoja de Motivo de venta no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } foreach (var item in list_Presentacion) { respuesta = Presentacion_bus.GuardarDB(item, ref MensajeError); } if (!respuesta) { MessageBox.Show("La Hoja de Presentación no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } foreach (in_Producto_Info item in _ListProductoInfo) { SIdProducto = item.IdProducto.ToString(); nom_producto = item.pr_descripcion; item.IdProducto = 0;//en caso de que sea conservar item.IdCategoria = "1"; item.IdLinea = 1; item.IdGrupo = 1; item.IdSubGrupo = 1; item.IdMarca = 1; item.IdProductoTipo = 2; item.IdPresentacion = "1"; item.IdUnidadMedida = "UNID"; item.IdUnidadMedida_Consumo = "UNID"; item.IdCod_Impuesto_Iva = "IVA12";; item.IdMotivo_Vta = 1; item.Estado = "A"; respuesta = _ProductoBus.GrabarDB(item, ref IdProducto, ref MensajeError); if (respuesta) { #region Producto por bodega foreach (var Sucursal in lst_Sucursal) { foreach (var Bodega in lst_Bodega) { if (Bodega.IdSucursal == Sucursal.IdSucursal) { info_producto_x_bodega = new in_producto_x_tb_bodega_Info(); info_producto_x_bodega.IdEmpresa = item.IdEmpresa; info_producto_x_bodega.IdSucursal = Sucursal.IdSucursal; info_producto_x_bodega.IdBodega = Bodega.IdBodega; info_producto_x_bodega.IdProducto = item.IdProducto; info_producto_x_bodega.pr_precio_publico = item.pr_precio_publico; info_producto_x_bodega.pr_precio_minimo = item.pr_precio_minimo; //info_producto_x_bodega.pr_stock = item.pr_stock; info_producto_x_bodega.pr_stock_minimo = item.pr_stock_minimo; info_producto_x_bodega.pr_costo_promedio = item.pr_costo_promedio; //Cuentas contables info_producto_x_bodega.IdCtaCble_Inven = cmb_IdCtaCble_Inven.get_PlanCtaInfo().IdCtaCble; //1 info_producto_x_bodega.IdCtaCble_VenIva = cmb_IdCtaCble_VenIva.get_PlanCtaInfo().IdCtaCble; //2 info_producto_x_bodega.IdCtaCble_Ven0 = cmb_IdCtaCble_Ven0.get_PlanCtaInfo().IdCtaCble; //3 info_producto_x_bodega.IdCtaCble_DevIva = cmb_IdCtaCble_DesIva.get_PlanCtaInfo().IdCtaCble; //4 info_producto_x_bodega.IdCtaCble_Des0 = cmb_IdCtaCble_Des0.get_PlanCtaInfo().IdCtaCble; //5 info_producto_x_bodega.IdCtaCble_DevIva = cmb_IdCtaCble_DevIva.get_PlanCtaInfo().IdCtaCble; //6 info_producto_x_bodega.IdCtaCble_Dev0 = cmb_IdCtaCble_Dev0.get_PlanCtaInfo().IdCtaCble; //7 info_producto_x_bodega.IdCtaCble_Costo = cmb_IdCtaCble_Costo.get_PlanCtaInfo().IdCtaCble; //8 info_producto_x_bodega.IdCtaCble_Gasto_x_cxp = cmb_IdCtaCble_Gasto_x_cxp.get_PlanCtaInfo().IdCtaCble; //9 info_producto_x_bodega.IdCtaCble_Vta = cmb_IdCtaCble_Vta.get_PlanCtaInfo().IdCtaCble; //10 //Fin cuentas contables info_producto_x_bodega.Estado = "A"; respuesta = bus_producto_x_bodega.GrabaDB(info_producto_x_bodega, param.IdEmpresa, ref MensajeError); } } } #endregion ListEstadoGrabacion.Add(new cl_estado_grabacion(c, item.IdProducto.ToString(), item.pr_codigo, item.pr_descripcion, "OK", "Migrado Ok")); progressBar.Value = c; lblNumRegistros.Text = c + " registros de " + Total_Reg; progressBar.Refresh(); Application.DoEvents(); } c++; } #endregion if (listaLog != "") { MensajeLog += " pero con errores:" + "\n" + listaLog + MensajeError; } } } else { MensajeLog = "No se efectuó la operación. Operación cancelada por el usuario."; } lblmsg3.Visible = false; } else { MensajeLog = "No existen Datos para importación."; } this.rtbLog.Text = MensajeLog; //splashScreenManager.CloseWaitForm(); return(respuesta); } catch (Exception ex) { //splashScreenManager.CloseWaitForm(); ListEstadoGrabacion.Add(new cl_estado_grabacion(c++, SIdProducto, SIdProducto, nom_producto, "ERROR", "No Migrado:" + ex.ToString())); gridControlProceGrabado.Refresh(); lblMensaje.Text = "Error al cargar " + ex.ToString(); lblMensaje.Visible = true; return(respuesta); } }
private Boolean Proceso_Grabacion() { Boolean respuesta = false; int c = 1; int Total_Reg = 0; string SIdProducto = ""; string nom_producto = ""; BindingList <cl_estado_grabacion> ListEstadoGrabacion = new BindingList <cl_estado_grabacion>(); try { string MensajeLog = "Ingreso Exitoso."; string MensajeWarning = ""; string listaLog = ""; this.rtbLog.Text = ""; bool B_Proceso_anulacion = true; lblMensaje.Text = ""; lblMensaje.Visible = false; decimal IdProducto = 0; int IdLinea = 0; int IdGrupo = 0; int IdSubGrupo = 0; int idMotivo = 0; gridControlProceGrabado.DataSource = ListEstadoGrabacion; if (gridControlProductos.DataSource != null) { if (rgImportar.SelectedIndex == 0) { MensajeWarning = "Atención esta a punto de eliminar toda la información actual, y reemplazarla con la nueva. Está seguro de continuar?"; } else { MensajeWarning = "Atención esta a punto de proceder. Está seguro de continuar?"; } lblmsg3.Visible = true; if (MessageBox.Show(MensajeWarning, "SISTEMAS", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { if (rgImportar.SelectedIndex == 0) { B_Proceso_anulacion = bus_producto_x_bodega.EliminarDB(param.IdEmpresa); B_Proceso_anulacion = _ProductoBus.Delete_Todos_Producto(param.IdEmpresa, ref MensajeError); if (B_Proceso_anulacion) { ListEstadoGrabacion.Add(new cl_estado_grabacion(0, "", "Eliminado productos", "", "OK", "Eliminado Ok")); gridControlProceGrabado.Refresh(); } } if (B_Proceso_anulacion == true) { //splashScreenManager.ShowWaitForm(); Total_Reg = _ListProductoInfo.Count(); progressBar.Maximum = Total_Reg; progressBar.Minimum = 1; progressBar.Step = 1; lblNumRegistros.Text = "0 registros de " + Total_Reg; c = 1; #region Listas try { foreach (var item in list_Categoria) { respuesta = Categoria_Bus.GrabarDB(param.IdEmpresa, item, ref MensajeError); } if (!respuesta) { MessageBox.Show("La Hoja de Categoria no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } catch (Exception) { MessageBox.Show("La Hoja de Categoria no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } try { foreach (var item in list_Linea) { respuesta = Linea_bus.GrabarDB(item, ref IdLinea, ref MensajeError); } if (!respuesta) { MessageBox.Show("La Hoja de Línea no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } catch (Exception) { MessageBox.Show("La Hoja de Línea no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } try { foreach (var item in list_Grupo) { respuesta = Grupo_bus.GrabarDB(item, ref IdGrupo, ref MensajeError); } if (!respuesta) { MessageBox.Show("La Hoja de Grupo no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } catch (Exception) { MessageBox.Show("La Hoja de Grupo no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } try { foreach (var item in list_SubGrupo) { respuesta = SubGrupo_bus.GrabarDB(item, ref IdSubGrupo, ref MensajeError); } if (!respuesta) { MessageBox.Show("La Hoja de SubGrupo no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } catch (Exception) { MessageBox.Show("La Hoja de SubGrupo no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } try { foreach (var item in list_Marca) { respuesta = Marca_bus.GrabarDB(item, ref MensajeError); } if (!respuesta) { MessageBox.Show("La Hoja de Marca no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } catch (Exception) { MessageBox.Show("La Hoja de Marca no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } _Motivo_venta_Info = new fa_motivo_venta_Info(); _Motivo_venta_Info.IdEmpresa = param.IdEmpresa; _Motivo_venta_Info.IdMotivo_Vta = 1; _Motivo_venta_Info.codMotivo_Vta = "1"; _Motivo_venta_Info.descripcion_motivo_vta = "no definido"; _Motivo_venta_Info.Estado = "A"; _Motivo_venta_Info.FechaCreacion = param.Fecha_Transac; _Motivo_venta_Info.UsuarioCreacion = param.IdUsuario; respuesta = Motivo_venta_bus.Grabar(_Motivo_venta_Info, ref idMotivo, ref MensajeError); if (!respuesta) { MessageBox.Show("La Hoja de Motivo de venta no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } foreach (var item in list_Presentacion) { respuesta = Presentacion_bus.GuardarDB(item, ref MensajeError); } if (!respuesta) { MessageBox.Show("La Hoja de Presentación no cumple con el formato de la plantilla", "Sistemas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } List <in_categorias_Info> listCategoria = new List <in_categorias_Info>(); listCategoria = Categoria_Bus.Get_List_categorias(param.IdEmpresa); List <in_linea_info> listLinea = new List <in_linea_info>(); listLinea = Linea_bus.Get_List_Linea(param.IdEmpresa); List <in_grupo_info> listgrupo = new List <in_grupo_info>(); listgrupo = Grupo_bus.Get_List_Grupo(param.IdEmpresa); List <in_subgrupo_info> listsubgrupo = SubGrupo_bus.ConsultaGeneralSubGrupo(param.IdEmpresa); List <in_Marca_Info> listmarca = Marca_bus.Get_list_Marca(param.IdEmpresa); List <in_presentacion_Info> lst_presentacion = Presentacion_bus.Get_List_presentacion(param.IdEmpresa); //cambiar lo de marca, subgrupo y medida para que eso venga desde la plantilla de excel y no este quemado foreach (in_Producto_Info item in _ListProductoInfo) { SIdProducto = item.IdProducto.ToString().Trim(); nom_producto = item.pr_descripcion.Trim(); item.IdProducto = 0;//en caso de que sea conservar try { item.IdCategoria = listCategoria.First(v => v.ca_Categoria.Trim().ToLower() == item.nom_Categoria.Trim().ToLower()).IdCategoria; } catch (Exception) { item.IdCategoria = "1"; } try { item.IdLinea = listLinea.First(v => v.IdCategoria == item.IdCategoria && v.nom_linea.Trim().ToLower() == item.nom_Linea.Trim().ToLower()).IdLinea; } catch (Exception) { item.IdLinea = 1; } try { item.IdGrupo = listgrupo.First(v => v.IdCategoria == item.IdCategoria && v.IdLinea == item.IdLinea && v.nom_grupo.Trim().ToLower() == item.nom_Grupo.Trim().ToLower()).IdGrupo; } catch (Exception) { item.IdGrupo = 1; } try { item.IdSubGrupo = listsubgrupo.First(v => v.IdCategoria == item.IdCategoria && v.IdLinea == item.IdLinea && v.IdGrupo == item.IdGrupo && v.nom_subgrupo.Trim().ToLower() == item.nom_SubGrupo.Trim().ToLower()).IdSubgrupo; } catch (Exception) { item.IdSubGrupo = 1; } try { item.IdMarca = listmarca.First(v => v.Descripcion.Trim().ToLower() == item.nom_Marca.Trim().ToLower()).IdMarca; } catch (Exception) { item.IdMarca = 1; } try { item.IdPresentacion = lst_presentacion.First(q => q.nom_presentacion.Trim().ToLower() == item.nom_Presentacion.Trim().ToLower()).IdPresentacion; } catch (Exception) { } item.IdProductoTipo = item.IdProductoTipo; item.IdUnidadMedida = "UNID"; item.IdUnidadMedida_Consumo = "UNID"; if (item.pr_ManejaIva == "S") { item.IdCod_Impuesto_Iva = param.Get_Parametro_Info(tb_parametro_enum.P_IVA).Valor; } else { item.IdCod_Impuesto_Iva = "IVA0"; } item.Estado = "A"; respuesta = _ProductoBus.GrabarDB(item, ref IdProducto, ref MensajeError); if (respuesta && item.IdProductoTipo == 3) { decimal ID = 1; in_Producto_Info i_producto_lote = new in_Producto_Info { IdEmpresa = item.IdEmpresa, IdProducto = 0, pr_codigo = item.pr_codigo, pr_codigo2 = item.pr_codigo2, pr_descripcion = item.pr_descripcion, pr_descripcion_2 = item.pr_descripcion_2, IdProductoTipo = 4, IdMarca = item.IdMarca, IdPresentacion = item.IdPresentacion, IdCategoria = item.IdCategoria, IdLinea = item.IdLinea, IdGrupo = item.IdGrupo, IdSubGrupo = item.IdSubGrupo, IdUnidadMedida = item.IdUnidadMedida, IdUnidadMedida_Consumo = item.IdUnidadMedida_Consumo, pr_codigo_barra = item.pr_codigo_barra, pr_observacion = item.pr_observacion, Estado = "A", IdCod_Impuesto_Iva = item.IdCod_Impuesto_Iva, Aparece_modu_Ventas = item.Aparece_modu_Ventas, Aparece_modu_Activo_F = item.Aparece_modu_Activo_F, Aparece_modu_Compras = item.Aparece_modu_Compras, Aparece_modu_Inventario = item.Aparece_modu_Inventario, IdProducto_padre = IdProducto, lote_num_lote = "LOTE0", lote_fecha_fab = null, lote_fecha_vcto = null, precio_1 = item.precio_1, precio_2 = item.precio_2, precio_3 = item.precio_3, precio_4 = item.precio_4, precio_5 = item.precio_5, porcentaje_2 = item.porcentaje_2, porcentaje_3 = item.porcentaje_3, porcentaje_4 = item.porcentaje_4, porcentaje_5 = item.porcentaje_5, signo_2 = item.signo_2, signo_3 = item.signo_3, signo_4 = item.signo_4, signo_5 = item.signo_5, se_distribuye = true }; respuesta = _ProductoBus.GrabarDB(i_producto_lote, ref ID, ref MensajeError); } ListEstadoGrabacion.Add(new cl_estado_grabacion(c, item.IdProducto.ToString(), item.pr_codigo, item.pr_descripcion, "OK", "Migrado Ok")); progressBar.Value = c; lblNumRegistros.Text = c + " registros de " + Total_Reg; progressBar.Refresh(); Application.DoEvents(); c++; } #endregion if (listaLog != "") { MensajeLog += " pero con errores:" + "\n" + listaLog + MensajeError; } } } else { MensajeLog = "No se efectuó la operación. Operación cancelada por el usuario."; } lblmsg3.Visible = false; } else { MensajeLog = "No existen Datos para importación."; } this.rtbLog.Text = MensajeLog; //splashScreenManager.CloseWaitForm(); return(respuesta); } catch (Exception ex) { //splashScreenManager.CloseWaitForm(); ListEstadoGrabacion.Add(new cl_estado_grabacion(c++, SIdProducto, SIdProducto, nom_producto, "ERROR", "No Migrado:" + ex.ToString())); gridControlProceGrabado.Refresh(); lblMensaje.Text = "Error al cargar " + ex.ToString(); lblMensaje.Visible = true; return(respuesta); } }