本文整理汇总了C#中AriCliModel.AriClinicContext.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# AriClinicContext.SaveChanges方法的具体用法?C# AriClinicContext.SaveChanges怎么用?C# AriClinicContext.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AriCliModel.AriClinicContext
的用法示例。
在下文中一共展示了AriClinicContext.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BigDelete
public static void BigDelete(AriClinicContext ctx)
{
ctx.Delete(ctx.InvoiceLines);
ctx.Delete(ctx.Invoices);
ctx.SaveChanges();
ctx.Delete(ctx.AppointmentInfos);
ctx.Delete(ctx.AppointmentTypes);
ctx.Delete(ctx.Diaries);
ctx.SaveChanges();
ctx.Delete(ctx.Payments);
ctx.Delete(ctx.Tickets);
ctx.Delete(ctx.ServiceNotes);
ctx.Delete(ctx.Policies);
ctx.Delete(ctx.Insurances);
ctx.Delete(ctx.InsuranceServices);
ctx.SaveChanges();
ctx.Delete(ctx.Services);
ctx.Delete(ctx.ServiceCategories);
ctx.Delete(ctx.TaxTypes);
ctx.Delete(ctx.Addresses); // eliminar direcciones.
ctx.Delete(ctx.Emails); // eliminar correos electrónicos
ctx.Delete(ctx.Telephones); // eliminar teléfonos.
ctx.Delete(ctx.Policies); // eliminar las pólizas.
ctx.Delete(ctx.PaymentMethods);
ctx.SaveChanges();
}
示例2: DeleteVisit
public static void DeleteVisit(AriClinicContext ctx)
{
ctx.Delete(ctx.OphthalmologicVisits);
ctx.Delete(ctx.BaseVisits);
ctx.Delete(ctx.VisitReasons);
ctx.SaveChanges();
}
示例3: GeneralPaymentDelete
public static void GeneralPaymentDelete(GeneralPayment gp, AriClinicContext ctx)
{
foreach (Payment p in gp.Payments)
{
PaymentDelete(p, ctx);
}
ctx.Delete(gp);
ctx.SaveChanges();
}
示例4: PaymentDelete
public static void PaymentDelete(Payment pay, AriClinicContext ctx)
{
// minus paid in ticket
if (pay.Ticket != null)
{
pay.Ticket.Paid = pay.Ticket.Paid - pay.Amount;
}
ctx.Delete(pay);
ctx.SaveChanges();
}
示例5: ApplyMultiTicket
public static void ApplyMultiTicket(AnestheticServiceNote asn, AriClinicContext ctx)
{
bool first = true;
if (asn.AnestheticTickets.Count > 1)
{
foreach (AnestheticTicket atck in asn.AnestheticTickets.OrderByDescending(x => x.Amount))
{
if (!first)
{
atck.Amount = atck.Amount / 2;
atck.Comments = "-50%";
ctx.SaveChanges();
}
first = false;
}
}
}
示例6: GeneralPaymentNew
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;
}
示例7: CreateAssociateTickets
public static void CreateAssociateTickets(AnestheticServiceNote asn, AriClinicContext ctx)
{
// Does this customer have a primary policy with that service?
Policy pol = PrimaryPolicy(asn.Customer);
if (pol == null)
{
throw new AriCliException(1, "There isn't a primary policy for this customer");
}
// Delete all tickets
ctx.Delete(asn.AnestheticTickets);
foreach (Procedure proc in asn.Procedures)
{
// Does this policy includes related (from procedure) services
InsuranceService ins = PolicyIncludesService(pol, proc.Service);
if (ins == null)
{
throw new AriCliException(3, "The insurance company have not the nomenclator service assigned");
}
// Everything seems ok, we can add anesthetic ticket
AnestheticTicket atck = new AnestheticTicket()
{
TicketDate = asn.ServiceNoteDate,
Description = String.Format("{0} ({1})", proc.Name, ins.Service.Name),
Amount = ins.Price,
Policy = pol,
InsuranceService = ins,
User = asn.User,
Clinic = asn.Clinic,
Professional = asn.Professional,
Surgeon = asn.Surgeon,
Procedure = proc,
AnestheticServiceNote = asn
};
ctx.Add(atck);
ctx.SaveChanges();
}
}
示例8: ImportTaxTypes
/// <summary>
/// Importa los tipos de IVA
/// </summary>
/// <param name="con"></param>
/// <param name="ctx"></param>
public static void ImportTaxTypes(OleDbConnection con, AriClinicContext ctx)
{
// (0) Borra tipos previos
ctx.Delete(ctx.TaxTypes);
ctx.SaveChanges();
// (1) Dar de alta los tipos de IVA importados.
string sql = "SELECT * FROM TiposIva";
cmd = new OleDbCommand(sql, con);
da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "ConTiposIVA");
int nreg = ds.Tables["ConTiposIVA"].Rows.Count;
int reg = 0;
TaxType tt = null;
foreach (DataRow dr in ds.Tables["ConTiposIVA"].Rows)
{
DataRow localDr = dr;
reg++;
Console.WriteLine("Tipos IVA {0:#####0} de {1:#####0} {2}", reg, nreg, (string)localDr["NomTipoIva"]);
tt = (from ti in ctx.TaxTypes
where ti.OftId == (int)localDr["IdTipoIVA"]
select ti).FirstOrDefault<TaxType>();
if (tt == null)
{
tt = new TaxType();
ctx.Add(tt);
}
tt.Name = (string)localDr["NomTipoIva"];
Single p = (Single)localDr["Porcentaje"];
tt.Percentage = decimal.Parse(p.ToString());
tt.OftId = (int)localDr["IdTipoIva"];
}
ctx.SaveChanges();
}
示例9: ImportSources
public static void ImportSources(OleDbConnection con, AriClinicContext ctx)
{
// (0) Borra tipos previos
ctx.Delete(ctx.Sources);
ctx.SaveChanges();
// (1) Dar de alta las procedencias
string sql = "SELECT * FROM ProcMed";
cmd = new OleDbCommand(sql, con);
da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "ConProcMed");
int nreg = ds.Tables["ConProcMed"].Rows.Count;
int reg = 0;
foreach (DataRow dr in ds.Tables["ConProcMed"].Rows)
{
reg++;
Console.WriteLine("Procedencias {0:#####0} de {1:#####0} {2}", reg, nreg, (string)dr["NomProcMed"]);
Source src = CntAriCli.GetSourceByOftId((int)dr["IdProcMed"], ctx);
if (src == null)
{
src = new Source();
src.OftId = (int)dr["IdProcMed"];
ctx.Add(src);
}
src.Name = (string)dr["NomProcMed"];
ctx.SaveChanges();
}
}
示例10: ImportInvoices
public static void ImportInvoices(OleDbConnection con, AriClinicContext ctx)
{
//(0) Delete previous invoices
ctx.Delete(ctx.InvoiceLines);
ctx.Delete(ctx.Invoices);
ctx.SaveChanges();
//
//(1) Read OFT invoices and import to Ariclinic
string sql = "SELECT * FROM Factura";
cmd = new OleDbCommand(sql, con);
da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "ConFacturas");
int nreg = ds.Tables["ConFacturas"].Rows.Count;
int reg = 0;
foreach (DataRow dr in ds.Tables["ConFacturas"].Rows)
{
DataRow localDr = dr;
reg++;
Console.WriteLine("Facturas {0:#####0} de {1:#####0} {2}", reg, nreg, "FACTURAS 1");
Invoice inv = (from f in ctx.Invoices
where f.Serial == "F" &&
f.Year == (int)localDr["Ano"] &&
f.InvoiceNumber == (int)localDr["NumFactura"]
select f).FirstOrDefault<Invoice>();
if (inv == null)
{
inv = new Invoice();
ctx.Add(inv);
}
else
{
// if exits all lines will be recreated
ctx.Delete(inv.InvoiceLines);
}
inv.InvoiceDate = (DateTime)localDr["Fecha"];
inv.Year = (int)localDr["Ano"];
inv.InvoiceNumber = (int)localDr["NumFactura"];
inv.Serial = "F"; // we must to set serial parameter to "F"
int id = (int)localDr["NumHis"];
inv.Customer = (from c in ctx.Customers
where c.OftId == id
select c).FirstOrDefault<Customer>();
inv.Total = (decimal)localDr["Total"];
ctx.SaveChanges();
}
//(2) Importe invoice lines;
int idTipoIva = 0;
int idServMed = 0;
int Ano = 0;
int NumFac = 0;
sql = "SELECT * FROM LinFactura";
cmd = new OleDbCommand(sql, con);
da = new OleDbDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds, "ConLineasFactura");
nreg = ds.Tables["ConLineasFactura"].Rows.Count;
reg = 0;
foreach (DataRow dr in ds.Tables["ConLineasFactura"].Rows)
{
reg++;
Console.WriteLine("Facturas 2 {0:#####0} de {1:#####0} {2}", reg, nreg, "FACTURAS 2");
InvoiceLine il = new InvoiceLine();
idTipoIva = (int)dr["IdTipoIva"];
idServMed = (int)dr["IdServMed"];
Ano = (int)dr["Ano"];
NumFac = (int)dr["NumFactura"];
TaxType tx = (from t in ctx.TaxTypes
where t.OftId == idTipoIva
select t).FirstOrDefault<TaxType>();
Service sv = (from s in ctx.Services
where s.OftId == idServMed
select s).FirstOrDefault<Service>();
sv.TaxType = tx;
Invoice inv = (from iv in ctx.Invoices
where iv.Year == Ano && iv.InvoiceNumber == NumFac && iv.Serial == "F"
select iv).FirstOrDefault<Invoice>();
il.Invoice = inv;
il.TaxType = tx;
il.TaxPercentage = tx.Percentage;
il.Amount = (decimal)dr["Importe"];
il.Description = (string)dr["Descripcion"];
ctx.Add(il);
ctx.SaveChanges();
}
}
示例11: ImportCategories
/// <summary>
/// Traspasa los datos que corresponden a servicios y categorias de servicio
/// </summary>
/// <param name="con">Conector a OFT</param>
/// <param name="ctx">Contexto de AriClinc</param>
public static void ImportCategories(OleDbConnection con, AriClinicContext ctx)
{
int id = 0;
// (0) Borrar los datos previos.
ctx.Delete(ctx.Services);
ctx.Delete(ctx.ServiceCategories);
ctx.SaveChanges();
// (1) Dar de alta las categorias de servicio
string sql = "SELECT * FROM TipServMed";
cmd = new OleDbCommand(sql, con);
da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "ConServicios");
int nreg = ds.Tables["ConServicios"].Rows.Count;
int reg = 0;
ServiceCategory sc = null;
foreach (DataRow dr in ds.Tables["ConServicios"].Rows)
{
DataRow localDr = dr;
reg++;
Console.WriteLine("Categorias {0:#####0} de {1:#####0} {2}", reg, nreg, (string)localDr["NomTipServMed"]);
sc = (from scat in ctx.ServiceCategories
where scat.OftId == (int)localDr["IdTipServMed"]
select scat).FirstOrDefault<ServiceCategory>();
if (sc == null)
{
sc = new ServiceCategory();
ctx.Add(sc);
}
sc.Name = (string)localDr["NomTipServMed"];
sc.OftId = (int)localDr["IdTipservMed"];
ctx.SaveChanges();
}
// (2) Con las categorías dadas de alta damos de alta los
// servicios.
sql = "SELECT * FROM ServMed";
cmd = new OleDbCommand(sql, con);
da = new OleDbDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds, "ConServ2");
nreg = ds.Tables["ConServ2"].Rows.Count;
reg = 0;
Service s = null;
foreach (DataRow dr in ds.Tables["ConServ2"].Rows)
{
reg++;
s = (from sr in ctx.Services
where sr.OftId == (int)dr["IdServMed"]
select sr).FirstOrDefault<Service>();
if (s == null)
{
s = new Service();
ctx.Add(s);
}
s.Name = (string)dr["NomServMed"];
id = (int)dr["IdTipServMed"];
s.ServiceCategory = (from scat in ctx.ServiceCategories
where scat.OftId == id
select scat).FirstOrDefault<ServiceCategory>();
s.OftId = (int)dr["IdServMed"];
}
ctx.SaveChanges();
}
示例12: DeleteProcedures
public static void DeleteProcedures(AriClinicContext ctx)
{
ctx.Delete(ctx.ProcedureAssigneds);
ctx.Delete(ctx.Procedures);
ctx.SaveChanges();
}
示例13: ImportAppointmentInfo
public static void ImportAppointmentInfo(OleDbConnection con, AriClinicContext ctx)
{
//(1) Borramos las citas anteriores.
//ctx.Delete(ctx.AppointmentInfos);
//(2) Leer las agendas OFT y darlas de alta en AriClinic
string sql = "SELECT * FROM Citas";
cmd = new OleDbCommand(sql, con);
da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "ConCitas");
int nreg = ds.Tables["ConCitas"].Rows.Count;
int reg = 0;
int i2 = 0;
int i3 = 0;
int i4 = 0;
foreach (DataRow dr in ds.Tables["ConCitas"].Rows)
{
i3++;
reg++;
Console.WriteLine("Citas {0:#####0} de {1:#####0} {2}", reg, nreg, "CITAS");
int id = (int)dr["NumHis"];
Patient patient = (from p in ctx.Patients
where p.OftId == id
select p).FirstOrDefault<Patient>();
id = (int)dr["IdLibCit"];
Diary diary = (from d in ctx.Diaries
where d.OftId == id
select d).FirstOrDefault<Diary>();
DateTime dt = (DateTime)dr["Fecha"];
DateTime ht = (DateTime)dr["Hora"];
DateTime dd = new DateTime(dt.Year, dt.Month, dt.Day, ht.Hour, ht.Minute, ht.Second);
AppointmentInfo app = (from a in ctx.AppointmentInfos
where a.Diary.DiaryId == diary.DiaryId
&& a.Patient.PersonId == patient.PersonId
&& a.BeginDateTime == dd
select a).FirstOrDefault<AppointmentInfo>();
if (app == null)
{
app = new AppointmentInfo();
ctx.Add(app);
}
id = (int)dr["IdTipCit"];
app.AppointmentType = (from at in ctx.AppointmentTypes
where at.OftId == id
select at).FirstOrDefault<AppointmentType>();
app.Diary = diary;
app.Patient = patient;
id = (int)dr["IdMed"];
app.Professional = (from pr in ctx.Professionals
where pr.OftId == id
select pr).FirstOrDefault<Professional>();
i4++;
app.BeginDateTime = dd;
ht = (DateTime)dr["HrFin"];
dd = new DateTime(dt.Year, dt.Month, dt.Day, ht.Hour, ht.Minute, ht.Second);
app.EndDateTime = dd;
ht = (DateTime)dr["Durac"];
app.Duration = ht.Minute;
if (app.Patient != null)
{
i2++;
app.Subject = CntAriCli.GetAppointmentSubject(app);
}
else
{
app.Subject = "SIN PACIENTE";
}
ctx.SaveChanges();
}
}
示例14: CreateServicesToTest
private static void CreateServicesToTest()
{
using (AriClinicContext ctx = new AriClinicContext("AriClinicContext"))
{
for (int i = 0; i < 10000; i++)
{
Service ser = new Service();
ser.Name = String.Format("Servicio {0}", i);
int i2 = i % 2;
switch (i2)
{
case 0:
ser.TaxType = CntAriCli.GetTaxType(3, ctx);
break;
case 1:
ser.TaxType = CntAriCli.GetTaxType(4, ctx);
break;
}
int i3 = i % 3;
switch (i3)
{
case 0:
ser.ServiceCategory = CntAriCli.GetServiceCategory(1, ctx);
break;
case 1:
ser.ServiceCategory = CntAriCli.GetServiceCategory(2, ctx);
break;
}
ctx.Add(ser);
ctx.SaveChanges();
Console.WriteLine("Creando registro {0}", i);
}
}
}
示例15: CheckTickets
public static void CheckTickets(AnestheticServiceNote asn, bool[] lschk, AriClinicContext ctx)
{
int i = 0;
int lenght = lschk.Count();
foreach (AnestheticTicket actk in asn.AnestheticTickets)
{
if (asn.Chk2)
{
actk.Checked = true;
}
else
{
if (i < lenght) actk.Checked = lschk[i];
}
i++;
}
ctx.SaveChanges();
}