예제 #1
0
        public ActionResult RprintTicket(TrRprintTicketViewModel vmodel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    TrRprintTicketViewModel vm = new TrRprintTicketViewModel
                    {
                        Tickets   = TicketBL.FindTicket(vmodel),
                        MethodsP  = PaymentBL.FindMethodsList(),
                        Languages = LanguageBL.FindLanguageListWithoutUniversal()
                    };
                    ViewBag.ticket = true;
                    return(View(vm));
                }
                vmodel.MethodsP  = PaymentBL.FindMethodsList();
                vmodel.Languages = LanguageBL.FindLanguageListWithoutUniversal();
                ViewBag.ticket   = false;
                return(View(vmodel));
            }
            catch (Exception ex)
            {
                //to do insert to log file
                var e1 = ex.GetBaseException(); // --> log
                var e4 = ex.Message;            // --> log
                var e5 = ex.Source;             // --> log
                var e8 = ex.GetType();          // --> log
                var e9 = ex.GetType().Name;     // --> log

                return(View("Error"));
            }
        }
예제 #2
0
        private ActionResult PayCash(TrPaymentMenuViewModel vmodel)
        {
            var     temp = vmodel.Amount.Replace(".", ",");
            decimal cash = decimal.Parse(temp);

            // legal limit for cash
            if (cash <= 3000)
            {
                PaymentBL.CalculCash(vmodel);
            }
            else
            {
                @ViewBag.limitCash = "Montant cash max de 3000 € dépassé !";
            }
            ViewBag.tot         = vmodel.GlobalTotal;
            ViewBag.amount      = vmodel.Amount;
            ViewBag.cashBack    = vmodel.CashReturn;
            vmodel.MethodsP     = PaymentBL.FindMethodsList();
            vmodel.AmountsPaid  = PaymentBL.MakeAmountsList(vmodel.NumTransaction);
            ViewBag.messageCard = "";
            if (ViewBag.tot == "0")
            {
                vmodel.Ticket    = TicketBL.FillTicket(vmodel.NumTransaction);
                ViewBag.NumT     = vmodel.Ticket.Ticket;
                vmodel.NumTicket = vmodel.Ticket.Ticket;
                ViewBag.ticket   = true;
            }
            else
            {
                ViewBag.ticket = false;
            }
            return(View(vmodel));
        }
        public List <Ticket> GetListTicketByMatchID(int matchID, Customer customer)
        {
            TicketBL      tkbl           = new TicketBL();
            List <Ticket> listShowTicket = new List <Ticket>();

            try
            {
                listShowTicket = tkbl.GetListTicketByMatchID(matchID);
                if (listShowTicket.Count != 0)
                {
                    var table = new ConsoleTable("Ma Ve", "Loai Ve", "Gia", "So Luong");
                    foreach (var item in listShowTicket)
                    {
                        string ticketprice = pricevalid(item.TicketPrice);
                        table.AddRow(item.TicketID, item.TicketType, ticketprice, item.Amount);
                    }
                    table.Write(Format.Default);
                    return(listShowTicket);
                }
            }
            catch (Exception)
            {
                Console.Write("Loi!! Nhan phim bat ki de tro lai man hinh dang nhap!");
                Console.ReadKey();
                m.LoginInterface();
            }
            return(listShowTicket);
        }
예제 #4
0
        public async Task <TicketBL> EditTicket(TicketBL ticket)
        {
            await _unitOfWork.TicketRepository.Update(_mapper.Map <TicketEntity>(ticket));

            _unitOfWork.Save();
            return(await GetTicketById(ticket.Id));
        }
예제 #5
0
 public ApplicationUsersController()
 {
     _puBL   = new ProjectUserBL();
     _userBL = new UserBL();
     _pBL    = new ProjectBL();
     _tBL    = new TicketBL();
 }
예제 #6
0
 public TicketsController()
 {
     _tRepo  = new TicketBL();
     _pRepo  = new ProjectBL();
     _tpRepo = new TicketPriorityBL();
     _tsRepo = new TicketStatusBL();
     _ttRepo = new TicketTypeBL();
     _uBL    = new UserBL();
 }
예제 #7
0
        private void txtMedicamento_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
        {
            TicketBL oTicketBL = new TicketBL();
            var      f         = new frmSearchMedicamento();
            var      result    = f.ShowDialog();

            if (result == DialogResult.OK)
            {
                var medicamento = f.MedicamentoSeleccionado;
                if (medicamento == null)
                {
                    return;
                }
                txtMedicamento.Text      = medicamento.NombreCompleto;
                txtMedicamento.Tag       = medicamento.IdProductoDetalle;
                idUnidadProductiva       = medicamento.IdLinea;
                txtUnidadProductiva.Text = medicamento.IdLinea;
                txtPrecio.Text           = medicamento.PrecioVenta.ToString();
                var tienePlan  = false;
                var resultplan = oTicketBL.TienePlan(_protocolId, txtUnidadProductiva.Text);
                if (resultplan.Count > 0)
                {
                    tienePlan = true;
                }
                else
                {
                    tienePlan = false;
                }

                if (tienePlan)
                {
                    if (resultplan[0].i_EsCoaseguro == 1)
                    {
                        #region Conexion SAM
                        ConexionSigesoft conectasam = new ConexionSigesoft();
                        conectasam.opensigesoft();
                        #endregion
                        var           cadena1 = "select PR.r_MedicineDiscount, OO.v_Name, PR.v_CustomerOrganizationId from Organization OO inner join protocol PR On PR.v_AseguradoraOrganizationId = OO.v_OrganizationId where PR.v_ProtocolId ='" + _protocolId + "'";
                        SqlCommand    comando = new SqlCommand(cadena1, connection: conectasam.conectarsigesoft);
                        SqlDataReader lector  = comando.ExecuteReader();
                        string        eps     = "";
                        while (lector.Read())
                        {
                            eps = lector.GetValue(0).ToString();
                        }
                        lector.Close();
                        conectasam.closesigesoft();
                        //calculo nuevo precio
                        txtPPS.Text     = medicamento.d_PrecioMayorista.ToString();
                        txtDctoEPS.Text = eps;
                        decimal nuevoPrecio = decimal.Parse(txtPPS.Text) - ((decimal.Parse(eps) * decimal.Parse(txtPPS.Text)) / 100);
                        txtNuevoPrecio.Text = nuevoPrecio.ToString();
                    }
                }
            }
        }
예제 #8
0
        public JsonResult LoadData()
        {
            int draw, start, length;
            int pageIndex = 0;

            if (null != Request.Form.GetValues("draw"))
            {
                draw   = int.Parse(Request.Form.GetValues("draw").FirstOrDefault().ToString());
                start  = int.Parse(Request.Form.GetValues("start").FirstOrDefault().ToString());
                length = int.Parse(Request.Form.GetValues("length").FirstOrDefault().ToString());
            }
            else
            {
                draw   = 1;
                start  = 0;
                length = 500;
            }

            if (start == 0)
            {
                pageIndex = 1;
            }
            else
            {
                pageIndex = (start / length) + 1;
            }

            TicketBL bL           = new TicketBL();
            int      totalrecords = 0;

            List <Ticket> pocoList = new List <Ticket>();

            pocoList = bL.GetAllTicketPageWise(pageIndex, ref totalrecords, length);
            List <Ticket> pList = new List <Ticket>();

            foreach (Ticket pC in pocoList)
            {
                Ticket pOCO = new Ticket();
                //pOCO.Id = pC.Id;
                pOCO.TicketNumber = pC.TicketNumber;
                pOCO.Error        = pC.Error;
                pOCO.Description  = pC.Description;
                pOCO.IsSolved     = pC.IsSolved;

                pList.Add(pOCO);
            }

            var data = pList;

            return(Json(new { draw = draw, recordsFiltered = totalrecords, recordsTotal = totalrecords, data = data }, JsonRequestBehavior.AllowGet));
        }
        private void btnEliminarTicket_Click(object sender, EventArgs e)
        {
            DialogResult Result = MessageBox.Show("¿Está seguro de eliminar el ticket?", "ADVERTENCIA!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (Result == System.Windows.Forms.DialogResult.Yes)
            {
                OperationResult objOperationResult = new OperationResult();
                TicketBL        oTicketBL          = new TicketBL();

                var ServiceId = grdData.Selected.Rows[0].Cells["v_ServiceId"].Value.ToString();
                var ticketId  = grdData.Selected.Rows[0].Cells["v_TicketId"].Value.ToString();
                oTicketBL.DeleteTicket(ticketId, Globals.ClientSession.GetAsList());
            }
        }
예제 #10
0
 public frmTicket(List <TicketList> Lista, string IdControl, string id, string mode, string protocolId, string modo)
 {
     _tickId     = id;
     _mode       = mode;
     _serviceId  = IdControl;
     _protocolId = protocolId;
     //_ticketId = IdControl;
     InitializeComponent();
     _objHospitalizacionBl  = new HospitalizacionBL();
     _objRecetaBl           = new RecetaBl();
     _objTicketBl           = new TicketBL();
     _listTicketList        = Lista;
     _listTicketDetalleList = new List <TicketDetalleList>();
     _modo = modo;
 }
예제 #11
0
        private void handleFinishEdit(object sender, System.Collections.Specialized.OrderedDictionary e)
        {
            if (sender.Equals(this.addTicket))
            {
                string code        = e[Constants.codeField].ToString();
                string spectacol   = e[Constants.spectacolField].ToString();
                int    nrOfTickets = SpectacleBL.getNrOfTicketsForSpectacle(spectacol);
                if (nrOfTickets == 0)
                {
                    MessageBox.Show("Cannot add more tickets");
                    return;
                }
                else if (nrOfTickets == -1)
                {
                    MessageBox.Show("Bad request,please check fields");
                    return;
                }
                int rand  = int.Parse(e[Constants.randField].ToString());
                int numar = int.Parse(e[Constants.numarField].ToString());
                OperationResult.opResult result = TicketBL.addTicketForSpectacle(code, spectacol, rand, numar);

                if (result == OperationResult.opResult.OperationInsertTicketDuplicate ||
                    result == OperationResult.opResult.OperationAddTicketFail)
                {
                    MessageBox.Show("Cannot add ticket for this place");
                    return;
                }
                else
                {
                    MessageBox.Show("Succes");
                }
            }
            else if (sender.Equals(this.export))
            {
                ExporterType type      = (ExporterType)int.Parse(e["Export Type"].ToString());
                Exporter     exporter  = ExportFactory.getExporter(type);
                string       spectacol = e[Constants.spectacolField].ToString();

                Array tickets = TicketBL.getAllTicketsForSpectacle(spectacol).ToArray();

                string path = e["File Path"].ToString();

                exporter.exportTickets(tickets.OfType <Ticket>().ToList(), path);
            }
        }
예제 #12
0
 private ActionResult PayCardDebit(TrPaymentMenuViewModel vmodel)
 {
     PaymentBL.CalculCash(vmodel);
     ViewBag.tot      = vmodel.GlobalTotal;
     ViewBag.amount   = vmodel.Amount;
     ViewBag.cashBack = vmodel.CashReturn;
     if (ViewBag.tot == "0")
     {
         vmodel.Ticket  = TicketBL.FillTicket(vmodel.NumTransaction);
         ViewBag.ticket = true;
     }
     else
     {
         ViewBag.ticket = false;
     }
     vmodel.AmountsPaid = PaymentBL.MakeAmountsList(vmodel.NumTransaction);
     vmodel.MethodsP    = PaymentBL.FindMethodsList();
     return(View(vmodel));
 }
예제 #13
0
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        //[Authorize(Roles = "vendor")]
        public ActionResult ProductBack(string nTransac)
        {
            TrProductBackViewModel vm = new TrProductBackViewModel();

            if (Session["Language"] == null)
            {
                Session["Language"] = ConfigurationManager.AppSettings["Language"];
            }
            string language = Session["Language"].ToString();
            //to do --> change init isChange..
            bool isChange = false;

            vm.Ticket         = TicketBL.FillTicket(nTransac, language, isChange);
            vm.Language       = language;
            vm.Languages      = LanguageBL.FindLanguageList();
            vm.NumTransaction = nTransac;
            vm.DateT          = vm.Ticket.DateTicket;
            ViewBag.DateTi    = vm.Ticket.DateTicket;
            return(View(vm));
        }
예제 #14
0
        public SellsManagement()
        {
            cliente = productos = 0;
            InitializeComponent();
            this.CenterToScreen();

            productBL       = new ProductBL();
            naturalClientBL = new NaturalClientBL();
            legalClientBL   = new LegalClientBL();
            ticketBL        = new TicketBL();

            addedQuantity = new Dictionary <int, int>();

            DateTime thisDay = DateTime.Today;

            fechaTextBox.Text = thisDay.ToString("d");

            dataGridView3.AutoGenerateColumns = false;
            dataGridView2.AutoGenerateColumns = false;
            dataGridView2.RowHeadersVisible   = false;
            dataGridView3.RowHeadersVisible   = false;

            listAdded = new BindingList <Product>();
            dataGridView2.DataSource = productBL.listProducts();
            dataGridView3.DataSource = listAdded;

            textBox4.Text           = Constants.CurrentUserText;
            comboBox1.SelectedIndex = 0;
            comboBox2.SelectedIndex = 0;

            textBox2.Show();
            textBox6.Hide();

            BindingList <Product> products = productBL.listProducts();

            foreach (Product p in products)
            {
                addedQuantity.Add(p.Id, 0);
            }
        }
예제 #15
0
        private void handlerTableEditRow(object sender, System.Collections.Specialized.OrderedDictionary e)
        {
            if (sender.Equals(spectalesTable))
            {
                string titlu   = e[Constants.titluField].ToString();
                Array  tickets = TicketBL.getAllTicketsForSpectacle(titlu).ToArray();
                if (tickets == null || tickets.Length == 0)
                {
                    MessageBox.Show("No tickets added for this spectacle");
                    return;
                }


                if (currentView != null)
                {
                    currentView.dismissFromContainer();
                }
                ticketsTable.drawInForm(this);
                ticketsTable.refreshWithData(tickets);
                currentView = ticketsTable;
            }
        }
예제 #16
0
        private ActionResult PayCash(TrPaymentMenuViewModel vmodel, string language)
        {
            var     temp = vmodel.Amount.Replace(".", ",");
            decimal cash = decimal.Parse(temp);

            // legal limit for cash
            if (cash <= 3000)
            {
                PaymentBL.CalculCash(vmodel);
            }
            else
            {
                @ViewBag.limitCash = "Montant cash max de 3000 € dépassé !";
            }
            ViewBag.tot         = vmodel.GlobalTotal;
            ViewBag.amount      = vmodel.Amount;
            ViewBag.cashBack    = vmodel.CashReturn;
            vmodel.MethodsP     = PaymentBL.FindMethodsList();
            vmodel.AmountsPaid  = PaymentBL.MakeAmountsList(vmodel.NumTransaction);
            ViewBag.messageCard = "";
            if (ViewBag.tot == "0")
            {
                //to do --> change init isChange...
                bool isChange = false;
                vmodel.Ticket    = TicketBL.FillTicket(vmodel.NumTransaction, language, isChange);
                vmodel.Language  = vmodel.Ticket.Language;
                vmodel.Languages = LanguageBL.FindLanguageListWithoutUniversal();
                vmodel.DateT     = vmodel.Ticket.DateTicket;
                ViewBag.DateTi   = vmodel.Ticket.DateTicket;
                ViewBag.ticket   = true;
            }
            else
            {
                ViewBag.ticket = false;
            }
            return(View(vmodel));
        }
예제 #17
0
 private ActionResult PayCardDebit(TrPaymentMenuViewModel vmodel, string language)
 {
     PaymentBL.CalculCash(vmodel);
     ViewBag.tot      = vmodel.GlobalTotal;
     ViewBag.amount   = vmodel.Amount;
     ViewBag.cashBack = vmodel.CashReturn;
     if (ViewBag.tot == "0")
     {
         //to do --> change init isChange...
         bool isChange = false;
         vmodel.Ticket    = TicketBL.FillTicket(vmodel.NumTransaction, language, isChange);
         vmodel.Language  = vmodel.Ticket.Language;
         vmodel.Languages = LanguageBL.FindLanguageListWithoutUniversal();
         ViewBag.DateTi   = vmodel.Ticket.DateTicket;
         ViewBag.ticket   = true;
     }
     else
     {
         ViewBag.ticket = false;
     }
     vmodel.AmountsPaid = PaymentBL.MakeAmountsList(vmodel.NumTransaction);
     vmodel.MethodsP    = PaymentBL.FindMethodsList();
     return(View(vmodel));
 }
예제 #18
0
        ////// same simulation process PayCardDebit
        //private ActionResult PayCardCredit(TrPaymentMenuViewModel vmodel)
        //{
        //    vmodel.Resp = TransactionBL.AskValidationCard(vmodel.Amount);
        //    if (vmodel.Resp == 1)
        //    {
        //        //to do --> create payment
        //        ViewBag.messageCard = "Demande acceptée !";
        //        ViewBag.tot = vmodel.GlobalTot;
        //        ViewBag.amount = vmodel.Amount;
        //        ViewBag.cashBack = vmodel.CashReturn;
        //        if (ViewBag.tot == "0")
        //        {
        //            vmodel.Ticket = TransactionBL.FillTicket(vmodel.NumTransaction);
        //            //vmodel.NumTicket = vmodel.Ticket.Ticket;
        //            ViewBag.NumT = vmodel.Ticket.Ticket;
        //            vmodel.NumTicket = vmodel.Ticket.Ticket;
        //            ViewBag.ticket = true;
        //        }
        //        else
        //        {

        //            ViewBag.ticket = false;
        //        }
        //    }
        //    else
        //    {
        //        ViewBag.messageCard = "Demande refusée !";
        //        ViewBag.tot = vmodel.GlobalTot;
        //        ViewBag.amount = "";
        //        ViewBag.cashBack = "0";
        //        ViewBag.ticket = false;
        //    }
        //    vmodel.MethodsP = TransactionBL.FindMethodsList();
        //    return View(vmodel);
        //}
        #endregion

        #region OptionsTicket
        public ActionResult ChangeLanguageTicket(TrPaymentMenuViewModel vmodel)
        {
            bool?isChange = true;

            vmodel.Ticket  = TicketBL.FillTicket(vmodel.NumTransaction, vmodel.Language, isChange);
            ViewBag.ticket = true;
            switch (vmodel.Language)
            {
            case "1":
                return(PartialView("_PartialTicket", vmodel.Ticket));

            case "2":
                return(PartialView("_PartialTicketNl", vmodel.Ticket));

            case "3":
                return(PartialView("_PartialTicketDe", vmodel.Ticket));

            case "4":
                return(PartialView("_PartialTicketEn", vmodel.Ticket));

            default:
                return(PartialView("_PartialTicket", vmodel.Ticket));
            }
        }
예제 #19
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            TicketBL oTicketBL = new TicketBL();

            try
            {
                _pobjOperationResult = new OperationResult();
                if (!uvDatos.Validate(true, false).IsValid)
                {
                    return;
                }

                if (txtMedicamento.Tag == null)
                {
                    MessageBox.Show(@"Por favor seleccione un medicamento", @"Error de validación", MessageBoxButtons.OK);
                    txtMedicamento.Focus();
                    return;
                }

                decimal d;
                _recetaDto.d_Cantidad           = decimal.TryParse(txtCantidad.Text, out d) ? d : 0;
                _recetaDto.v_Duracion           = txtDuracion.Text.Trim();
                _recetaDto.v_Posologia          = txtPosologia.Text.Trim();
                _recetaDto.t_FechaFin           = dtpFechaFin.Value;
                _recetaDto.v_IdProductoDetalle  = txtMedicamento.Tag.ToString();
                _recetaDto.v_IdUnidadProductiva = idUnidadProductiva;
                _recetaDto.v_ServiceId          = _serviceId;

                var tienePlan  = false;
                var resultplan = oTicketBL.TienePlan(_protocolId, txtUnidadProductiva.Text);
                if (resultplan.Count > 0)
                {
                    tienePlan = true;
                }
                else
                {
                    tienePlan = false;
                }

                if (tienePlan)
                {
                    if (resultplan[0].i_EsCoaseguro == 1)
                    {
                        #region Conexion SIGESOFT verificar la unidad productiva del componente
                        ConexionSigesoft conectasam = new ConexionSigesoft();
                        conectasam.opensigesoft();
                        var cadena1 = "select PL.d_ImporteCo " +
                                      "from [dbo].[plan] PL " +
                                      "inner join protocol PR on PL.v_ProtocoloId=PR.v_ProtocolId " +
                                      "inner join servicecomponent SC on PL.v_IdUnidadProductiva=SC.v_IdUnidadProductiva " +
                                      "inner join diagnosticrepository DR on DR.v_ComponentId=SC.v_ComponentId " +
                                      "where PR.v_ProtocolId='" + _protocolId + "' and DR.v_DiagnosticRepositoryId='" + _idDiagnosticRepository + "' ";
                        SqlCommand    comando     = new SqlCommand(cadena1, connection: conectasam.conectarsigesoft);
                        SqlDataReader lector      = comando.ExecuteReader();
                        string        ImporteCo   = "";
                        bool          lectorleido = false;
                        while (lector.Read())
                        {
                            ImporteCo   = lector.GetValue(0).ToString();
                            lectorleido = true;
                        }
                        if (lectorleido == false)
                        {
                            MessageBox.Show(@"El consultorio no tiene Plan de Seguros", @"Error de validación", MessageBoxButtons.OK);
                            return;
                        }
                        lector.Close();
                        conectasam.closesigesoft();
                        #endregion
                        _recetaDto.d_SaldoPaciente    = (decimal.Parse(ImporteCo) / 100) * (decimal.Parse(txtNuevoPrecio.Text) * _recetaDto.d_Cantidad);
                        _recetaDto.d_SaldoAseguradora = (decimal.Parse(txtNuevoPrecio.Text) * _recetaDto.d_Cantidad) - _recetaDto.d_SaldoPaciente;
                    }
                }
                else
                {
                    _recetaDto.d_SaldoPaciente = decimal.Parse(txtPrecio.Text) * _recetaDto.d_Cantidad;
                }

                _objRecetaBl.AddUpdateRecipe(ref _pobjOperationResult, _recetaDto);

                if (_pobjOperationResult.Success == 0)
                {
                    MessageBox.Show(_pobjOperationResult.ErrorMessage, @"Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, @"btnGuardar_Click()", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #20
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            TicketBL oTicketBL = new TicketBL();

            if (_TempTicketDetalleList == null)
            {
                _TempTicketDetalleList = new List <TicketDetalleList>();
            }
            OperationResult objOperationResult = new OperationResult();

            string[] componentIdFromProtocol = _TempTicketDetalleList.FindAll(p => p.i_RecordStatus != (int)RecordStatus.EliminadoLogico)
                                               .Select(p => p.v_IdProductoDetalle).ToArray();

            bool IsExists = _ticketlBL.IsExistsproductoInTicket(ref objOperationResult, componentIdFromProtocol, _ProductoId);

            if (IsExists)
            {
                var msj = string.Format("El examen producto puede agregar, ya existe", labelmensaje.Text);
                MessageBox.Show(msj, "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (_mode == "New")
            {
                // || cbExamen.Text == ""
                if (txtMedicamento.Tag == null)
                {
                    string mensage = "";
                    if (txtMedicamento.Tag == null)
                    {
                        mensage = @"Por favor seleccione un medicamento";
                    }
                    //else if (cbExamen.Text == ""){mensage = @"Por favor seleccione un examen";}
                    MessageBox.Show(mensage, @"Error de validación", MessageBoxButtons.OK);
                    txtMedicamento.Focus();
                    return;
                }

                var findResult = _TempTicketDetalleList.Find(p => p.v_IdProductoDetalle == _ProductoId);
                _objTicketDetalleList = new TicketDetalleList();

                if (findResult == null)
                {
                    _objTicketDetalleList.v_TicketDetalleId = Guid.NewGuid().ToString();

                    _objTicketDetalleList.v_IdProductoDetalle  = txtMedicamento.Tag.ToString();
                    _objTicketDetalleList.v_NombreProducto     = txtMedicamento.Text;
                    _objTicketDetalleList.v_CodInterno         = txtCodigo.Text;
                    _objTicketDetalleList.v_IdUnidadProductiva = txtUnidadProductiva.Text;
                    var precioTarifa = oTicketBL.ObtenerPrecioTarifario(_serviceId, _objTicketDetalleList.v_IdProductoDetalle);


                    decimal d;
                    _objTicketDetalleList.d_Cantidad = decimal.TryParse(txtCantidad.Text, out d) ? d : 0;

                    //nuevo
                    //int planId = 0;
                    //var servicioDet = oTicketBL.GetService(ref objOperationResult,_serviceId);
                    //if (servicioDet.i_PlanId != null)
                    //{
                    //    planId = (int)servicioDet.i_PlanId;
                    //}
                    //////


                    var tienePlan = false;
                    //var resultplan = oTicketBL.TienePlan_(_protocolId, planId);
                    var resultplan = oTicketBL.TienePlan(_protocolId, lineId);

                    if (resultplan.Count > 0)
                    {
                        tienePlan = true;
                    }
                    else
                    {
                        tienePlan = false;
                    }

                    if (tienePlan)
                    {
                        if (resultplan[0].i_EsCoaseguro == 1)
                        {
                            #region Conexion SIGESOFT verificar la unidad productiva del componente
                            ConexionSigesoft conectasam = new ConexionSigesoft();
                            conectasam.opensigesoft();
                            var cadena1 = "select PL.d_ImporteCo, PL.i_PlanId " +
                                          "from [dbo].[plan] PL " +
                                          "inner join protocol PR on PL.v_ProtocoloId=PR.v_ProtocolId " +
                                          "where PR.v_ProtocolId='" + _protocolId + "' and PL.v_IdUnidadProductiva='" + lineId + "'";
                            SqlCommand    comando = new SqlCommand(cadena1, connection: conectasam.conectarsigesoft);
                            SqlDataReader lector = comando.ExecuteReader();
                            string        ImporteCo = ""; string PlanId = "";
                            bool          lectorleido = false;
                            while (lector.Read())
                            {
                                ImporteCo   = lector.GetValue(0).ToString();
                                PlanId      = lector.GetValue(1).ToString();
                                lectorleido = true;
                            }

                            if (lectorleido == false)
                            {
                                MessageBox.Show(@"Elija un Examen que tenga Plan de Seguros", @"Error de validación", MessageBoxButtons.OK);
                                return;
                            }
                            lector.Close();

                            #endregion
                            _objTicketDetalleList.d_SaldoPaciente    = decimal.Round((decimal.Parse(txtPrecioVenta.Text)), 2) * decimal.Round((decimal.Parse(txtCantidad.Text)), 2) * decimal.Round((decimal.Parse(ImporteCo)), 2) / 100;
                            _objTicketDetalleList.d_SaldoAseguradora = decimal.Round((decimal.Parse(txtPrecioVenta.Text)), 2) * decimal.Round((decimal.Parse(txtCantidad.Text)), 2) - _objTicketDetalleList.d_SaldoPaciente;
                            _objTicketDetalleList.d_PrecioVenta      = decimal.Round((decimal.Parse(txtPrecioVenta.Text)), 2);

                            #region Update a service agrega el PlanId
                            var cadena2 = "update service set " +
                                          "i_PlanId = '" + PlanId + "' " +
                                          "where v_ServiceId = '" + _serviceId + "' ";
                            SqlCommand    comando_ = new SqlCommand(cadena2, connection: conectasam.conectarsigesoft);
                            SqlDataReader lector_  = comando_.ExecuteReader();
                            lector_.Close();

                            conectasam.closesigesoft();
                            #endregion
                        }
                        else if (resultplan[0].i_EsDeducible == 1)
                        {
                        }
                    }
                    else
                    {
                        _objTicketDetalleList.d_PrecioVenta = decimal.Round((decimal.Parse(txtPrecio.Text)), 2);   // decimal.Parse(txtPrecioVenta.Text);
                    }

                    _objTicketDetalleList.i_RecordStatus = (int)RecordStatus.Agregado;
                    _objTicketDetalleList.i_RecordType   = (int)RecordType.Temporal;


                    _TempTicketDetalleList.Add(_objTicketDetalleList);
                }
                else
                {
                    if (findResult.i_RecordStatus == (int)RecordStatus.EliminadoLogico)
                    {
                        if (findResult.i_RecordType == (int)RecordType.NoTemporal)
                        {
                            _objTicketDetalleList.v_IdProductoDetalle  = txtMedicamento.Tag.ToString();
                            _objTicketDetalleList.v_NombreProducto     = txtMedicamento.Text;
                            _objTicketDetalleList.v_CodInterno         = txtCodigo.Text;
                            _objTicketDetalleList.v_IdUnidadProductiva = txtUnidadProductiva.Text;
                            var precioTarifa = oTicketBL.ObtenerPrecioTarifario(_serviceId, _objTicketDetalleList.v_IdProductoDetalle);
                            _objTicketDetalleList.d_PrecioVenta = precioTarifa;    // decimal.Parse(txtPrecioVenta.Text);
                            decimal d;
                            _objTicketDetalleList.d_Cantidad = decimal.TryParse(txtCantidad.Text, out d) ? d : 0;

                            var tienePlan  = false;
                            var resultplan = oTicketBL.TienePlan(_protocolId, txtUnidadProductiva.Text);
                            if (resultplan.Count > 0)
                            {
                                tienePlan = true;
                            }
                            else
                            {
                                tienePlan = false;
                            }

                            if (tienePlan)
                            {
                                if (resultplan[0].i_EsCoaseguro == 1)
                                {
                                    _objTicketDetalleList.d_SaldoPaciente    = resultplan[0].d_Importe;
                                    _objTicketDetalleList.d_SaldoAseguradora = (decimal.Parse(_objTicketDetalleList.d_PrecioVenta.ToString()) * _objTicketDetalleList.d_Cantidad) - resultplan[0].d_Importe;
                                }
                                if (resultplan[0].i_EsDeducible == 1)
                                {
                                    _objTicketDetalleList.d_SaldoPaciente    = resultplan[0].d_Importe * decimal.Parse(_objTicketDetalleList.d_PrecioVenta.ToString()) * _objTicketDetalleList.d_Cantidad / 100;
                                    _objTicketDetalleList.d_SaldoAseguradora = (decimal.Parse(_objTicketDetalleList.d_PrecioVenta.ToString()) * _objTicketDetalleList.d_Cantidad) - _objTicketDetalleList.d_SaldoPaciente;
                                }
                            }

                            findResult.i_RecordStatus = (int)RecordStatus.Grabado;
                        }
                        else if (findResult.i_RecordType == (int)RecordType.Temporal)       // El registro tiene un ID temporal [GUID]
                        {
                            _objTicketDetalleList.v_IdProductoDetalle  = txtMedicamento.Tag.ToString();
                            _objTicketDetalleList.v_NombreProducto     = txtMedicamento.Text;
                            _objTicketDetalleList.v_CodInterno         = txtCodigo.Text;
                            _objTicketDetalleList.d_PrecioVenta        = decimal.Parse(txtPrecioVenta.Text);
                            _objTicketDetalleList.v_IdUnidadProductiva = txtUnidadProductiva.Text;
                            decimal d;
                            _objTicketDetalleList.d_Cantidad = decimal.TryParse(txtCantidad.Text, out d) ? d : 0;

                            var tienePlan  = false;
                            var resultplan = oTicketBL.TienePlan(_protocolId, txtUnidadProductiva.Text);
                            if (resultplan.Count > 0)
                            {
                                tienePlan = true;
                            }
                            else
                            {
                                tienePlan = false;
                            }

                            if (tienePlan)
                            {
                                if (resultplan[0].i_EsCoaseguro == 1)
                                {
                                    _objTicketDetalleList.d_SaldoPaciente    = resultplan[0].d_Importe;
                                    _objTicketDetalleList.d_SaldoAseguradora = (decimal.Parse(_objTicketDetalleList.d_PrecioVenta.ToString()) * _objTicketDetalleList.d_Cantidad) - resultplan[0].d_Importe;
                                }
                                if (resultplan[0].i_EsDeducible == 1)
                                {
                                    _objTicketDetalleList.d_SaldoPaciente    = resultplan[0].d_Importe * decimal.Parse(_objTicketDetalleList.d_PrecioVenta.ToString()) * _objTicketDetalleList.d_Cantidad / 100;
                                    _objTicketDetalleList.d_SaldoAseguradora = (decimal.Parse(_objTicketDetalleList.d_PrecioVenta.ToString()) * _objTicketDetalleList.d_Cantidad) - _objTicketDetalleList.d_SaldoPaciente;
                                }
                            }

                            _objTicketDetalleList.i_RecordType = (int)RecordType.Temporal;

                            findResult.i_RecordStatus = (int)RecordStatus.Agregado;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Por favor seleccione otro medicamento. ya existe", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
            }
            else if (_mode == "Edit")
            {
                var     result = _TempTicketDetalleList.Find(p => p.v_TicketDetalleId == _id);
                decimal d;
                result.d_Cantidad = decimal.Round((decimal.TryParse(txtCantidad.Text, out d) ? d : 0), 2);
                if ((result.d_SaldoAseguradora != null || result.d_SaldoAseguradora >= 0) || result.d_SaldoPaciente != null || result.d_SaldoPaciente >= 0)
                {
                    result.d_SaldoAseguradora =
                        decimal.Round((decimal.TryParse(txtCantidad.Text, out d) ? d : 0), 2) * decimal.Round((decimal)result.d_PrecioVenta, 2);
                    result.d_SaldoPaciente = 0;
                }
                result.v_CodInterno   = txtCodigo.Text;
                result.i_RecordStatus = (int)RecordStatus.Modificado;
            }
            MessageBox.Show("Se grabo correctamente.", "INFORMACION!", MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.Close();
        }
예제 #21
0
        public void TicketTest()
        {
            TicketBL ticketTest = new TicketBL();

            Assert.NotNull(ticketTest.GetListTicketByMatchID(1));
        }
예제 #22
0
        public ActionResult SendTicket(string error, string description, List <HttpPostedFileBase> fileData)
        {
            TicketBL ticketBl           = new TicketBL();
            bool     isSendSuccessfully = false;
            Ticket   ticket             = new Ticket();

            if (Request.Files.Count > 0)
            {
                try
                {
                    string relativePath = "~/TicketFiles";
                    string path         = Server.MapPath(relativePath);
                    //string fileFath = Path.Combine(path, categoryName);
                    StringBuilder mailBody    = new StringBuilder();
                    string        senderEmail = string.Empty;
                    string        fileFath    = path;
                    if (!Directory.Exists(fileFath))
                    {
                        Directory.CreateDirectory(fileFath);
                    }
                    //  Get all files from Request object
                    HttpFileCollectionBase files = Request.Files;
                    for (int i = 0; i < files.Count; i++)
                    {
                        HttpPostedFileBase file = files[i];
                        string             fname;

                        // Checking for Internet Explorer
                        if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                        {
                            string[] testfiles = file.FileName.Split(new char[] { '\\' });
                            fname = testfiles[testfiles.Length - 1];
                        }
                        else
                        {
                            fname = file.FileName;
                        }

                        // Get the complete folder path and store the file inside it.
                        //string fnameWithPath = Path.Combine(fileFath, fname);
                        fname = DateTime.Now.ToString("yyyyMMddhhmm") + "_" + fname;
                        string fnameWithPath = fileFath + "/" + fname;
                        file.SaveAs(fnameWithPath);

                        ticket.Error       = error;
                        ticket.Description = description;
                        ticket.FilePath    = relativePath + "/" + fname;
                        ticket.ShipId      = Convert.ToInt32(Session["ShipId"].ToString());
                    }

                    string ticketNumber = ticketBl.SaveTicket(ticket, Convert.ToInt32(Session["UserType"].ToString()));
                    if (ticketNumber != null)
                    {
                        if (Session["UserType"].ToString() == "1")
                        {
                            senderEmail = ConfigurationManager.AppSettings["shipEmail"];
                        }
                        else
                        {
                            senderEmail = Session["Email"].ToString();
                        }
                        MailMessage mail = new MailMessage();

                        mailBody.Append("Ticket Number : ");
                        mailBody.Append(ticketNumber.ToString());
                        mailBody.Append("\n");
                        mailBody.Append("Error Message : ");
                        mailBody.Append(error);
                        mailBody.Append("\n");
                        mailBody.Append("Error Description : ");
                        mailBody.Append(description);
                        mailBody.Append("\n");

                        mail.Body = mailBody.ToString();
                        if (ticket.FilePath != null || ticket.FilePath != "")
                        {
                            mail.Attachments.Add(new Attachment(Server.MapPath(ticket.FilePath)));
                        }



                        if (!String.IsNullOrEmpty(senderEmail))
                        {
                            //SendEmail.SendMail("Ticket", senderEmail, "*****@*****.**", ticketNumber.ToString(), error, description, Server.MapPath(ticket.FilePath));

                            SendEmail.SendMail("Ticket", senderEmail, mail, ref isSendSuccessfully);
                        }
                        //SendEmail.SendMail("Ticket", "*****@*****.**", "*****@*****.**", ticketNumber.ToString(), error, description, Server.MapPath(ticket.FilePath));
                        //SendEmail.SendMail("Ticket", "*****@*****.**", Session["Email"].ToString(), ticketNumber.ToString(), error, description, Server.MapPath(ticket.FilePath));
                    }
                    // Returns message that successfully uploaded
                    return(Json(ticketNumber, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json("Error occurred. Error details: " + ex.Message));
                }
            }
            else
            {
                return(Json("No files selected."));
            }
        }
        public Ticket InputTicketInfo(Customer customer)
        {
            string        choice;
            string        path           = Path.GetFullPath("DataCart" + customer.Username + ".txt");
            TicketBL      tkbl           = new TicketBL();
            List <Ticket> listShowTicket = new List <Ticket>();
            Ticket        t           = new Ticket();
            bool          checkchoice = false;
            bool          check1      = false;
            bool          check2      = false;
            bool          check3      = false;

            while (check1 == false)
            {
                Console.Write("Nhap ma tran:");
                t.M.MatchID    = Input(Console.ReadLine());
                listShowTicket = GetListTicketByMatchID(t.M.MatchID, customer);
                if (listShowTicket.Count == 0)
                {
                    Console.WriteLine("Ma tran khong dung!Moi Ban nhap lai:");
                    check1 = false;
                    continue;
                }
                int sumAmount = GetAmountBoughtByMatchID(t.M.MatchID, customer, path);
                if (sumAmount == 10)
                {
                    Console.WriteLine("Ban da mua du 10 ve cho tran nay,Ban co muon mua ve tran khac khong?(C/K):");
                    choice      = Console.ReadLine().ToUpper();
                    checkchoice = m.Choose(choice);
                    if (checkchoice == true)
                    {
                        check1 = false;
                    }
                    else
                    {
                        check1 = true;
                        m.MenuTicket(customer);
                    }
                }
                if (sumAmount < 10)
                {
                    check1 = true;
                }
            }
            while (check2 == false)
            {
                Console.Write("Nhap loai ve:");
                t.TicketType = Console.ReadLine().ToUpper();
                if (validateString(t.TicketType) != true)
                {
                    Console.WriteLine("Loai ve la ki tu chu cai A-Z!Moi ban nhap lai");
                    continue;
                }
                try
                {
                    foreach (var item in listShowTicket)
                    {
                        if (t.TicketType == item.TicketType)
                        {
                            t.TicketID    = item.TicketID;
                            t.TicketPrice = item.TicketPrice;
                            check2        = true;
                        }
                    }
                }
                catch (System.Exception)
                {
                }
                if (check2 == false)
                {
                    Console.WriteLine("Loai ve khong dung!Moi ban nhap lai:");
                    continue;
                }
            }
            while (check3 == false)
            {
                int amountCount = 0;
                amountCount = GetAmountBoughtByMatchID(t.M.MatchID, customer, path);
                Console.Write("Nhap so luong ve muon mua:");
                t.Amount = Input(Console.ReadLine());
                if ((t.Amount + amountCount) > 10)
                {
                    Console.WriteLine("Moi nguoi chi duoc mua toi da 10 ve cho 1 tran!Ban co muon nhap lai khong?(C/K)");
                    choice      = Console.ReadLine().ToUpper();
                    checkchoice = m.Choose(choice);
                    if (checkchoice == true)
                    {
                        check1 = false;
                        continue;
                    }
                    else
                    {
                        check3 = true;
                        m.MenuTicket(customer);
                    }
                }
                try
                {
                    foreach (var item in listShowTicket)
                    {
                        if (t.TicketType == item.TicketType && item.Amount == 0)
                        {
                            check3 = true;
                            Console.WriteLine("Tran nay da ban het ve!An phim bat ky de tro ve menu!");
                            Console.ReadKey();
                            m.MenuTicket(customer);
                        }
                        if (t.TicketType == item.TicketType && t.Amount <= item.Amount)
                        {
                            check3 = true;
                        }
                    }
                }
                catch (System.Exception)
                {
                }
                if (check3 == false)
                {
                    Console.WriteLine("so luong ve con lai nho hon so ve muon mua!Ban co muon nhap lai khong?(C/K)");
                    choice      = Console.ReadLine().ToUpper();
                    checkchoice = m.Choose(choice);
                    if (checkchoice == true)
                    {
                        continue;
                    }
                    else
                    {
                        check3 = true;
                        m.MenuTicket(customer);
                    }
                }
            }
            return(t);
        }
예제 #24
0
 public TicketsController(TicketBL repo)
 {
     _tRepo = repo;
 }
예제 #25
0
 public TicketService()
 {
     ticketBL = new TicketBL();
 }
예제 #26
0
        public ActionResult Index(string gTot, string nTransac)
        {
            try
            {
                TrPaymentMenuViewModel vm = new TrPaymentMenuViewModel();
                if (string.IsNullOrEmpty(nTransac))
                {
                    ////provisoire
                    //vm.GlobalTotal = "399.97";
                    //vm.NumTransaction = "11";
                    //ViewBag.tot = "399.97";
                    //ViewBag.transac = "11";
                    //ViewBag.ticket = false;
                    throw new NullReferenceException();
                }
                else
                {
                    if (string.IsNullOrEmpty(gTot))
                    {
                        gTot = TransactionBL.FindTotalByTransacId(nTransac);
                    }
                    var listAmounts = PaymentBL.MakeAmountsList(nTransac);
                    if (listAmounts.Count == 0)
                    {
                        vm.GlobalTotal = gTot;
                        ViewBag.tot    = gTot;
                        ViewBag.ticket = false;
                    }
                    else
                    {
                        vm.AmountsPaid = listAmounts;
                        decimal result = PaymentBL.AdaptTotalWithPaid(gTot, listAmounts);
                        if (result < 0)
                        {
                            decimal temp = Math.Abs(result);
                            vm.CashReturn    = temp.ToString();
                            ViewBag.cashBack = temp.ToString();
                            vm.GlobalTotal   = "0";
                            ViewBag.tot      = "0";
                            vm.Ticket        = TicketBL.FillTicket(nTransac);
                            ViewBag.ticket   = true;
                        }
                        else if (result == 0)
                        {
                            ViewBag.cashBack = "0";
                            vm.GlobalTotal   = "0";
                            ViewBag.tot      = "0";
                            vm.Ticket        = TicketBL.FillTicket(nTransac);
                            ViewBag.ticket   = true;
                        }
                        else
                        {
                            vm.GlobalTotal = result.ToString();
                            ViewBag.tot    = result.ToString();
                            ViewBag.ticket = false;
                        }
                    }
                    vm.NumTransaction = nTransac;
                    ViewBag.transac   = nTransac;
                }
                vm.MethodsP         = PaymentBL.FindMethodsList();
                ViewBag.messageCard = "";
                return(View(vm));
            }
            catch (NullReferenceException ex)
            {
                //to do insert to log file
                var e1 = ex.GetBaseException(); // --> log
                var e4 = ex.Message;            // --> log
                var e5 = ex.Source;             // --> log
                var e8 = ex.GetType();          // --> log
                var e9 = ex.GetType().Name;     // --> log

                ViewBag.Error = "Il n'y a pas de transaction en cours !";
                return(View("Error"));
            }
            catch (Exception ex)
            {
                //to do insert to log file
                var e1 = ex.GetBaseException(); // --> log
                var e4 = ex.Message;            // --> log
                var e5 = ex.Source;             // --> log
                var e8 = ex.GetType();          // --> log
                var e9 = ex.GetType().Name;     // --> log

                return(View("Error"));
            }
        }
예제 #27
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (cboMedico.SelectedValue.ToString() == "-1")
            {
                MessageBox.Show("Seleccionar un médico tratante", " ¡ VALIDACIÓN!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (_auxiliaryExams == null)
            {
                _auxiliaryExams = new List <ServiceComponentList>();
            }

            // Save ListView / recorrer la lista de examenes seleccionados
            foreach (ListViewItem item in lvExamenesSeleccionados.Items)
            {
                var fields           = item.SubItems;
                var ComponentId      = fields[1].Text.Split('|');
                var NombreComponente = fields[0].Text.Split('|');



                MedicalExamBL objComponentBL  = new MedicalExamBL();
                componentDto  objComponentDto = new componentDto();

                OperationResult objOperationResult = new OperationResult();
                foreach (var scid in ComponentId)
                {
                    var conCargoA = -1;
                    if (_type == "Hospi")
                    {
                        var oFrmType = new frmType();
                        oFrmType.ShowDialog();

                        if (oFrmType._conCargoA == "Médico")
                        {
                            conCargoA = 1;
                        }
                        else
                        {
                            conCargoA = 2;
                        }
                    }

                    objComponentDto = objComponentBL.GetMedicalExam(ref objOperationResult, scid);
                    SystemParameterBL oSp = new SystemParameterBL();
                    var o = oSp.GetSystemParameter(ref objOperationResult, 116, int.Parse(objComponentDto.i_CategoryId.ToString()));
                    //Lógica de Aumento de Precio Base

                    var porcentajes = o.v_Field.Split('-');

                    float p1 = porcentajes[0] == null ? 0 : float.Parse(porcentajes[0].ToString());

                    float p2 = porcentajes[1] == null ? 0 : float.Parse(porcentajes[1].ToString());

                    float pb          = objComponentDto.r_BasePrice.Value;
                    var   precio_base = pb + (pb * p1 / 100) + (pb * p2 / 100);
                    //FormPrecioComponente frm = new FormPrecioComponente("", "", "");
                    //frmConfigSeguros frm1 = new frmConfigSeguros(0, 0, 0, "", "");
                    ServiceComponentList auxiliaryExam          = new ServiceComponentList();
                    servicecomponentDto  objServiceComponentDto = new servicecomponentDto();
                    ServiceBL            _ObjServiceBL          = new ServiceBL();
                    TicketBL             oTicketBL = new TicketBL();
                    if (_modo == "ASEGU")
                    {
                        #region OLD Logica antigua
                        #region Conexion SAM
                        //ConexionSigesoft conectasam = new ConexionSigesoft();
                        //conectasam.opensigesoft();
                        #endregion
                        #region Query
                        //var componente = NombreComponente[0].ToString();
                        //var cadena1 = "select PL.i_EsDeducible, PL.i_EsCoaseguro, PL.d_Importe, PL.d_ImporteCo from [dbo].[plan] PL where PL.v_IdUnidadProductiva='" + lineId + "' and PL.v_ProtocoloId='" + _protocolId + "' ";
                        //SqlCommand comando = new SqlCommand(cadena1, connection: conectasam.conectarsigesoft);
                        //SqlDataReader lector = comando.ExecuteReader();
                        //int deducible = 0;
                        //int coaseguro = 0;
                        //decimal? importe = 0;
                        //decimal? importeCo = 0;
                        //while (lector.Read())
                        //{
                        //    deducible = int.Parse(lector.GetValue(0).ToString()); coaseguro = int.Parse(lector.GetValue(1).ToString()); importe = decimal.Parse(lector.GetValue(2).ToString()); importeCo = decimal.Parse(lector.GetValue(3).ToString());
                        //}
                        //lector.Close();
                        //string factores = ""; string aseguradoraName = ""; string organizationId = "";
                        //var factorGlobal = "";
                        //var cadena2 = "select PR.r_PriceFactor, OO.v_Name, PR.v_CustomerOrganizationId from Organization OO inner join protocol PR On PR.v_AseguradoraOrganizationId = OO.v_OrganizationId where PR.v_ProtocolId ='" + _protocolId + "'";
                        //comando = new SqlCommand(cadena2, connection: conectasam.conectarsigesoft);
                        //lector = comando.ExecuteReader();
                        //while (lector.Read())
                        //{
                        //    factores = lector.GetValue(0).ToString();
                        //    var factorArray = factores.Split('|');// factores[0].ToString().Split('|');
                        //    factorGlobal = factorArray[0];
                        //    aseguradoraName = lector.GetValue(1).ToString();
                        //    organizationId = lector.GetValue(2).ToString();
                        //}
                        //lector.Close();
                        //string empresa = "";
                        //var cadena3 = "select v_Name from Organization OO  where OO.v_OrganizationId ='" + organizationId + "'";
                        //comando = new SqlCommand(cadena3, connection: conectasam.conectarsigesoft);
                        //lector = comando.ExecuteReader();
                        //while (lector.Read())
                        //{
                        //    empresa = lector.GetValue(0).ToString();
                        //}
                        //lector.Close();
                        #endregion
                        #region Lógica PARA SABER SI ES DEDUCIBLE O COASEGURO
                        //if (rbNuevaConsulta.Checked)// QUIERE DECIR QUE ES UNA NUEVA ATENCION Y DEBE SER CONSIDERADO COMO DEDUCIBLE SIN FACTOR
                        //{
                        //    factorGlobal = "1";
                        //    coaseguro = 0;
                        //    importeCo = null;
                        //}
                        //else if (rbAdicional.Checked) // QUIERE DECIR QUE ES UN COMPONENTE ADICIONAL Y DEBE SER CONSIDERADO COMO COASEGURO CON FACTOR
                        //{
                        //    deducible = 0;
                        //    importe = null;
                        //}
                        #endregion
                        #region Formulario
                        //precio_base = (float)objComponentDto.r_PriceSegus;// se cambia el precio inicial por el SEGUS
                        //frmConfigSeguros frm1 = new frmConfigSeguros(deducible, coaseguro, importe, precio_base.ToString(), factorGlobal, importeCo);
                        //frm1.Text = aseguradoraName + " / " + empresa;
                        //frm1.ShowDialog();
                        #endregion
                        #endregion

                        #region Obteniendo los campos de la BD
                        ConexionSigesoft conectasam = new ConexionSigesoft();
                        conectasam.opensigesoft();
                        var           componente      = NombreComponente[0].ToString();
                        var           cadena          = "select i_KindOfService from  component where v_ComponentId='" + objComponentDto.v_ComponentId + "'";
                        SqlCommand    comando         = new SqlCommand(cadena, connection: conectasam.conectarsigesoft);
                        SqlDataReader lector          = comando.ExecuteReader();
                        int           i_KindOfService = 0;
                        while (lector.Read())
                        {
                            try
                            {
                                i_KindOfService = int.Parse(lector.GetValue(0).ToString());
                            }
                            catch (Exception exception)
                            {
                                MessageBox.Show(exception.Message, " ¡ ERROR !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        lector.Close();
                        var cadena1 = "select PL.i_PlanId, PL.i_EsCoaseguro, PL.d_Importe, PL.d_ImporteCo " +
                                      "from [dbo].[plan] PL " +
                                      "where PL.v_IdUnidadProductiva='" + lineId + "' and PL.v_ProtocoloId='" + _protocolId + "' ";
                        comando = new SqlCommand(cadena1, connection: conectasam.conectarsigesoft);
                        lector  = comando.ExecuteReader();
                        string PlanId = ""; int coaseguro = 0; decimal?importe = 0; decimal?importeCo = 0;
                        while (lector.Read())
                        {
                            try
                            {
                                PlanId    = lector.GetValue(0).ToString();
                                coaseguro = int.Parse(lector.GetValue(1).ToString());
                                importe   = decimal.Parse(lector.GetValue(2).ToString());
                                importeCo = decimal.Parse(lector.GetValue(3).ToString());
                            }
                            catch (Exception exception)
                            {
                                MessageBox.Show(exception.Message, " ¡ ERROR !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        lector.Close();
                        string factores = ""; string aseguradoraName = ""; string organizationId = ""; var factorGlobal = "";
                        var    cadena2 = "select PR.r_PriceFactor, OO.v_Name, PR.v_CustomerOrganizationId " +
                                         "from Organization OO " +
                                         "inner join protocol PR On PR.v_AseguradoraOrganizationId = OO.v_OrganizationId " +
                                         "where PR.v_ProtocolId ='" + _protocolId + "'";
                        comando = new SqlCommand(cadena2, connection: conectasam.conectarsigesoft);
                        lector  = comando.ExecuteReader();
                        while (lector.Read())
                        {
                            try
                            {
                                factores = lector.GetValue(0).ToString();
                                var factorArray = factores.Split('|');// factores[0].ToString().Split('|');
                                factorGlobal    = factorArray[0];
                                aseguradoraName = lector.GetValue(1).ToString();
                                organizationId  = lector.GetValue(2).ToString();
                            }
                            catch (Exception exception)
                            {
                                MessageBox.Show(exception.Message, " ¡ ERROR !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        lector.Close();
                        #endregion

                        #region Según el tipo de componente se hace el calculo
                        switch (i_KindOfService)
                        {
                        //CLINICA
                        case 1:
                        {
                            if (objComponentDto.r_PriceSegus != 0)
                            {
                                objServiceComponentDto.r_Price            = objComponentDto.r_PriceSegus;
                                objServiceComponentDto.d_SaldoPaciente    = importe;
                                objServiceComponentDto.d_SaldoAseguradora = (decimal)objComponentDto.r_PriceSegus - importe;
                            }
                            else
                            {
                                frmConfigSeguros frm1 = new frmConfigSeguros("1");
                                frm1.ShowDialog();
                                objServiceComponentDto.r_Price            = (float)frm1.nuevoPrecio;
                                objServiceComponentDto.d_SaldoPaciente    = importe;
                                objServiceComponentDto.d_SaldoAseguradora = frm1.nuevoPrecio - importe;
                            }
                        }
                        break;

                        //SERVICIOS AUXILIARES
                        case 2:
                        {
                            if (objComponentDto.r_PriceSegus != 0)
                            {
                                objServiceComponentDto.r_Price            = objComponentDto.r_PriceSegus * float.Parse(factorGlobal);
                                objServiceComponentDto.d_SaldoPaciente    = importeCo * (decimal)objServiceComponentDto.r_Price / 100;
                                objServiceComponentDto.d_SaldoAseguradora = (100 - importeCo) * (decimal)objServiceComponentDto.r_Price / 100;
                            }
                            else
                            {
                                frmConfigSeguros frm1 = new frmConfigSeguros(factorGlobal);
                                frm1.ShowDialog();
                                objServiceComponentDto.r_Price            = (float)frm1.nuevoPrecio;
                                objServiceComponentDto.d_SaldoPaciente    = importeCo * frm1.nuevoPrecio / 100;
                                objServiceComponentDto.d_SaldoAseguradora = (100 - importeCo) * frm1.nuevoPrecio / 100;
                            }
                        }
                        break;

                        //HONORARIOS MÉDICOS Y/O QUIRURGICOS
                        case 3:
                        {
                            if (objComponentDto.r_PriceSegus != 0)
                            {
                                objServiceComponentDto.r_Price            = objComponentDto.r_PriceSegus * float.Parse(factorGlobal);
                                objServiceComponentDto.d_SaldoPaciente    = importeCo * (decimal)objServiceComponentDto.r_Price / 100;
                                objServiceComponentDto.d_SaldoAseguradora = (100 - importeCo) * (decimal)objServiceComponentDto.r_Price / 100;
                            }
                            else
                            {
                                frmConfigSeguros frm1 = new frmConfigSeguros(factorGlobal);
                                frm1.ShowDialog();
                                objServiceComponentDto.r_Price            = (float)frm1.nuevoPrecio;
                                objServiceComponentDto.d_SaldoPaciente    = importeCo * frm1.nuevoPrecio / 100;
                                objServiceComponentDto.d_SaldoAseguradora = (100 - importeCo) * frm1.nuevoPrecio / 100;
                            }
                        }
                        break;
                        }
                        #endregion



                        objServiceComponentDto.v_ServiceId              = _serviceId;
                        objServiceComponentDto.i_ExternalInternalId     = (int)Common.ComponenteProcedencia.Interno;
                        objServiceComponentDto.i_ServiceComponentTypeId = 1;
                        objServiceComponentDto.i_IsVisibleId            = 1;
                        objServiceComponentDto.i_IsInheritedId          = (int)Common.SiNo.NO;
                        objServiceComponentDto.d_StartDate              = null;
                        objServiceComponentDto.d_EndDate                  = null;
                        objServiceComponentDto.i_index                    = 1;
                        objServiceComponentDto.v_ComponentId              = scid;
                        objServiceComponentDto.i_IsInvoicedId             = (int)Common.SiNo.NO;
                        objServiceComponentDto.i_ServiceComponentStatusId = (int)Common.ServiceStatus.PorIniciar;
                        objServiceComponentDto.i_QueueStatusId            = (int)Common.QueueStatusId.LIBRE;
                        objServiceComponentDto.i_Iscalling                = (int)Common.Flag_Call.NoseLlamo;
                        objServiceComponentDto.i_Iscalling_1              = (int)Common.Flag_Call.NoseLlamo;
                        objServiceComponentDto.i_IsManuallyAddedId        = (int)Common.SiNo.NO;
                        objServiceComponentDto.i_IsRequiredId             = (int)Common.SiNo.SI;
                        objServiceComponentDto.v_IdUnidadProductiva       = txtUnidProdId.Text;
                        objServiceComponentDto.i_MedicoTratanteId         = int.Parse(cboMedico.SelectedValue.ToString());
                        if (rbNuevaConsulta.Checked)
                        {
                            objServiceComponentDto.i_TipoDesc = 1;
                        }
                        else if (rbAdicional.Checked)
                        {
                            objServiceComponentDto.i_TipoDesc = 2;
                        }

                        _ObjServiceBL.AddServiceComponent(ref objOperationResult, objServiceComponentDto, Globals.ClientSession.GetAsList());
                        #region Update a service agrega el PlanId
                        cadena1 = "update service set " +
                                  "i_PlanId = '" + PlanId + "' " +
                                  "where v_ServiceId = '" + _serviceId + "' ";
                        comando = new SqlCommand(cadena1, connection: conectasam.conectarsigesoft);
                        lector  = comando.ExecuteReader();
                        lector.Close();
                        #endregion
                    }
                    else
                    {
                        FormPrecioComponente frm = new FormPrecioComponente(NombreComponente[0].ToString(), precio_base.ToString(), "");
                        frm.ShowDialog();
                        objServiceComponentDto.i_ConCargoA              = conCargoA;
                        objServiceComponentDto.v_ServiceId              = _serviceId;
                        objServiceComponentDto.i_ExternalInternalId     = (int)Common.ComponenteProcedencia.Interno;
                        objServiceComponentDto.i_ServiceComponentTypeId = 1;
                        objServiceComponentDto.i_IsVisibleId            = 1;
                        objServiceComponentDto.i_IsInheritedId          = (int)Common.SiNo.NO;
                        objServiceComponentDto.d_StartDate              = null;
                        objServiceComponentDto.d_EndDate                  = null;
                        objServiceComponentDto.i_index                    = 1;
                        objServiceComponentDto.r_Price                    = frm.Precio;
                        objServiceComponentDto.v_ComponentId              = scid;
                        objServiceComponentDto.i_IsInvoicedId             = (int)Common.SiNo.NO;
                        objServiceComponentDto.i_ServiceComponentStatusId = (int)Common.ServiceStatus.PorIniciar;
                        objServiceComponentDto.i_QueueStatusId            = (int)Common.QueueStatusId.LIBRE;
                        //objServiceComponentDto.i_IsRequiredId = (int)Common.SiNo.SI;
                        objServiceComponentDto.i_Iscalling          = (int)Common.Flag_Call.NoseLlamo;
                        objServiceComponentDto.i_Iscalling_1        = (int)Common.Flag_Call.NoseLlamo;
                        objServiceComponentDto.i_IsManuallyAddedId  = (int)Common.SiNo.NO;
                        objServiceComponentDto.i_IsRequiredId       = (int)Common.SiNo.SI;
                        objServiceComponentDto.v_IdUnidadProductiva = objComponentDto.v_IdUnidadProductiva;
                        objServiceComponentDto.i_MedicoTratanteId   = int.Parse(cboMedico.SelectedValue.ToString());
                        objServiceComponentDto.d_SaldoPaciente      = 0;
                        objServiceComponentDto.d_SaldoAseguradora   = 0;
                        _ObjServiceBL.AddServiceComponent(ref objOperationResult, objServiceComponentDto, Globals.ClientSession.GetAsList());
                    }
                }

                //Actualizo si son examenes adicionales
                if (_DataSource.Count > 0)
                {
                    new AdditionalExamBL().UpdateAdditionalExamByComponentIdAndServiceId(ComponentId[0], _serviceId,
                                                                                         Globals.ClientSession.i_SystemUserId);
                }
            }

            MessageBox.Show("Se grabo correctamente", " ¡ INFORMACIÓN !", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.DialogResult = DialogResult.OK;
        }
예제 #28
0
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        //[Authorize(Roles = "vendor")]
        public ActionResult Index(string gTot, string nTransac)
        {
            try
            {
                TrPaymentMenuViewModel vm = new TrPaymentMenuViewModel();
                if (string.IsNullOrEmpty(nTransac))
                {
                    throw new NullReferenceException();
                }
                else
                {
                    if (Session["Language"] == null)
                    {
                        Session["Language"] = ConfigurationManager.AppSettings["Language"];
                    }
                    string language = Session["Language"].ToString();

                    if (string.IsNullOrEmpty(gTot))
                    {
                        gTot = TransactionBL.FindTotalByTransacId(nTransac);
                    }
                    var listAmounts = PaymentBL.MakeAmountsList(nTransac);
                    if (listAmounts.Count == 0)
                    {
                        vm.GlobalTotal = gTot;
                        ViewBag.tot    = gTot;
                        ViewBag.ticket = false;
                    }
                    else
                    {
                        vm.AmountsPaid = listAmounts;
                        decimal result = PaymentBL.AdaptTotalWithPaid(gTot, listAmounts);
                        if (result < 0)
                        {
                            decimal temp = Math.Abs(result);
                            vm.CashReturn    = temp.ToString();
                            ViewBag.cashBack = temp.ToString();
                            vm.GlobalTotal   = "0";
                            ViewBag.tot      = "0";
                            //to do --> change init isChange...
                            bool isChange = false;
                            vm.Ticket      = TicketBL.FillTicket(nTransac, language, isChange);
                            ViewBag.ticket = true;
                        }
                        else if (result == 0)
                        {
                            ViewBag.cashBack = "0";
                            vm.GlobalTotal   = "0";
                            ViewBag.tot      = "0";
                            //to do --> change init isChange...
                            bool isChange = false;
                            vm.Ticket      = TicketBL.FillTicket(nTransac, language, isChange);
                            ViewBag.ticket = true;
                        }
                        else
                        {
                            vm.GlobalTotal = result.ToString();
                            ViewBag.tot    = result.ToString();
                            ViewBag.ticket = false;
                        }
                    }
                    vm.NumTransaction = nTransac;
                    ViewBag.transac   = nTransac;
                }
                vm.MethodsP         = PaymentBL.FindMethodsList();
                vm.Languages        = LanguageBL.FindLanguageListWithoutUniversal();
                ViewBag.messageCard = "";
                return(View(vm));
            }
            catch (NullReferenceException ex)
            {
                //to do insert to log file
                var e1 = ex.GetBaseException(); // --> log
                var e4 = ex.Message;            // --> log
                var e5 = ex.Source;             // --> log
                var e8 = ex.GetType();          // --> log
                var e9 = ex.GetType().Name;     // --> log

                ViewBag.Error = "Il n'y a pas de transaction en cours !";
                return(View("Error"));
            }
            catch (Exception ex)
            {
                //to do insert to log file
                var e1 = ex.GetBaseException(); // --> log
                var e4 = ex.Message;            // --> log
                var e5 = ex.Source;             // --> log
                var e8 = ex.GetType();          // --> log
                var e9 = ex.GetType().Name;     // --> log

                return(View("Error"));
            }
        }