Exemple #1
0
        private void btnReportePDF_Click(object sender, EventArgs e)
        {
            ProtocolBL             oProtocolBL = new ProtocolBL();
            List <ServiceOrderPdf> Lista       = new List <ServiceOrderPdf>();
            ServiceOrderPdf        oServiceOrderPdf;

            DialogResult    Result             = MessageBox.Show("¿Desea publicar a la WEB?", "ADVERTENCIA!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            OperationResult objOperationResult = new OperationResult();

            List <ProtocolComponentList> ListaComponentes = new List <ProtocolComponentList>();
            SecurityBL oSecurityBL = new SecurityBL();

            ServiceOrderDetailPdf        oServiceOrderDetailPdf;
            List <ServiceOrderDetailPdf> ListaServiceOrderDetailPdf = new List <ServiceOrderDetailPdf>();

            SystemUserList oSystemUserList = new SystemUserList();

            //saveFileDialog1.FileName = "Orden de Servicio";
            //saveFileDialog1.Filter = "Files (*.pdf;)|*.pdf;";

            //if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            //{

            using (new LoadingClass.PleaseWait(this.Location, "Generando..."))
            {
                this.Enabled = false;
                var MedicalCenter   = _serviceBL.GetInfoMedicalCenterSede();
                var pEmpresaCliente = new ProtocolBL().GetEmpresaByProtocoloId(_ProtocolId)[0].v_Name;
                var _DataService    = oProtocolBL.GetProtocolById(ref objOperationResult, _ProtocolId);

                foreach (var Protocolo in _TempServiceOrderDetail)
                {
                    oServiceOrderPdf = new ServiceOrderPdf();
                    //Llenar cabecera
                    var oProtocolo = oProtocolBL.GetProtocolById(ref objOperationResult, Protocolo.v_ProtocolId);
                    oServiceOrderPdf.v_ServiceOrderId = _ServiceOrderId;
                    oServiceOrderPdf.EmpresaCliente   = oProtocolo.v_OrganizationInvoice + " / " + oProtocolo.v_GroupOccupation + " / " + oProtocolo.v_EsoType;

                    //Llenar Detalle
                    ListaComponentes           = oProtocolBL.GetProtocolComponents(ref objOperationResult, Protocolo.v_ProtocolId);
                    ListaServiceOrderDetailPdf = new List <ServiceOrderDetailPdf>();
                    foreach (var Componente in ListaComponentes)
                    {
                        oServiceOrderDetailPdf = new ServiceOrderDetailPdf();
                        oServiceOrderDetailPdf.v_ServiceOrderDetailId = _TempServiceOrderDetail.Find(p => p.v_ProtocolId == Protocolo.v_ProtocolId).v_ServiceOrderDetailId;
                        oServiceOrderDetailPdf.v_ServiceOrderId       = _ServiceOrderId;
                        oServiceOrderDetailPdf.v_ComponentId          = Componente.v_ComponentId;
                        oServiceOrderDetailPdf.Componente             = Componente.v_ComponentName;
                        oServiceOrderDetailPdf.v_Precio = Componente.r_Price;
                        ListaServiceOrderDetailPdf.Add(oServiceOrderDetailPdf);
                    }
                    oServiceOrderPdf.DetalleServiceOrder = ListaServiceOrderDetailPdf;
                    oServiceOrderPdf.TotalProtocolo      = ListaServiceOrderDetailPdf.Sum(s => s.v_Precio);
                    Lista.Add(oServiceOrderPdf);
                }

                //obtener profesion del usuario
                var SystemUserId = Globals.ClientSession.i_SystemUserId;

                oSystemUserList = oSecurityBL.GetSystemUserAndProfesional(ref objOperationResult, SystemUserId);

                string ruta = Common.Utils.GetApplicationConfigValue("rutaCotizacion").ToString();



                if (chkProtocoloEspecial.Checked)
                {
                    OrdenServicioPromocion.CrearOrdenServicio(rbSi.Checked ? true : false, Lista, MedicalCenter, pEmpresaCliente, DateTime.Parse(txtDateTime.Text).ToString("dd 'd'e MMMM 'd'e yyyy"), oSystemUserList.Profesion + ". " + oSystemUserList.v_PersonName, ruta + _ServiceOrderId + ".pdf");
                }
                else
                {
                    OrdenServicio.CrearOrdenServicio(rbSi.Checked ? true : false, Lista, MedicalCenter, pEmpresaCliente, _ServiceOrderId, DateTime.Parse(txtDateTime.Text).ToString("dd 'd'e MMMM 'd'e yyyy"), oSystemUserList.Profesion + ". " + oSystemUserList.v_PersonName, ruta + _ServiceOrderId + ".pdf");
                }

                this.Enabled = true;
                //}
            }
        }
Exemple #2
0
        public static MessageCustom GenerateServiceOrderReport(BoardServiceOrder data, int userId, string FechaEmision)
        {
            MessageCustom msg = new MessageCustom();

            try
            {
                var MedicalCenter   = ServiceBl.GetInfoMedicalCenterSede();
                var pEmpresaCliente = data.EntityserviceOrder.v_OrganizationName;
                //var _DataService = ProtocolBL.GetProtocolById(ProtocolId);
                List <ProtocolComponentCustom> ListaComponentes = new List <ProtocolComponentCustom>();
                List <ServiceOrderPdf>         Lista            = new List <ServiceOrderPdf>();
                foreach (var objServiceOrder in data.ListEntityServiceOrder)
                {
                    ServiceOrderPdf objSerOrdPdf = new ServiceOrderPdf();

                    var oProtocolo = ProtocolBL.GetProtocolById(objServiceOrder.v_ProtocolId);
                    objSerOrdPdf.v_ServiceOrderId = data.EntityserviceOrder.v_ServiceOrderId;
                    objSerOrdPdf.EmpresaCliente   = oProtocolo.v_OrganizationInvoice + " / " + oProtocolo.v_GroupOccupation + " / " + oProtocolo.v_EsoType;
                    var board = ProtocolBL.GetProtocolComponentByProtocolId(objServiceOrder.v_ProtocolId);
                    ListaComponentes = board.ListProtocolComponents;
                    List <ServiceOrderDetailPdf> ListaServiceOrderDetailPdf = new List <ServiceOrderDetailPdf>();
                    foreach (var Componente in ListaComponentes)
                    {
                        ServiceOrderDetailPdf oServiceOrderDetailPdf = new ServiceOrderDetailPdf();
                        oServiceOrderDetailPdf.v_ServiceOrderDetailId = data.ListEntityServiceOrder.Find(p => p.v_ProtocolId == oProtocolo.v_ProtocolId).v_ServiceOrderDetailId;
                        oServiceOrderDetailPdf.v_ServiceOrderId       = data.EntityserviceOrder.v_ServiceOrderId;
                        oServiceOrderDetailPdf.v_ComponentId          = Componente.ComponentId;
                        oServiceOrderDetailPdf.Componente             = Componente.ComponentName;
                        oServiceOrderDetailPdf.v_Precio = Componente.Price;
                        ListaServiceOrderDetailPdf.Add(oServiceOrderDetailPdf);
                    }
                    objSerOrdPdf.DetalleServiceOrder = ListaServiceOrderDetailPdf;
                    objSerOrdPdf.TotalProtocolo      = ListaServiceOrderDetailPdf.Sum(s => s.v_Precio);
                    Lista.Add(objSerOrdPdf);
                }

                var oSystemUserList = new SecurityDal().GetSystemUserAndProfesional(userId);

                string ruta = HttpContext.Current.Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["rutaCotizacion"]);
                string path = ruta + "/" + data.EntityserviceOrder.v_ServiceOrderId + ".pdf";
                if (data.EntityserviceOrder.i_EsProtocoloEspecial == (int)SiNo.Si)
                {
                    OrdenServicioPromocion.CrearOrdenServicio(data.EntityserviceOrder.i_MostrarPrecio == (int)SiNo.Si ? true : false, Lista, MedicalCenter, pEmpresaCliente, DateTime.Parse(FechaEmision).ToString("dd 'd'e MMMM 'd'e yyyy"), oSystemUserList == null ? "" : oSystemUserList.Profesion + ". " + oSystemUserList.v_PersonName, path);
                }
                else
                {
                    OrdenServicio.CrearOrdenServicio(data.EntityserviceOrder.i_MostrarPrecio == (int)SiNo.Si ? true : false, Lista, MedicalCenter, pEmpresaCliente, data.EntityserviceOrder.v_ServiceOrderId, DateTime.Parse(FechaEmision).ToString("dd 'd'e MMMM 'd'e yyyy"), oSystemUserList == null ? "" : oSystemUserList.Profesion + ". " + oSystemUserList.v_PersonName, path);
                }
                msg.Error  = false;
                msg.Id     = data.EntityserviceOrder.v_ServiceOrderId + ".pdf";
                msg.Status = (int)HttpStatusCode.Accepted;
                return(msg);
            }
            catch (Exception ex)
            {
                msg.Error   = true;
                msg.Status  = (int)HttpStatusCode.BadRequest;
                msg.Message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(msg);
            }
        }