public static decimal GetUnpaid(ServiceNote sn, AriClinicContext ctx) { decimal amount = sn.Tickets.Sum(t => t.Amount); decimal paid = sn.Tickets.Sum(t => t.Paid); return(amount - paid); }
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 (type == "InTab") { HtmlControl tt = (HtmlControl)this.FindControl("TitleArea"); tt.Attributes["class"] = "ghost"; // hide patient column RadGrid1.Columns.FindByDataField("Ticket.Policy.Customer.FullName").Visible = false; } if (Request.QueryString["ServiceNoteId"] != null) { serviceNoteId = int.Parse(Request.QueryString["ServiceNoteId"]); serviceNote = CntAriCli.GetServiceNote(serviceNoteId, ctx); HtmlControl tt = (HtmlControl)this.FindControl("TitleArea"); tt.Attributes["class"] = "ghost"; RadGrid1.Columns.FindByDataField("ServiceNote.Customer.FullName").Visible = false; // Ticket.Description RadGrid1.Columns.FindByDataField("Ticket.Description").Visible = false; // Ticket.Amount RadGrid1.Columns.FindByDataField("Ticket.Amount").Visible = false; //Ticket.Paid RadGrid1.Columns.FindByDataField("Ticket.Paid").Visible = false; // to fit in iframe space RadGrid1.PageSize = 3; RadGrid1.AllowFilteringByColumn = false; } // translate filters CntWeb.TranslateRadGridFilters(RadGrid1); }
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); } }
public static GeneralPayment GeneralPaymentNew(Clinic clinic, ServiceNote sn, decimal amount, PaymentMethod payMethod, DateTime payDate, string description, AriClinicContext ctx) { var rs = from t in sn.Tickets where t.Amount > t.Paid select t; GeneralPayment gp = new GeneralPayment(); gp.ServiceNote = sn; gp.PaymentDate = payDate; gp.Description = description; gp.PaymentMethod = payMethod; gp.Amount = amount; gp.Clinic = clinic; ctx.Add(gp); foreach (Ticket t in rs.OrderByDescending(tk => tk.Amount - tk.Paid)) { Payment pay = new Payment(); pay.PaymentMethod = payMethod; pay.PaymentDate = payDate; pay.Ticket = t; pay.GeneralPayment = gp; pay.Description = description; pay.Clinic = clinic; decimal dif = t.Amount - t.Paid; if (dif <= amount) { pay.Amount = dif; amount = amount - dif; t.Paid = t.Paid + dif; } else { pay.Amount = amount; t.Paid = t.Paid + amount; amount = 0; } ctx.Add(pay); if (amount == 0) { break; } } ctx.SaveChanges(); return(gp); }
public static GeneralPayment GeneralPaymentNew(Clinic clinic, ServiceNote sn, decimal amount, PaymentMethod payMethod, DateTime payDate, string description, AriClinicContext ctx) { var rs = from t in sn.Tickets where t.Amount > t.Paid select t; GeneralPayment gp = new GeneralPayment(); gp.ServiceNote = sn; gp.PaymentDate = payDate; gp.Description = description; gp.PaymentMethod = payMethod; gp.Amount = amount; gp.Clinic = clinic; ctx.Add(gp); foreach (Ticket t in rs.OrderByDescending(tk => tk.Amount - tk.Paid)) { Payment pay = new Payment(); pay.PaymentMethod = payMethod; pay.PaymentDate = payDate; pay.Ticket = t; pay.GeneralPayment = gp; pay.Description = description; pay.Clinic = clinic; decimal dif = t.Amount - t.Paid; if (dif <= amount) { pay.Amount = dif; amount = amount - dif; t.Paid = t.Paid + dif; } else { pay.Amount = amount; t.Paid = t.Paid + amount; amount = 0; } ctx.Add(pay); if (amount == 0) break; } ctx.SaveChanges(); return gp; }
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); } }
public static decimal GetUnpaid(ServiceNote sn, AriClinicContext ctx) { decimal amount = sn.Tickets.Sum(t => t.Amount); decimal paid = sn.Tickets.Sum(t => t.Paid); return (amount - paid); }
public static void ImportServiceNote(OleDbConnection con, AriClinicContext ctx) { //(0) Borrar las notas de servicio y tickets previos //ctx.Delete(ctx.Payments); //ctx.Delete(ctx.GeneralPayments); //ctx.Delete(ctx.Tickets); //ctx.Delete(ctx.ServiceNotes); //ctx.SaveChanges(); // Nos hace falta una clĂnica, la creamos ahora Clinic cl = (from c in ctx.Clinics where c.Name == "Clinica Valencia" select c).FirstOrDefault<Clinic>(); if (cl == null) { cl = new Clinic(); cl.Name = "Clinica Valencia"; ctx.Add(cl); ctx.SaveChanges(); } //(1) Leer las notas de servicio OFT string sql = "SELECT * FROM NotaServicio"; cmd = new OleDbCommand(sql, con); da = new OleDbDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds, "ConNotaServicio"); int nreg = ds.Tables["ConNotaServicio"].Rows.Count; int reg = 0; foreach (DataRow dr in ds.Tables["ConNotaServicio"].Rows) { reg++; Console.WriteLine("Notas de servicio {0:#####0} de {1:#####0} A:{2} N:{3}", reg, nreg,(int)dr["Ano"], (int)dr["NumNota"]); ServiceNote sn = (from s in ctx.ServiceNotes where s.Oft_Ano == (int)dr["Ano"] && s.Oft_NumNota == (int)dr["NumNota"] select s).FirstOrDefault<ServiceNote>(); if (sn == null) { sn = new ServiceNote(); ctx.Add(sn); } int id = (int)dr["NumHis"]; sn.Customer = (from cus in ctx.Customers where cus.OftId == id select cus).FirstOrDefault<Customer>(); sn.ServiceNoteDate = (DateTime)dr["Fecha"]; decimal total = (decimal)dr["Total"]; sn.Total = total; sn.Clinic = cl; Professional prf = (from p in ctx.Professionals where p.OftId == 0 select p).FirstOrDefault<Professional>(); sn.Professional = prf; sn.Oft_Ano = (int)dr["Ano"]; sn.Oft_NumNota = (int)dr["NumNota"]; ctx.SaveChanges(); } //(2) Importar la lĂneas de las notas de servicio sql = "SELECT * FROM LinNotaServicio"; cmd = new OleDbCommand(sql, con); da = new OleDbDataAdapter(cmd); ds = new DataSet(); da.Fill(ds, "ConLineasServicio"); nreg = ds.Tables["ConLineasServicio"].Rows.Count; reg = 0; foreach (DataRow dr in ds.Tables["ConLineasServicio"].Rows) { reg++; Console.WriteLine("Lineas de servicio {0:#####0} de {1:#####0} A:{2} N:{3}", reg, nreg, (int)dr["Ano"], (int)dr["NumNota"]); int idSer = (int)dr["IdServMed"]; int idAno = (int)dr["Ano"]; int idNumNota = (int)dr["NumNota"]; int idProfessional = (int)dr["IdMed"]; InsuranceService insuranceService = (from ins in ctx.InsuranceServices where ins.Service.OftId == idSer select ins).FirstOrDefault<InsuranceService>(); ServiceNote serviceNote = (from sn in ctx.ServiceNotes where sn.Oft_Ano == idAno && sn.Oft_NumNota == idNumNota select sn).FirstOrDefault<ServiceNote>(); Decimal amount = (decimal)dr["Importe"]; Professional professional = (from p in ctx.Professionals where p.OftId == idProfessional select p).FirstOrDefault<Professional>(); Ticket tk = (from t in ctx.Tickets where t.ServiceNote.ServiceNoteId == serviceNote.ServiceNoteId && t.InsuranceService.InsuranceServiceId == insuranceService.InsuranceServiceId && t.Professional.PersonId == professional.PersonId && t.Amount == amount select t).FirstOrDefault<Ticket>(); if (tk == null) { tk = new Ticket(); ctx.Add(tk); } tk.InsuranceService = insuranceService; tk.ServiceNote = serviceNote; tk.Amount = amount; tk.Professional = professional; tk.ServiceNote.Professional = tk.Professional; if (tk.ServiceNote.Professional == null) tk.ServiceNote.Professional = tk.Professional; tk.Description = (string)dr["Descripcion"]; tk.Clinic = cl; tk.TicketDate = tk.ServiceNote.ServiceNoteDate; // hay notas sin cliente, no deberia pero las hay if (tk.ServiceNote.Customer != null) tk.Policy = tk.ServiceNote.Customer.Policies.FirstOrDefault<Policy>(); ctx.SaveChanges(); } }
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; } }
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 = ""; } } }
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; } }
public static int InvoiceServiceNote(ServiceNote sn, AriClinicContext ctx) { // it there's an invoice related to this service // we do nothing and return 0 if (sn.Invoice != null) return 0; // invoice Invoice i = new Invoice(); Decimal total = 0; i.Customer = sn.Customer; sn.Invoice = i; // this make the relationship i.InvoiceDate = sn.ServiceNoteDate; i.Serial = CntAriCli.GetHealthCompany(ctx).InvoiceSerial; i.Year = i.InvoiceDate.Year; i.InvoiceNumber = CntAriCli.GetNextInvoiceNumber(i.Serial, i.Year, ctx); ctx.Add(i); // invoice lines foreach (Ticket t in sn.Tickets) { InvoiceLine il = new InvoiceLine(); il.Invoice = i; il.Ticket = t; il.Description = t.Description; il.Amount = t.Amount; il.TaxType = t.InsuranceService.Service.TaxType; il.TaxPercentage = il.TaxType.Percentage; total += il.Amount; ctx.Add(il); } i.Total = total; // save the work and return id ctx.SaveChanges(); return i.InvoiceId; }
protected void UnloadData(GeneralPayment pay) { if (pay != null) { snote = 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, snote, amount, payMethod, payDate, description, ctx); }
public static bool ContainsTicketsInvoiced(ServiceNote sn, AriClinicContext ctx) { foreach (Ticket t in sn.Tickets) { if (t.InvoiceLines.Count > 0) return true; } return false; }
public static decimal GetServiceNoteAmountPay(ServiceNote snote) { decimal a = 0; foreach (Ticket t in snote.Tickets) { foreach (Payment p in t.Payments) { a += p.Amount; } } return a; }
public static decimal GetServiceNoteAmount(ServiceNote snote) { decimal a = 0; foreach (Ticket t in snote.Tickets) { a += t.Amount; } return a; }
public static void CreatePayment(Ticket t, PaymentMethod pm, Decimal amount, DateTime dt, string des, ServiceNote note, Clinic cl, GeneralPayment gp, AriClinicContext ctx) { // Now we need verify if there's a payment yet with the same values Payment p = new Payment(); p.Amount = amount; p.Clinic = cl; p.PaymentDate = dt; p.PaymentMethod = pm; p.GeneralPayment = gp; p.Description = des; p.Ticket = t; t.Paid = t.Paid + amount; ctx.Add(p); }
public static bool PayNote(PaymentMethod pm, Decimal amount, DateTime dt, string des, ServiceNote note, Clinic cl, GeneralPayment gp, AriClinicContext ctx) { Payment p = null; // payment to be created Ticket t = null; // related ticket //(0) Control if amount > pending in note decimal total_paid = 0; foreach (Ticket tk in note.Tickets) total_paid += tk.Paid; if ((note.Total - total_paid) < amount) return false; // amount bigger than debt. //(1) Look for a ticket (inside note) with the same amount t = (from tk in note.Tickets where (tk.Amount - tk.Paid) == amount select tk).FirstOrDefault<Ticket>(); if (t != null) { // (1.1) It exists. CreatePayment(t, pm, amount, dt, des, note, cl, gp, ctx); } else { // (1.2) It doesn't exist var rs = from tk in note.Tickets orderby (tk.Amount - tk.Paid) select tk; foreach (Ticket tk in rs) { if (tk.Amount - tk.Paid >= amount) { CreatePayment(tk, pm, amount, dt, des, note, cl, gp, ctx); break; // out } else { decimal paid = tk.Amount - tk.Paid; amount = amount - paid; CreatePayment(tk, pm, paid, dt, des, note, cl, gp, ctx); } } } ctx.SaveChanges(); return true; }
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 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 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; } }
public static void DeleteServiceNote(ServiceNote sn, AriClinicContext ctx) { // First delete related records. foreach (GeneralPayment gp in sn.GeneralPayments) { GeneralPaymentDelete(gp, ctx); } ctx.Delete(sn.Tickets); ctx.Delete(sn); ctx.SaveChanges(); }