Exemplo n.º 1
0
        public ticketDto GetTicket(ref OperationResult objOperationResult, string _tickId)
        {
            try
            {
                SigesoftEntitiesModel dbContext    = new SigesoftEntitiesModel();
                ticketDto             objDtoEntity = null;

                var objEntity = (from a in dbContext.ticket
                                 where a.v_TicketId == _tickId
                                 select a).FirstOrDefault();

                if (objEntity != null)
                {
                    objDtoEntity = ticketAssembler.ToDTO(objEntity);
                }

                objOperationResult.Success = 1;
                return(objDtoEntity);
            }
            catch (Exception ex)
            {
                objOperationResult.Success          = 0;
                objOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex);
                return(null);
            }
        }
Exemplo n.º 2
0
        private void LoadData()
        {
            OperationResult objOperationResult = new OperationResult();

            Utils.LoadDropDownList(cboTipoCuenta, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 310, null), DropDownListAction.All);
            this.grdTicketDetalle.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns;

            if (_mode == "New")
            {
                int Year      = DateTime.Now.Year;
                int Month     = DateTime.Now.Month;
                int intNodeId = int.Parse(Globals.ClientSession.GetAsList()[2]);

                txtFecha.Text     = DateTime.Now.ToString("dd/MM/yyyy");
                txtNServicio.Text = _serviceId;
            }
            else if (_mode == "Edit")
            {
                objticketDtoo = _objTicketBl.GetTicket(ref objOperationResult, _tickId);

                txtNTicket.Text   = objticketDtoo.v_TicketId;
                txtFecha.Text     = objticketDtoo.d_Fecha.ToString();
                txtNServicio.Text = objticketDtoo.v_ServiceId;
                if (objticketDtoo.i_ConCargoA == (int)CargoHospitalizacion.Paciente)
                {
                    rbPaciente.Checked = true;
                }
                else
                {
                    rbMedicoTratante.Checked = true;
                }

                cboTipoCuenta.SelectedValue = objticketDtoo.i_TipoCuentaId.ToString();

                var dataListPc = _objTicketBl.GetTicketDetails(ref objOperationResult, _tickId);

                if (objticketDtoo.i_TicketInterno == 1)
                {
                    chkTicketInterno.Checked = true;
                }
                else
                {
                    chkTicketInterno.Checked = false;
                }

                grdTicketDetalle.DataSource = dataListPc;

                _tmpTicketDetalleList = dataListPc;

                if (objOperationResult.Success != 1)
                {
                    MessageBox.Show("Error en operación:" + System.Environment.NewLine + objOperationResult.ExceptionMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 3
0
        public string AddTicket(ref OperationResult objOperationResult, ticketDto objticketDto, List <ticketdetalleDto> pobjticketdetalleDto, List <string> ClientSession)
        {
            string NewId0 = null;

            try
            {
                SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();
                ticket objEntity = ticketAssembler.ToEntity(objticketDto);

                objEntity.d_InsertDate   = DateTime.Now;
                objEntity.i_InsertUserId = Int32.Parse(ClientSession[2]);
                objEntity.i_IsDeleted    = 0;
                // Autogeneramos el Pk de la tabla
                int intNodeId = int.Parse(ClientSession[0]);
                NewId0 = Common.Utils.GetNewId(intNodeId, Utils.GetNextSecuentialId(intNodeId, 345), "TK");;
                objEntity.v_TicketId = NewId0;

                dbContext.AddToticket(objEntity);
                dbContext.SaveChanges();

                foreach (var item in pobjticketdetalleDto)
                {
                    ticketdetalle objEntity1 = ticketdetalleAssembler.ToEntity(item);

                    objEntity1.d_InsertDate   = DateTime.Now;
                    objEntity1.i_InsertUserId = Int32.Parse(ClientSession[2]);
                    objEntity1.i_IsDeleted    = 0;

                    var NewId1 = Common.Utils.GetNewId(intNodeId, Utils.GetNextSecuentialId(intNodeId, 346), "KD");
                    objEntity1.v_TicketDetalleId = NewId1;
                    objEntity1.v_TicketId        = NewId0;

                    dbContext.AddToticketdetalle(objEntity1);
                    dbContext.SaveChanges();
                }

                objOperationResult.Success = 1;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "TK", "v_TicketId=" + NewId0.ToString(), Success.Ok, null);
            }
            catch (Exception ex)
            {
                objOperationResult.Success          = 0;
                objOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex);
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "TK", "v_TicketId=" + NewId0.ToString(), Success.Failed, objOperationResult.ExceptionMessage);
            }
            return(NewId0);
        }
        private void btnImprimirTicket_Click(object sender, EventArgs e)
        {
            OperationResult _objOperationResult = new OperationResult();

            using (new LoadingClass.PleaseWait(this.Location, "Generando..."))
            {
                this.Enabled = false;

                var MedicalCenter = _serviceBL.GetInfoMedicalCenter();

                var ticketId = grdData.Selected.Rows[0].Cells["v_TicketId"].Value.ToString();

                var lista = _hospitBL.BuscarTicketsDetalle(ticketId);

                //var serviceId = lista.SelectMany(p => p.Servicios.Select(q=>q.v_ServiceId));
                //int doctor = 1;
                Ticket  = _hospitBL.GetHospitServTicket(ticketId);
                hospser = _hospitBL.GetHospitServwithTicekt(Ticket.v_ServiceId);

                serv = _hospitBL.GetService(Ticket.v_ServiceId);
                prot = _hospitBL.GetProtocol(serv.v_ProtocolId);

                var datosP = _pacientBL.DevolverDatosPaciente(Ticket.v_ServiceId);

                string      ruta       = Common.Utils.GetApplicationConfigValue("rutaTicketsH").ToString();
                ServiceList personData = _serviceBL.GetServicePersonData(ref _objOperationResult, hospser.v_ServiceId);

                var hospitalizacion           = _hospitBL.GetHospitalizacion(ref _objOperationResult, hospser.v_HopitalizacionId);
                var hospitalizacionhabitacion = _hospitBL.GetHospitalizacionHabitacion(ref _objOperationResult, hospser.v_HopitalizacionId);
                var medicoTratante            = new ServiceBL().GetMedicoTratante(Ticket.v_ServiceId);

                string nombre = "Ticket N° " + ticketId + "_" + personData.v_DocNumber;

                TicketHosp.CreateTicket(ruta + nombre + ".pdf", MedicalCenter, lista, datosP, hospitalizacion, hospitalizacionhabitacion, medicoTratante, Ticket, prot);

                this.Enabled = true;
            }
            //this.Close();
        }
Exemplo n.º 5
0
        private void btnGuardarTicket_Click(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();

            _ticketdetalleDTO = new List <ticketdetalleDto>();
            if (objticketDto == null)
            {
                objticketDto = new ticketDto();
            }
            //objticketDto.v_TicketId
            txtNServicio.Text            = _serviceId;
            objticketDto.v_ServiceId     = txtNServicio.Text;
            objticketDto.d_Fecha         = DateTime.Parse(txtFecha.Text);
            objticketDto.i_ConCargoA     = rbMedicoTratante.Checked ? (int)CargoHospitalizacion.MedicoTratante :(int)CargoHospitalizacion.Paciente;
            objticketDto.i_TipoCuentaId  = int.Parse(cboTipoCuenta.SelectedValue.ToString());
            objticketDto.i_TicketInterno = chkTicketInterno.Checked ? 1 : 0;
            if (_mode == "New")
            {
                foreach (var item in _tmpTicketDetalleList)
                {
                    ticketdetalleDto ticketDetalle = new ticketdetalleDto();

                    ticketDetalle.v_IdProductoDetalle  = item.v_IdProductoDetalle;
                    ticketDetalle.d_Cantidad           = item.d_Cantidad;
                    ticketDetalle.i_EsDespachado       = item.i_EsDespachado;
                    ticketDetalle.v_CodInterno         = item.v_CodInterno;
                    ticketDetalle.v_Descripcion        = item.v_NombreProducto;
                    ticketDetalle.d_PrecioVenta        = item.d_PrecioVenta;
                    ticketDetalle.d_SaldoPaciente      = item.d_SaldoPaciente;
                    ticketDetalle.d_SaldoAseguradora   = item.d_SaldoAseguradora;
                    ticketDetalle.v_IdUnidadProductiva = item.v_IdUnidadProductiva;
                    _ticketdetalleDTO.Add(ticketDetalle);
                }


                DialogResult Result = MessageBox.Show("¿Desea Guardar Ticket?", "ADVERTENCIA!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (Result == System.Windows.Forms.DialogResult.Yes)
                {
                    ticketId = _objTicketBl.AddTicket(ref objOperationResult, objticketDto, _ticketdetalleDTO, Globals.ClientSession.GetAsList());
                    this.Close();
                }
                else
                {
                    this.Close();
                }

                //if (!string.IsNullOrEmpty(_tickId))
                //{
                //    _mode = "Edit";
                //    _tickId = txtNTicket.Text;
                //}
            }
            else if (_mode == "Edit")
            {
                objticketDto.v_TicketId = _tickId;
                _ticketdetalleDTOUpdate = new List <ticketdetalleDto>();
                _ticketdetalleDTODelete = new List <ticketdetalleDto>();

                objticketDto.d_Fecha         = DateTime.Parse(txtFecha.Text);
                objticketDto.i_ConCargoA     = rbMedicoTratante.Checked ? (int)CargoHospitalizacion.MedicoTratante : (int)CargoHospitalizacion.Paciente;
                objticketDto.i_TipoCuentaId  = int.Parse(cboTipoCuenta.SelectedValue.ToString());
                objticketDto.i_TicketInterno = chkTicketInterno.Checked ? 1 : 0;
                foreach (var item in _tmpTicketDetalleList)
                {
                    #region Add
                    if (item.i_RecordType == (int)RecordType.Temporal && item.i_RecordStatus == (int)RecordStatus.Agregado)
                    {
                        ticketdetalleDto ticketdetalleDtoAdd = new ticketdetalleDto();

                        ticketdetalleDtoAdd.v_IdProductoDetalle  = item.v_IdProductoDetalle;
                        ticketdetalleDtoAdd.d_Cantidad           = item.d_Cantidad;
                        ticketdetalleDtoAdd.i_EsDespachado       = item.i_EsDespachado;
                        ticketdetalleDtoAdd.v_CodInterno         = item.v_CodInterno;
                        ticketdetalleDtoAdd.v_Descripcion        = item.v_NombreProducto;
                        ticketdetalleDtoAdd.d_PrecioVenta        = item.d_PrecioVenta;
                        ticketdetalleDtoAdd.d_SaldoPaciente      = item.d_SaldoPaciente;
                        ticketdetalleDtoAdd.d_SaldoAseguradora   = item.d_SaldoAseguradora;
                        ticketdetalleDtoAdd.v_IdUnidadProductiva = item.v_IdUnidadProductiva;
                        _ticketdetalleDTO.Add(ticketdetalleDtoAdd);
                    }
                    #endregion

                    #region Upd
                    if (item.i_RecordType == (int)RecordType.NoTemporal && item.i_RecordStatus == (int)RecordStatus.Modificado)
                    {
                        ticketdetalleDto ticketdetalleDtoUp = new ticketdetalleDto();
                        ticketdetalleDtoUp.v_TicketDetalleId    = item.v_TicketDetalleId;
                        ticketdetalleDtoUp.v_IdProductoDetalle  = item.v_IdProductoDetalle;
                        ticketdetalleDtoUp.d_Cantidad           = item.d_Cantidad;
                        ticketdetalleDtoUp.i_EsDespachado       = item.i_EsDespachado;
                        ticketdetalleDtoUp.v_CodInterno         = item.v_CodInterno;
                        ticketdetalleDtoUp.v_Descripcion        = item.v_NombreProducto;
                        ticketdetalleDtoUp.d_PrecioVenta        = item.d_PrecioVenta;
                        ticketdetalleDtoUp.i_IsDeleted          = 0;
                        ticketdetalleDtoUp.d_SaldoPaciente      = item.d_SaldoPaciente;
                        ticketdetalleDtoUp.d_SaldoAseguradora   = item.d_SaldoAseguradora;
                        ticketdetalleDtoUp.v_IdUnidadProductiva = item.v_IdUnidadProductiva;
                        _ticketdetalleDTOUpdate.Add(ticketdetalleDtoUp);
                    }
                    #endregion

                    #region Del
                    if (item.i_RecordType == (int)RecordType.NoTemporal && item.i_RecordStatus == (int)RecordStatus.EliminadoLogico)
                    {
                        ticketdetalleDto ticketdetalleDtoDel = new ticketdetalleDto();

                        ticketdetalleDtoDel.v_TicketDetalleId = item.v_TicketDetalleId;

                        _ticketdetalleDTODelete.Add(ticketdetalleDtoDel);
                    }
                    #endregion
                }

                DialogResult Result = MessageBox.Show("¿Desea Guardar Ticket Editado?", "ADVERTENCIA!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (Result == System.Windows.Forms.DialogResult.Yes)
                {
                    _objTicketBl.UpdateTicket(ref objOperationResult,
                                              objticketDto,
                                              _ticketdetalleDTO,
                                              _ticketdetalleDTOUpdate.Count == 0 ? null : _ticketdetalleDTOUpdate,
                                              _ticketdetalleDTODelete.Count == 0 ? null : _ticketdetalleDTODelete,
                                              Globals.ClientSession.GetAsList());
                    this.Close();
                }
                else
                {
                    this.Close();
                }
                //if (objOperationResult.Success == 1)  // Operación sin error
                //{
                //    //this.DialogResult = DialogResult.OK;
                //    MessageBox.Show("Se grabo correctamente.", "INFORMACION!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    _mode = "Edit";
                //    //this.Close();
                //}
                //else  // Operación con error
                //{
                //    MessageBox.Show(Constants.GenericErrorMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //    // Se queda en el formulario.
                //}
            }
        }
Exemplo n.º 6
0
        public static void CreateTicket(string filePDF,
                                        organizationDto infoEmpresaPropietaria, List <TicketDetalleList> detalleTicket,
                                        PacientList datosPac, hospitalizacionDto hospit,
                                        hospitalizacionhabitacionDto hospitHabit, MedicoTratanteAtenciones medico, ticketDto ticket, protocolDto protocolo)
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 45f, 41f);

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include       = string.Empty;
            List <PdfPCell> cells         = null;
            float[]         columnWidths  = null;
            string[]        columnValues  = null;
            string[]        columnHeaders = null;
            PdfPTable       header2       = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            PdfPCell  cell            = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValue1        = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold1    = FontFactory.GetFont("Calibri", 9, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresaPropietaria.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);
            var tamaño_celda = 15f;
            var cellsTit     = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("TICKET " + ticket.v_TicketId, fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            #region DATOS
            string titular = "";
            if (datosPac.v_OwnerName == "")
            {
                titular = datosPac.v_FirstName + " " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName;
            }
            else
            {
                titular = datosPac.v_OwnerName;
            }
            string n_habitac = "";
            if (hospitHabit.i_HabitacionId == 1)
            {
                n_habitac = "201";
            }
            else if (hospitHabit.i_HabitacionId == 2)
            {
                n_habitac = "202";
            }
            else if (hospitHabit.i_HabitacionId == 3)
            {
                n_habitac = "203";
            }
            else if (hospitHabit.i_HabitacionId == 4)
            {
                n_habitac = "204";
            }
            else if (hospitHabit.i_HabitacionId == 5)
            {
                n_habitac = "205";
            }
            else if (hospitHabit.i_HabitacionId == 6)
            {
                n_habitac = "206";
            }
            else if (hospitHabit.i_HabitacionId == 7)
            {
                n_habitac = "207";
            }
            else if (hospitHabit.i_HabitacionId == 8)
            {
                n_habitac = "208";
            }
            else if (hospitHabit.i_HabitacionId == 9)
            {
                n_habitac = "301";
            }
            else if (hospitHabit.i_HabitacionId == 10)
            {
                n_habitac = "302";
            }
            else if (hospitHabit.i_HabitacionId == 11)
            {
                n_habitac = "303";
            }
            else if (hospitHabit.i_HabitacionId == 12)
            {
                n_habitac = "304";
            }
            else if (hospitHabit.i_HabitacionId == 13)
            {
                n_habitac = "305";
            }
            else if (hospitHabit.i_HabitacionId == 14)
            {
                n_habitac = "306";
            }
            else if (hospitHabit.i_HabitacionId == 15)
            {
                n_habitac = "307";
            }
            else if (hospitHabit.i_HabitacionId == 16)
            {
                n_habitac = "308";
            }
            else
            {
                n_habitac = "- - -";
            }
            string med = "";

            if (medico != null)
            {
                med = medico.Nombre;
            }
            else
            {
                med = "CLINICA SAN LORENZO";
            }
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("SERViCIO: ", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(protocolo.v_Name, fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("CÓDIGO INTERNO: ", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(hospitHabit.v_HopitalizacionId, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("PACIENTE: ", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_FirstName + " " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("TITULAR: ", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(titular, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("HIST. CLINICA : ", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_DocNumber, fontColumnValueBold1))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("CAMA : ", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(n_habitac, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("EMPRESA: ", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_Employer, fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("INGRESO :", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(hospit.d_FechaIngreso.ToString() == null?"":hospit.d_FechaIngreso.ToString().Split(' ')[0], fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },


                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("MEDICO A CARGO: ", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(med, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 5f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 15f, 30f, 15f, 15f, 10F, 15F };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            #region DATOS
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("DETALLE", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("FECHA", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("TICKET", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("NOMBRE", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("CANT", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
            };
            columnWidths = new float[] { 12f, 12f, 66f, 10f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion


            #region Parte Dinámica
            cells = new List <PdfPCell>();
            int    tamañoTickets = 0;
            string enfermera     = "";
            if (detalleTicket != null)
            {
                var detalletickets = detalleTicket.FindAll(p => p.d_Cantidad != 0);
                tamañoTickets = detalletickets.Count();

                cell = new PdfPCell(new Phrase(ticket.d_Fecha.ToString().Split(' ')[0], fontColumnValue))
                {
                    Rowspan = tamañoTickets, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, MinimumHeight = 15f
                };
                cells.Add(cell);

                cell = new PdfPCell(new Phrase(ticket.i_TipoCuentaId.ToString() == "1" ? "\nSOP" : ticket.i_TipoCuentaId.ToString() == "2" ? "\nPROC - SOP" : ticket.i_TipoCuentaId.ToString() == "3" ? "\nHOSP" : ticket.i_TipoCuentaId.ToString() == "4" ? "\nI. SERV." : string.Empty, fontColumnValue))
                {
                    Rowspan = tamañoTickets, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, MinimumHeight = 15f
                };
                cells.Add(cell);

                foreach (var item in detalleTicket)
                {
                    cell = new PdfPCell(new Phrase(item.v_Descripcion, fontColumnValue))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_LEFT, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, MinimumHeight = 15f
                    };
                    cells.Add(cell);
                    int cantidad = (int)item.d_Cantidad;
                    cell = new PdfPCell(new Phrase(cantidad.ToString(), fontColumnValue))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_CENTER, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, MinimumHeight = 15f
                    };
                    cells.Add(cell);
                    enfermera = item.UsuarioCrea;
                }
            }
            columnWidths = new float[] { 12f, 12f, 66f, 10f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

            document.Add(filiationWorker);
            #endregion

            #region Enfermera
            cells = new List <PdfPCell>();

            cell = new PdfPCell(new Phrase("Enfermera: ", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 25f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase(enfermera, fontColumnValueBold))
            {
                Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 25f
            };
            cells.Add(cell);


            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 50f
            };
            cells.Add(cell);


            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("_______________________________________", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("_______________________________________", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);

            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("FARMACIA", fontColumnValue1))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("PACIENTE: " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + ", " + datosPac.v_FirstName + "\nDNI: " + datosPac.v_DocNumber, fontColumnValue1))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);



            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 30f
            };
            cells.Add(cell);

            columnWidths = new float[] { 10f, 34f, 12f, 34f, 10f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

            document.Add(filiationWorker);
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
            RunFile(filePDF);
        }
Exemplo n.º 7
0
        public void UpdateTicket(ref OperationResult _pobjOperationResult, ticketDto objticketDto, List <ticketdetalleDto> _ticketdetalleDTOAdd, List <ticketdetalleDto> _ticketdetalleDTOUpdate, List <ticketdetalleDto> _ticketdetalleDTODelete, List <string> ClientSession)
        {
            try
            {
                SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();

                #region Actualizar ticket
                var objEntitySource = (from a in dbContext.ticket
                                       where a.v_TicketId == objticketDto.v_TicketId
                                       select a).FirstOrDefault();
                objticketDto.d_UpdateDate = DateTime.Now;
                if (objEntitySource.d_InsertDate == null || objEntitySource.i_InsertUserId == null)
                {
                    objticketDto.d_InsertDate   = DateTime.Now;
                    objticketDto.i_InsertUserId = Int32.Parse(ClientSession[2]);
                }
                else
                {
                    objticketDto.d_InsertDate   = objEntitySource.d_InsertDate;
                    objticketDto.i_InsertUserId = objEntitySource.i_InsertUserId;
                }

                objticketDto.i_UpdateUserId = Int32.Parse(ClientSession[2]);
                objticketDto.i_IsDeleted    = 0;
                ticket objStrongEntity = ticketAssembler.ToEntity(objticketDto);
                dbContext.ticket.ApplyCurrentValues(objStrongEntity);
                dbContext.SaveChanges();
                #endregion

                int intNodeId = int.Parse(ClientSession[0]);

                #region add detalle

                foreach (var item in _ticketdetalleDTOAdd)
                {
                    ticketdetalle objEntity1 = ticketdetalleAssembler.ToEntity(item);

                    objEntity1.d_InsertDate   = DateTime.Now;
                    objEntity1.i_InsertUserId = Int32.Parse(ClientSession[2]);
                    objEntity1.i_IsDeleted    = 0;

                    var NewId1 = Common.Utils.GetNewId(intNodeId, Utils.GetNextSecuentialId(intNodeId, 346), "KD");
                    objEntity1.v_TicketDetalleId = NewId1;
                    objEntity1.v_TicketId        = objticketDto.v_TicketId;
                    dbContext.AddToticketdetalle(objEntity1);
                    dbContext.SaveChanges();
                }
                #endregion

                #region upd detalle
                if (_ticketdetalleDTOUpdate != null)
                {
                    foreach (var item in _ticketdetalleDTOUpdate)
                    {
                        var updatedetalleticket = (from a in dbContext.ticketdetalle
                                                   where a.v_TicketDetalleId == item.v_TicketDetalleId
                                                   select a).FirstOrDefault();

                        //objEntitySource1.v_ComponentId = item.v_ComponentId;

                        updatedetalleticket.d_Cantidad         = item.d_Cantidad;
                        updatedetalleticket.i_EsDespachado     = item.i_EsDespachado;
                        updatedetalleticket.d_SaldoAseguradora = item.d_SaldoAseguradora;
                        updatedetalleticket.d_SaldoPaciente    = item.d_SaldoPaciente;
                        updatedetalleticket.i_IsDeleted        = 0;

                        updatedetalleticket.d_UpdateDate   = DateTime.Now;
                        updatedetalleticket.i_UpdateUserId = Int32.Parse(ClientSession[2]);
                        dbContext.SaveChanges();
                    }
                }

                #endregion

                #region del detalle

                if (_ticketdetalleDTODelete != null)
                {
                    foreach (var item in _ticketdetalleDTODelete)
                    {
                        var objEntitySource1 = (from a in dbContext.ticketdetalle
                                                where a.v_TicketDetalleId == item.v_TicketDetalleId
                                                select a).FirstOrDefault();

                        objEntitySource1.d_UpdateDate   = DateTime.Now;
                        objEntitySource1.i_UpdateUserId = Int32.Parse(ClientSession[2]);
                        objEntitySource1.i_IsDeleted    = 1;
                        dbContext.SaveChanges();
                    }
                }
                #endregion

                //dbContext.SaveChanges();
                _pobjOperationResult.Success = 1;

                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "TICKET / DETALLE", "v_TicketId=" + objticketDto.v_TicketId.ToString(), Success.Ok, null);
                return;
            }
            catch (Exception ex)
            {
                _pobjOperationResult.Success          = 0;
                _pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex);

                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "TICKET / DETALLE", "v_TicketId=" + objticketDto.v_TicketId.ToString(), Success.Failed, _pobjOperationResult.ExceptionMessage);
                return;
            }
        }