public Boolean eliminarregistrotabla(List <prd_ControlProduccionObreroDetalle_Info> lmDetalleInfo, int idempresa, decimal IdCtrlPrdObrero, ref string msg) { try { var contact = new prd_ControlProduccion_Obrero_Det(); using (EntitiesProduccion_Cidersus context = new EntitiesProduccion_Cidersus()) { foreach (var item in lmDetalleInfo) { var address = context.prd_ControlProduccion_Obrero_Det.FirstOrDefault(A => A.IdEmpresa == idempresa && A.IdSucursal == item.IdSucursal && A.IdControlProduccionObrero == IdCtrlPrdObrero); //&& A.Secuencia == item.Secuencia && A.IdFecha == item.IdFecha); if (address != null) { contact = address; context.prd_ControlProduccion_Obrero_Det.Remove(contact); context.SaveChanges(); msg = "Guardado 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() + " " + ex.Message; oDataLog.Guardar_Log_Error(Log_Error_sis, ref msg); throw new Exception(ex.ToString()); } }
public Boolean grabarDB(List <prd_ControlProduccionObreroDetalle_Info> lmDetalleInfo, int idempresa, decimal IdCtrlPrdObrero, ref string msg) { try { int c = 1; using (EntitiesProduccion_Cidersus context = new EntitiesProduccion_Cidersus()) { foreach (var item in lmDetalleInfo) { var address = new prd_ControlProduccion_Obrero_Det(); address.IdEmpresa = idempresa; address.IdSucursal = item.IdSucursal; address.IdControlProduccionObrero = IdCtrlPrdObrero; address.Secuencia = c; c++; address.HoraInicio = item.HoraInicio; address.CodBarra = item.CodBarra; address.CodBarraMaestro = item.CodBarraMaestro; address.IdProducto = item.IdProducto; address.Cantidad = item.Cantidad; context.prd_ControlProduccion_Obrero_Det.Add(address); context.SaveChanges(); } context.Dispose(); } msg = "Guardado 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); mensaje = ex.ToString() + " " + ex.Message; oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.ToString()); } }