public Boolean ModificarDB(fa_cotizacion_info inf, ref string msg) { try { Boolean resCab = false; Boolean resDet = false; ArreglandoObjeto(ref inf); if (ValidarObjeto(inf, ref msg) == false) { return(false); } resCab = oData.ModificarDB(inf, ref msg); //resDet = ModificarDetalleDB(inf.lista_detalle, inf, ref msg); return(resCab && resDet); } 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("", "ModificarDB", ex.Message), ex) { EntityType = typeof(fa_cotizacion_Bus) }; } }
public Boolean AnularDB(fa_cotizacion_info info, ref string mensajeE) { try { using (EntitiesFacturacion context = new EntitiesFacturacion()) { var contact = context.fa_cotizacion.FirstOrDefault(cot => cot.IdEmpresa == info.IdEmpresa && cot.IdCotizacion == info.IdCotizacion && cot.IdSucursal == info.IdSucursal && cot.IdBodega == info.IdBodega); if (contact != null) { contact.cc_estado = "I"; contact.Fecha_UltAnu = DateTime.Now; contact.MotivoAnu = info.MotivoAnu; contact.IdUsuarioUltAnu = info.IdUsuario; context.SaveChanges(); } } 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); mensajeE = ex.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensajeE); throw new Exception(ex.ToString()); } }
public Boolean GrabarDB(fa_cotizacion_info inf, ref decimal IdNumCotizacion, ref string msg) { try { Boolean resCab = false; Boolean resDet = false; ArreglandoObjeto(ref inf); if (ValidarObjeto(inf, ref msg) == false) { return(false); } resCab = oData.GrabarDB(inf, ref IdNumCotizacion, ref msg); foreach (var item in inf.lista_detalle) { item.IdCotizacion = IdNumCotizacion; } //resDet=GuardarDetalle(inf.lista_detalle, ref msg); return(resCab && resDet); } 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("", "GrabarDB", ex.Message), ex) { EntityType = typeof(fa_cotizacion_Bus) }; } }
public void Detalle() { try { infocotizacion = buscotizacion.Get_Info_cotizacio(param.IdEmpresa, IdSucursal, IdBodega, IdCotizacion); //List<fa_cotizacion_det_info> fu = new List<fa_cotizacion_det_info>(); //faGridDetalle.set_grid_detalle(fu); UCfaCliente.cmb_cliente.EditValue = infocotizacion.IdCliente; UCfaCliente.cmb_vendedor.EditValue = infocotizacion.IdVendedor; // this.panel1.Controls.Add(faBodega); UCfaBodega.cmb_sucursal.EditValue = IdSucursal; UCfaBodega.cmb_bodega.EditValue = IdBodega; LoadProductos(); spinEditDiasPlazo.Value = infocotizacion.cc_diasPlazo; rbtnContado.Checked = (infocotizacion.cc_tipopago == "CON") ? true : false; rbtnCredito.Checked = (infocotizacion.cc_tipopago == "CRE") ? true : false; txtObservacion.Text = infocotizacion.cc_observacion; dateFecha.Value = infocotizacion.cc_fecha; txtInteres.EditValue = Convert.ToDecimal(infocotizacion.cc_interes); txtTransporte.EditValue = Convert.ToDecimal(infocotizacion.cc_transporte); txtOtro1.EditValue = Convert.ToDecimal(infocotizacion.cc_otroValor1); txtOtro2.EditValue = Convert.ToDecimal(infocotizacion.cc_otroValor2); txtCodigoCot.Text = infocotizacion.CodCotizacion; txtNumCot.Text = Convert.ToString(IdCotizacion); dateFechaVencimiento.Value = infocotizacion.cc_fechaVencimiento; //listadetalle=buscotizacion.Get_Info_cotizacio(param.IdEmpresa, IdSucursal, IdBodega, IdCotizacion); //convertir_infotabla(listatabla, listadetalle); //faGridDetalle.set_grid_detalle(listatabla); } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Boolean ActualizarEstado(int IdEmpresa, fa_cotizacion_info oDeT) { try { using (EntitiesFacturacion context = new EntitiesFacturacion()) { var contact = context.fa_cotizacion.FirstOrDefault(minfo => minfo.IdEmpresa == IdEmpresa && minfo.IdCotizacion == oDeT.IdCotizacion); if (contact != null) { contact.MotivoAnu = oDeT.MotivoAnu; contact.ip = oDeT.ip; contact.nom_pc = oDeT.nom_pc; contact.Fecha_UltAnu = oDeT.Fecha_UltAnu; contact.IdUsuarioUltAnu = oDeT.IdUsuarioUltAnu; contact.cc_estado = "I"; context.SaveChanges(); } } 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(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.ToString()); } }
public fa_cotizacion_info Get_Info_cotizacion(int IdEmpresa, int IdSucursal, int IdBodega, decimal IdCotizacion) { try { fa_cotizacion_info infCot = new fa_cotizacion_info(); EntitiesFacturacion entitieFa = new EntitiesFacturacion(); var selectBaParam = from C in entitieFa.fa_cotizacion where C.IdEmpresa == IdEmpresa && C.IdSucursal == IdSucursal && C.IdBodega == IdBodega && C.IdCotizacion == IdCotizacion select C; foreach (var item in selectBaParam) { infCot.IdEmpresa = item.IdEmpresa; infCot.IdSucursal = item.IdSucursal; infCot.IdBodega = item.IdBodega; infCot.IdCotizacion = item.IdCotizacion; infCot.IdCliente = Convert.ToInt32(item.IdCliente); infCot.IdVendedor = Convert.ToInt32(item.IdVendedor); infCot.cc_fecha = Convert.ToDateTime(item.cc_fecha); infCot.cc_diasPlazo = Convert.ToInt16(item.cc_diasPlazo); infCot.cc_dirigidoA = item.cc_dirigidoA; infCot.cc_estado = item.cc_estado; infCot.cc_fechaVencimiento = Convert.ToDateTime(item.cc_fechaVencimiento); infCot.cc_observacion = item.cc_observacion; infCot.cc_tipopago = item.cc_tipopago; infCot.cc_otroValor1 = Convert.ToDouble(item.cc_otroValor1); infCot.cc_otroValor2 = Convert.ToDouble(item.cc_otroValor2); infCot.cc_transporte = Convert.ToDouble(item.cc_transporte); infCot.cc_interes = Convert.ToDouble(item.cc_interes); infCot.CodCotizacion = item.CodCotizacion; infCot.ip = item.ip; infCot.IdUsuario = item.IdUsuario; infCot.nom_pc = item.nom_pc; } return(infCot); } 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 ActualizarEstado(int idempresa, fa_cotizacion_info oInfo) { try { return(oData.ActualizarEstado(idempresa, oInfo)); } 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("", "ActualizarEstado", ex.Message), ex) { EntityType = typeof(fa_cotizacion_Bus) }; } }
public Boolean AnularDB(fa_cotizacion_info inf, ref string mensajeE) { try { return(oData.AnularDB(inf, ref mensajeE)); } 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("", "AnularCotizacionDB", ex.Message), ex) { EntityType = typeof(fa_cotizacion_Bus) }; } }
public Boolean ModificarDB(fa_cotizacion_info info, ref string msgs) { try { using (EntitiesFacturacion context = new EntitiesFacturacion()) { var contact = context.fa_cotizacion.FirstOrDefault(cot => cot.IdEmpresa == info.IdEmpresa && cot.IdCotizacion == info.IdCotizacion && cot.IdSucursal == info.IdSucursal && cot.IdBodega == info.IdBodega); if (contact != null) { contact.IdCliente = info.IdCliente; contact.IdVendedor = info.IdVendedor; contact.cc_fecha = Convert.ToDateTime(info.cc_fecha.ToShortDateString()); contact.cc_diasPlazo = Convert.ToInt16(info.cc_diasPlazo); contact.cc_dirigidoA = info.cc_dirigidoA; contact.cc_fechaVencimiento = Convert.ToDateTime(info.cc_fechaVencimiento.ToShortDateString()); contact.cc_observacion = info.cc_observacion; contact.cc_tipopago = info.cc_tipopago; contact.cc_transporte = info.cc_transporte; contact.cc_interes = info.cc_interes; contact.cc_otroValor1 = info.cc_otroValor1; contact.cc_otroValor2 = info.cc_otroValor2; contact.CodCotizacion = info.CodCotizacion; contact.Fecha_UltMod = info.Fecha_UltMod; contact.IdUsuarioUltMod = info.IdUsuarioUltMod; context.SaveChanges(); } } 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); msgs = ex.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref msgs); throw new Exception(ex.ToString()); } }
public Boolean ValidarObjeto(fa_cotizacion_info inf, ref string mensajeE) { try { mensajeE = ""; if (inf.lista_detalle.Count == 0) { mensajeE = "Objeto no valido no tiene detalle"; return(false); } if (inf.IdEmpresa == 0 && inf.IdSucursal == 0 && inf.IdBodega == 0) { mensajeE = "Uno de los PK del objeto estan en cero IdEmpresa=" + inf.IdEmpresa + " IdSucursal=" + inf.IdSucursal + " IdBodega=" + inf.IdBodega; return(false); } if (inf.IdCliente == 0 && inf.IdVendedor == 0) { mensajeE = "Id de cliente o vendedor esta en cero IdCliente=" + inf.IdCliente + " IdVendedor=" + inf.IdVendedor; return(false); } 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("", "ValidarObjeto", ex.Message), ex) { EntityType = typeof(fa_cotizacion_Bus) }; } }
private void ArreglandoObjeto(ref fa_cotizacion_info inf) { try { inf.cc_observacion = (inf.cc_observacion == null) ? "" : inf.cc_observacion; inf.cc_fecha = Convert.ToDateTime(inf.cc_fecha.ToShortDateString()); inf.cc_fechaVencimiento = Convert.ToDateTime(inf.cc_fechaVencimiento.ToShortDateString()); foreach (var item in inf.lista_detalle) { item.IdEmpresa = inf.IdEmpresa; item.IdSucursal = inf.IdSucursal; item.IdBodega = inf.IdBodega; item.dc_pagaIva = (item.dc_iva > 0)?"S":"N"; item.dc_detallexItems = (item.dc_detallexItems == null) ? "" : item.dc_detallexItems; } int c = 1; foreach (var item in inf.lista_detalle) { item.IdEmpresa = inf.IdEmpresa; item.IdSucursal = inf.IdSucursal; item.IdBodega = inf.IdBodega; item.Secuencial = c; c = c + 1; } } 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("", "ArreglandoObjeto", ex.Message), ex) { EntityType = typeof(fa_cotizacion_Bus) }; } }
public Boolean GrabarDB(fa_cotizacion_info info, ref decimal IdNumCotizacion, ref string msgs) { try { using (EntitiesFacturacion context = new EntitiesFacturacion()) { EntitiesFacturacion factCot = new EntitiesFacturacion(); var ID = ((from C in factCot.fa_cotizacion where C.IdEmpresa == info.IdEmpresa && C.IdBodega == info.IdBodega && C.IdSucursal == info.IdSucursal select C.IdCotizacion).ToList().Count() == 0)?1:((from C in factCot.fa_cotizacion where C.IdEmpresa == info.IdEmpresa && C.IdBodega == info.IdBodega && C.IdSucursal == info.IdSucursal select C.IdCotizacion).Max() + 1); if (ValidarCodCot(info.CodCotizacion)) { msgs = "\n EL Codigo " + info.CodCotizacion + " de la Cotizacion ya esta en Uso. \n Ingrese otro."; return(false); } var addressG = new fa_cotizacion(); addressG.IdEmpresa = info.IdEmpresa; addressG.IdSucursal = info.IdSucursal; addressG.IdBodega = info.IdBodega; addressG.IdCotizacion = IdNumCotizacion = ID; addressG.IdCliente = info.IdCliente; addressG.IdVendedor = info.IdVendedor; addressG.cc_fecha = Convert.ToDateTime(info.cc_fecha.ToShortDateString()); addressG.cc_diasPlazo = Convert.ToInt16(info.cc_diasPlazo); addressG.cc_dirigidoA = info.cc_dirigidoA; addressG.cc_estado = "A"; addressG.cc_fechaVencimiento = Convert.ToDateTime(info.cc_fechaVencimiento.ToShortDateString()); addressG.cc_observacion = info.cc_observacion; addressG.cc_tipopago = info.cc_tipopago; addressG.cc_transporte = Convert.ToDouble(info.cc_transporte); addressG.cc_interes = info.cc_interes; addressG.cc_otroValor1 = info.cc_otroValor1; addressG.cc_otroValor2 = info.cc_otroValor2; addressG.CodCotizacion = (info.CodCotizacion == "")?"COT-" + Convert.ToString(info.IdCotizacion):info.CodCotizacion; info.CodCotizacion = addressG.CodCotizacion; addressG.Fecha_Transac = DateTime.Now; addressG.ip = info.ip; addressG.IdUsuario = info.IdUsuario; addressG.nom_pc = info.nom_pc; context.fa_cotizacion.Add(addressG); context.SaveChanges(); } 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); msgs = ex.ToString(); oDataLog.Guardar_Log_Error(Log_Error_sis, ref msgs); throw new Exception(ex.ToString()); } }
public List <fa_cotizacion_info> Get_List_cotizacion(int IdEmpresa, int IdSucursalIni, int IdSucursalFin, int IdBodegaIni, int IdBodegaFin , DateTime FechaIni, DateTime FechaFin) { try { List <fa_cotizacion_info> CotizacionInfo = new List <fa_cotizacion_info>(); EntitiesFacturacion OEFAC = new EntitiesFacturacion(); // var SelectCotizacion = from q in OEFAC.vwfa_cotizacion_detalle select q; if (IdSucursalIni == 0) { SelectCotizacion = from q in OEFAC.vwfa_cotizacion_detalle where q.IdEmpresa == IdEmpresa && q.cc_fecha >= FechaIni && q.cc_fecha <= FechaFin select q; } else { // SelectCotizacion = from q in OEFAC.vwfa_cotizacion_detalle where q.IdEmpresa == IdEmpresa && q.IdBodega >= IdBodegaIni && q.IdBodega <= IdBodegaFin && q.IdSucursal >= IdSucursalIni && q.IdSucursal <= IdSucursalFin && q.cc_fecha >= FechaIni && q.cc_fecha <= FechaFin select q; } var CabeceraCotizacion = from cab in SelectCotizacion group cab by new { cab.IdEmpresa, cab.IdSucursal, cab.IdBodega, cab.bo_Descripcion, cab.IdCotizacion, cab.pe_nombre, cab.pe_apellido , cab.Ve_Vendedor, cab.Su_Descripcion, cab.cc_dirigidoA, cab.CodCotizacion, cab.cc_fecha, cab.cc_fechaVencimiento, cab.cc_diasPlazo, cab.cc_observacion , cab.cc_estado } into grouping select new { grouping.Key, subototal = grouping.Sum(p => p.dc_subtotal), iva = grouping.Sum(p => p.dc_iva), Total = grouping.Sum(p => p.dc_total) }; foreach (var item in CabeceraCotizacion) { fa_cotizacion_info info = new fa_cotizacion_info(); List <fa_cotizacion_det_info> ListDet_coti = new List <fa_cotizacion_det_info>(); info.IdCotizacion = item.Key.IdCotizacion; info.IdEmpresa = item.Key.IdEmpresa; info.IdSucursal = item.Key.IdSucursal; info.IdBodega = item.Key.IdBodega; info.Bodega = item.Key.bo_Descripcion; info.Cliente = item.Key.pe_apellido + "" + item.Key.pe_nombre; info.Vendedor = item.Key.Ve_Vendedor; info.Sucursal = item.Key.Su_Descripcion; info.cc_dirigidoA = item.Key.cc_dirigidoA; info.cc_fecha = item.Key.cc_fecha; info.CodCotizacion = item.Key.CodCotizacion; info.cc_fechaVencimiento = item.Key.cc_fechaVencimiento; info.cc_diasPlazo = item.Key.cc_diasPlazo; info.cc_observacion = item.Key.cc_observacion; info.subtotal = Convert.ToDecimal(item.subototal); info.cc_estado = item.Key.cc_estado; info.iva = item.iva; info.total = item.Total; info.lista_detalle = ListDet_coti; CotizacionInfo.Add(info); } return(CotizacionInfo); } 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()); } }