protected bool CreateChange()
 {
     if (!DataOk())
     {
         return(false);
     }
     if (sn == null)
     {
         firstTime = true;
         sn        = new ServiceNote();
         UnloadData(sn);
         ctx.Add(sn);
     }
     else
     {
         sn = CntAriCli.GetServiceNote(serviceNoteId, ctx);
         UnloadData(sn);
     }
     ctx.SaveChanges();
     // control that this note have lines
     if (firstTime && sn.Tickets.Count() == 0)
     {
         firstTime = false;
         string command = String.Format("ariDialog('{0}','{1}','warning',null,0,0);"
                                        , Resources.GeneralResource.Warning
                                        , Resources.GeneralResource.ServiceNoteLinesNedeed);
         RadAjaxManager1.ResponseScripts.Add(command);
         Session["LinkId"] = sn.ServiceNoteId;
         return(false);
     }
     return(true);
 }
 protected void LoadClinicCombo(ServiceNote sn)
 {
     // clear previous items
     rdcbClinic.Items.Clear();
     foreach (Clinic c in ctx.Clinics)
     {
         rdcbClinic.Items.Add(new RadComboBoxItem(c.Name, c.ClinicId.ToString()));
     }
     if (sn != null && sn.Clinic != null)
     {
         rdcbClinic.SelectedValue = sn.Clinic.ClinicId.ToString();
     }
     else
     {
         if (cl != null)
         {
             rdcbClinic.SelectedValue = cl.ClinicId.ToString();
         }
         else
         {
             rdcbClinic.Items.Add(new RadComboBoxItem(" ", ""));
             rdcbClinic.SelectedValue = "";
         }
     }
 }
Beispiel #3
0
 protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
 {
     RadGrid1.Rebind();
     if (e.Argument == "new")
     {
         RadGrid1.CurrentPageIndex = RadGrid1.PageCount - 1;
         RadGrid1.Rebind();
     }
     if (e.Argument == "yes")
     {
         if (Session["DeleteId"] != null)
         {
             try
             {
                 serviceNoteId = (int)Session["DeleteId"];
                 ServiceNote sn = CntAriCli.GetServiceNote(serviceNoteId, ctx);
                 CntAriCli.DeleteServiceNote(sn, ctx);
                 RadGrid1.Rebind();
                 Session["DeleteId"] = null;
             }
             catch (Exception ex)
             {
                 Session["Exception"] = ex;
                 string command = String.Format("showDialog('Error','{0}','error',null, 0, 0)"
                                                , Resources.GeneralResource.DeleteRecordFail);
                 RadAjaxManager1.ResponseScripts.Add(command);
             }
         }
     }
 }
Beispiel #4
0
        public RptServNote(int idservnote, AriClinicContext ctx1)
            : this()
        {
            ctx1        = new AriClinicContext("AriClinicContext");
            companyname = CntAriCli.GetHealthCompany(ctx1).Name;
            ServiceNote servNote = CntAriCli.GetServiceNote(idservnote, ctx1);

            this.DataSource = servNote;
            //this.subReport1.ReportSource.DataSource = servNote.Tickets;
            this.subReport1.Report.DataSource = servNote.Tickets;
        }
    protected void Page_Init(object sender, EventArgs e)
    {
        ctx = new AriClinicContext("AriClinicContext");
        // security control, it must be a user logged
        if (Session["User"] == null)
        {
            Response.Redirect("Default.aspx");
        }
        else
        {
            user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
            Process proc = (from p in ctx.Processes
                            where p.Code == "payment"
                            select p).FirstOrDefault <Process>();
            per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
            btnAccept.Visible = per.Modify;
        }
        if (Session["Clinic"] != null)
        {
            cl = (Clinic)Session["Clinic"];
        }
        //

        //
        if (Request.QueryString["ServiceNoteId"] != null)
        {
            serviceNoteId = int.Parse(Request.QueryString["ServiceNoteId"]);
            snote         = CntAriCli.GetServiceNote(serviceNoteId, ctx);
            // calcute total amount and total payments
            //txtServiceNoteData.Text = String.Format("ID:{0} Fecha:{1:dd/MM/yy} Total:{2} Pagado:{3}",
            //    snote.ServiceNoteId,
            //    snote.ServiceNoteDate,
            //    CntAriCli.GetServiceNoteAmount(snote),
            //    CntAriCli.GetServiceNoteAmountPay(snote));
            txtServiceNoteData.Text = String.Format("{0} ({1:dd/MM/yy}) T:{2:0.00} P:{3:0.00}", snote.Customer.ComercialName, snote.ServiceNoteDate, snote.Total, snote.Paid);
            txtAmount.Value         = (double)CntAriCli.GetUnpaid(snote, ctx);
            //txtAmount.Text = string.Format("{0:#.#}", CntAriCli.GetUnpaid(snote, ctx));
            SetFocus(rdcbClinic);
        }

        if (Request.QueryString["GeneralPaymentId"] != null)
        {
            paymentId = Int32.Parse(Request.QueryString["GeneralPaymentId"]);
            gpay      = CntAriCli.GetGeneralPayment(paymentId, ctx);
            LoadData(gpay);
        }
        else
        {
            rddpGeneralPaymentDate.SelectedDate = DateTime.Now;
            LoadPaymentMethodCombo(null);
            LoadClinicCombo(null);
        }
    }
    protected void UnloadData(GeneralPayment pay)
    {
        if (pay != null)
        {
            serviceNote = pay.ServiceNote;
            CntAriCli.GeneralPaymentDelete(pay, ctx);
        }
        Clinic        clinic      = CntAriCli.GetClinic(int.Parse(rdcbClinic.SelectedValue), ctx);
        PaymentMethod payMethod   = CntAriCli.GetPaymentMethod(int.Parse(rdcbPaymentMethod.SelectedValue), ctx);
        DateTime      payDate     = (DateTime)rddpGeneralPaymentDate.SelectedDate;
        Decimal       amount      = (decimal)txtAmount.Value;
        string        description = txtComments.Text;

        pay = CntAriCli.GeneralPaymentNew(clinic, serviceNote, amount, payMethod, payDate, description, ctx);
    }
 protected void Page_Init(object sender, EventArgs e)
 {
     ctx = new AriClinicContext("AriClinicContext");
     if (Session["User"] == null)
     {
         Response.Redirect("Default.aspx");
     }
     else
     {
         user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
         Process proc = (from p in ctx.Processes
                         where p.Code == "payment"
                         select p).FirstOrDefault <Process>();
         permission        = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
         btnAccept.Visible = permission.Modify;
     }
     if (Session["Clinic"] != null)
     {
         clinic = (Clinic)Session["Clinic"];
     }
     if (Request.QueryString["ServiceNoteId"] != null)
     {
         serviceNoteId           = int.Parse(Request.QueryString["ServiceNoteId"]);
         serviceNote             = CntAriCli.GetServiceNote(serviceNoteId, ctx);
         txtServiceNoteData.Text = String.Format("{0} ({1:dd/MM/yy}) T:{2:0.00} P:{3:0.00}", serviceNote.Customer.ComercialName, serviceNote.ServiceNoteDate, serviceNote.Total, serviceNote.Paid);
         txtAmount.Value         = (double)CntAriCli.GetUnpaid(serviceNote, ctx);
         if (serviceNote.Clinic != null)
         {
             clinic = serviceNote.Clinic;
         }
         SetFocus(rdcbClinic);
     }
     if (Request.QueryString["GeneralPaymentId"] != null)
     {
         generalPaymentId = Int32.Parse(Request.QueryString["GeneralPaymentId"]);
         generalPayment   = CntAriCli.GetGeneralPayment(generalPaymentId, ctx);
         serviceNote      = generalPayment.ServiceNote;
         LoadData(generalPayment);
     }
     else
     {
         rddpGeneralPaymentDate.SelectedDate = DateTime.Now;
         LoadPaymentMethodCombo(null);
         LoadClinicCombo(clinic);
     }
 }
Beispiel #8
0
        public static void LoadTicketsAndServiceNotes(RdcModel ctxRid, AriClinicContext ctx)
        {
            int numr = ctxRid.Acto_medico_asgs.Count(); int r = 0;

            DateTime fechaAnt      = new DateTime(1, 1, 1);
            int      idHistoriaAnt = 0;

            ServiceNote sn = null;

            foreach (Acto_medico_asg asg in (from ams in ctxRid.Acto_medico_asgs
                                             orderby ams.Fecha, ams.Id_historia
                                             select ams))
            {
                Console.WriteLine("Tickest & Service notes -> {1:000000}/{2:000000} {0:dd/MM/yyyy} ", asg.Fecha, ++r, numr);
                Patient patient = (from p in ctx.Patients
                                   where p.OftId == asg.Id_historia
                                   select p).FirstOrDefault <Patient>();
                if (asg.Fecha != fechaAnt || asg.Id_historia != idHistoriaAnt)
                {
                    // al cambiar la fecha o el paciente creamos una nueva nota de servicio
                    sn                 = new ServiceNote();
                    sn.Customer        = patient.Customer;
                    sn.ServiceNoteDate = asg.Fecha;
                    ctx.Add(sn);
                    ctx.SaveChanges();
                    fechaAnt      = asg.Fecha;
                    idHistoriaAnt = (int)asg.Id_historia;
                }
                // montamos el ticket de hoy
                Ticket tck = new Ticket();
                tck.ServiceNote = sn;
                InsuranceService isrv = (from ins in ctx.InsuranceServices
                                         where ins.OftId == asg.Id_acto_medico_asc
                                         select ins).FirstOrDefault <InsuranceService>();
                tck.InsuranceService = isrv;
                tck.TicketDate       = asg.Fecha;
                tck.Policy           = patient.Customer.Policies.FirstOrDefault <Policy>();
                tck.Amount           = 1;
                tck.Comments         = asg.Observaciones;
                tck.Description      = isrv.Service.Name;
                tck.Checked          = asg.Comunicado;
                ctx.Add(tck);
                ctx.SaveChanges();
            }
        }
 protected void UnloadData(ServiceNote sn)
 {
     sn.ServiceNoteDate = (DateTime)rddpServiceNoteDate.SelectedDate;
     clinicId           = Int32.Parse(rdcbClinic.SelectedValue);
     sn.Clinic          = CntAriCli.GetClinic(clinicId, ctx);
     sn.User            = CntAriCli.GetUser(user.UserId, ctx);
     //
     sn.Total = sn.Tickets.Sum(t => t.Amount);
     sn.Paid  = sn.GeneralPayments.Sum(gp => gp.Amount);
     //
     customerId  = Int32.Parse(rdcComercialName.SelectedValue);
     sn.Customer = CntAriCli.GetCustomer(customerId, ctx);
     if (rdcProfessionalName.SelectedValue != "")
     {
         professionalId  = Int32.Parse(rdcProfessionalName.SelectedValue);
         sn.Professional = CntAriCli.GetProfessional(professionalId, ctx);
     }
     else
     {
         sn.Professional = null;
     }
 }
    protected void LoadData(ServiceNote sn)
    {
        txtServiceNoteId.Text = sn.ServiceNoteId.ToString();
        //txtCustomerId.Text = sn.Customer.PersonId.ToString();

        rdcComercialName.Items.Clear();
        rdcComercialName.Items.Add(new RadComboBoxItem(sn.Customer.FullName, sn.Customer.PersonId.ToString()));
        rdcComercialName.SelectedValue = sn.Customer.PersonId.ToString();
        //txtComercialName.Text = sn.Customer.FullName;
        rddpServiceNoteDate.SelectedDate = sn.ServiceNoteDate;
        LoadClinicCombo(sn);
        txtTotal.Text = String.Format("{0:0.00}", sn.Total);
        txtPaid.Text  = String.Format("{0:0.00}", sn.Paid);
        if (sn.Professional != null)
        {
            //txtProfessionalId.Text = sn.Professional.PersonId.ToString();
            rdcProfessionalName.Items.Clear();
            rdcProfessionalName.Items.Add(new RadComboBoxItem(sn.Professional.FullName, sn.Professional.PersonId.ToString()));
            rdcProfessionalName.SelectedValue = sn.Professional.PersonId.ToString();
            //txtProfessionalName.Text = sn.Professional.FullName;
        }
    }
Beispiel #11
0
 protected void Page_Init(object sender, EventArgs e)
 {
     ctx = new AriClinicContext("AriClinicContext");
     // security control, it must be a user logged
     if (Session["User"] == null)
     {
         Response.Redirect("Default.aspx");
     }
     else
     {
         user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
         Process proc = (from p in ctx.Processes
                         where p.Code == "policy"
                         select p).FirstOrDefault <Process>();
         per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
     }
     // cheks if is call from another form
     if (Request.QueryString["Type"] != null)
     {
         type = Request.QueryString["Type"];
     }
     // read the realated patient
     if (Request.QueryString["PatientId"] != null)
     {
         patientId = Int32.Parse(Request.QueryString["PatientId"]);
         pat       = CntAriCli.GetPatient(patientId, ctx);
         cus       = pat.Customer;
     }
     // read passed customer if any
     if (Request.QueryString["CustomerId"] != null)
     {
         customerId = Int32.Parse(Request.QueryString["CustomerId"]);
         cus        = CntAriCli.GetCustomer(customerId, ctx);
     }
     //
     if (Request.QueryString["NotPaid"] != null)
     {
         notPaid = true;
     }
     //
     if (type == "InTab")
     {
         HtmlControl tt = (HtmlControl)this.FindControl("TitleArea");
         tt.Attributes["class"] = "ghost";
         // hide patient column
         RadGrid1.Columns.FindByDataField("Policy.Customer.FullName").Visible = false;
         //
         RadGrid1.PageSize = 6;
     }
     else
     {
     }
     if (Request.QueryString["AnestheticServiceNoteId"] != null)
     {
         anestheticServiceNoteId = Int32.Parse(Request.QueryString["AnestheticServiceNoteId"]);
         asn = CntAriCli.GetAnestheticServiceNote(anestheticServiceNoteId, ctx);
         HtmlControl tt = (HtmlControl)this.FindControl("TitleArea");
         tt.Attributes["class"] = "ghost";
         // here the fields that must be hidden
         RadGrid1.Columns.FindByDataField("TicketDate").Visible = false;
         RadGrid1.Columns.FindByDataField("Policy.Customer.FullName").Visible = false;
         RadGrid1.Columns.FindByDataField("Checked").Visible     = false;
         RadGrid1.Columns.FindByDataField("Clinic.Name").Visible = false;
     }
     if (Request.QueryString["ServiceNoteId"] != null)
     {
         serviceNoteId = int.Parse(Request.QueryString["ServiceNoteId"]);
         sn            = CntAriCli.GetServiceNote(serviceNoteId, ctx);
         HtmlControl tt = (HtmlControl)this.FindControl("TitleArea");
         tt.Attributes["class"] = "ghost";
         // here the fields that must be hidden
         RadGrid1.Columns.FindByDataField("TicketDate").Visible = false;
         RadGrid1.Columns.FindByDataField("Policy.Customer.FullName").Visible = false;
         RadGrid1.Columns.FindByDataField("Checked").Visible     = false;
         RadGrid1.Columns.FindByDataField("Clinic.Name").Visible = false;
         RadGrid1.Columns.FindByDataField("Paid").Visible        = false;
     }
     // translate filters
     CntWeb.TranslateRadGridFilters(RadGrid1);
     //
 }
Beispiel #12
0
 protected void Page_Init(object sender, EventArgs e)
 {
     ctx = new AriClinicContext("AriClinicContext");
     // security control, it must be a user logged
     if (Session["User"] == null)
     {
         Response.Redirect("Default.aspx");
     }
     else
     {
         user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
         Process proc = (from p in ctx.Processes
                         where p.Code == "ticket"
                         select p).FirstOrDefault <Process>();
         per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
         btnAccept.Visible = per.Modify;
         if (user.Professionals.Count > 0)
         {
             prof = user.Professionals[0];
             txtProfessionalId.Text   = prof.PersonId.ToString();
             txtProfessionalName.Text = prof.FullName;
         }
     }
     //
     if (Request.QueryString["CustomerId"] != null)
     {
         customerId            = Int32.Parse(Request.QueryString["CustomerId"]);
         cus                   = CntAriCli.GetCustomer(customerId, ctx);
         txtCustomerId.Text    = cus.PersonId.ToString();
         txtComercialName.Text = cus.FullName;
         // if a patient has been passed we can not touch it
         txtCustomerId.Enabled    = false;
         txtComercialName.Enabled = false;
         btnCustomerId.Visible    = false;
         LoadPolicyCombo(null);
     }
     else
     {
         LoadPolicyCombo(null);
         LoadClinicCombo(null);
     }
     if (Session["Clinic"] != null)
     {
         cl = (Clinic)Session["Clinic"];
     }
     //
     if (Request.QueryString["ServiceNoteId"] != null)
     {
         serviceNoteId = int.Parse(Request.QueryString["ServiceNoteId"]);
         sn            = CntAriCli.GetServiceNote(serviceNoteId, ctx);
         // disable select fields
         cus = sn.Customer;
         txtCustomerId.Text    = cus.PersonId.ToString(); txtCustomerId.Enabled = false;
         txtComercialName.Text = cus.FullName; txtComercialName.Enabled = false;
         cl   = sn.Clinic;
         prof = sn.Professional;
         if (prof != null)
         {
             txtProfessionalId.Text   = prof.PersonId.ToString(); txtProfessionalId.Enabled = false;
             txtProfessionalName.Text = prof.FullName; txtProfessionalName.Enabled = false;
         }
         rddpTicketDate.SelectedDate = sn.ServiceNoteDate;
     }
     //
     if (Request.QueryString["TicketId"] != null)
     {
         ticketId   = Int32.Parse(Request.QueryString["TicketId"]);
         tck        = CntAriCli.GetTicket(ticketId, ctx);
         cus        = tck.Policy.Customer;
         customerId = cus.PersonId;
         if (tck.ServiceNote != null)
         {
             sn            = tck.ServiceNote;
             serviceNoteId = sn.ServiceNoteId;
         }
         LoadData(tck);
     }
     else
     {
         // If there isn't a ticket the default date must be today
         rddpTicketDate.SelectedDate = DateTime.Now;
         if (sn != null)
         {
             rddpTicketDate.SelectedDate = sn.ServiceNoteDate;
         }
         LoadPolicyCombo(null);
         LoadClinicCombo(null);
     }
 }
    protected void Page_Init(object sender, EventArgs e)
    {
        ctx = new AriClinicContext("AriClinicContext");
        // security control, it must be a user logged
        if (Session["User"] == null)
        {
            Response.Redirect("Default.aspx");
        }
        else
        {
            user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
            Process proc = (from p in ctx.Processes
                            where p.Code == "ticket"
                            select p).FirstOrDefault <Process>();
            per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
            btnAccept.Visible = per.Modify;
        }
        //
        if (Request.QueryString["PatientId"] != null)
        {
            patientId = Int32.Parse(Request.QueryString["PatientId"]);
            pat       = CntAriCli.GetPatient(patientId, ctx);
            cus       = pat.Customer;
        }
        if (Request.QueryString["CustomerId"] != null || cus != null)
        {
            if (cus == null)
            {
                customerId = Int32.Parse(Request.QueryString["CustomerId"]);
                cus        = CntAriCli.GetCustomer(customerId, ctx);
            }
            //txtCustomerId.Text = cus.PersonId.ToString();

            rdcComercialName.Items.Clear();
            rdcComercialName.Items.Add(new RadComboBoxItem(cus.FullName, cus.PersonId.ToString()));
            rdcComercialName.SelectedValue = cus.PersonId.ToString();
            //txtComercialName.Text = cus.FullName;
            // if a patient has been passed we can not touch it
            //txtCustomerId.Enabled = false;
            btnCustomerId.Visible = false;
        }
        else
        {
            LoadClinicCombo(null);
        }
        if (Session["Clinic"] != null)
        {
            cl = (Clinic)Session["Clinic"];
        }
        //
        if (Request.QueryString["ServiceNoteId"] != null)
        {
            serviceNoteId = Int32.Parse(Request.QueryString["ServiceNoteId"]);
            sn            = CntAriCli.GetServiceNote(serviceNoteId, ctx);
            cus           = sn.Customer;
            customerId    = cus.PersonId;
            LoadData(sn);
            // Load internal frame
            HtmlControl frm = (HtmlControl)this.FindControl("ifTickets");
            frm.Attributes["src"] = String.Format("TicketGrid.aspx?ServiceNoteId={0}", serviceNoteId);
            frm = (HtmlControl)this.FindControl("ifGeneralPayments");
            frm.Attributes["src"] = String.Format("GeneralPaymentGrid.aspx?ServiceNoteId={0}", serviceNoteId);
        }
        else
        {
            // If there isn't a ticket the default date must be today
            rddpServiceNoteDate.SelectedDate = DateTime.Now;
            LoadClinicCombo(null);
            firstTime          = true;
            btnInvoice.Visible = false;
        }
    }