// POST: Invoices/Delete/5 //Eliminar factura public void DeleteConfirmed(int id) { Invoice invoice = db.Invoice.Find(id); //Actualizando el Detalle ProjectDetails pd = db.ProjectDetails.Find(invoice.InvoiceProjectDetails.First().ProjectDetailsSpecialist.projectDetailsId); pd.totalInvoiced = pd.totalInvoiced - invoice.amount; pd.toInvoice = pd.totalContracted - pd.totalInvoiced; //Actualizar Proyecto pd.ProjSup.Project.totalnvoiced = decimal.Parse((pd.totalInvoiced - invoice.amount).ToString()); pd.ProjSup.Project.toInvoiced = decimal.Parse((pd.totalContracted - pd.totalInvoiced).ToString()); //Actualizar Estado del SUplemento Supplement s = pd.ProjSup.Supplement; double facturado = s.ProjSup.Sum(z => z.ProjectDetails.Sum(ss => ss.totalInvoiced)); if (Math.Abs(facturado - decimal.ToDouble(s.amount)) < 0.1) { foreach (var state in s.StateCSupplement) { state.state = false; } StateC terminado = db.StateC.Find(10); StateCSupplement stateCSupplement = new StateCSupplement { stateCId = terminado.stateCId, Supplement = s, date = DateTime.Now, description = "Maximo de facturacion alcanzada", state = true }; db.StateCSupplement.Add(stateCSupplement); } else { if (s.StateCSupplement.First(a => a.state).stateCId == 10) { foreach (var state in s.StateCSupplement) { state.state = false; } StateC iniciado = db.StateC.Find(5); StateCSupplement stateCSupplement = new StateCSupplement { stateCId = iniciado.stateCId, Supplement = s, date = DateTime.Now, description = "Estado cambiado dinamicamente x Ediacion de Facturas", state = true }; db.StateCSupplement.Add(stateCSupplement); } } db.InvoiceProjectDetails.RemoveRange(invoice.InvoiceProjectDetails); db.InvoiceStateSet.RemoveRange(invoice.InvoiceStateSet); db.Invoice.Remove(invoice); db.SaveChanges(); }
private void Start() { _fsmSystem = new FSMSystem(); IFSMState stateA = new StateA(_fsmSystem); IFSMState stateB = new StateB(); IFSMState stateC = new StateC(_fsmSystem); stateA[(int)State.B] = stateB; stateA[(int)State.C] = stateC; stateB[(int)State.C] = stateC; stateC[(int)State.A] = stateA; stateC[(int)State.B] = stateB; _fsmSystem.AddState(stateA, true); _fsmSystem.AddState(stateB); _fsmSystem.AddState(stateC); }
/// <summary> /// 方法执行体 /// </summary> public void Process() { StateC.Process(); }
public void Editar_Factura(int?idfact, int?iddet, string projDetailsSpecialistId, string montos, string oldm) { List <int> ids = Convert(projDetailsSpecialistId); List <double> montosv = ConvertMontos(montos); Invoice i = db.Invoice.Find(idfact); double montoant = i.amount; db.InvoiceProjectDetails.RemoveRange(i.InvoiceProjectDetails); for (int j = 0; j < ids.Count; j++) { InvoiceProjectDetails ipd = new InvoiceProjectDetails(); ipd.projDetailsSpecialistId = ids[j]; ipd.amount = montosv[j]; ipd.Invoice = i; i.InvoiceProjectDetails.Add(ipd); } double montof = montosv.Sum(); i.amount = montof; //Actualizando el Detalle ProjectDetails pd = db.ProjectDetails.Find(iddet); pd.totalInvoiced = pd.totalInvoiced + montof - montoant; pd.toInvoice = pd.totalContracted - pd.totalInvoiced; //Actualizar Proyecto pd.ProjSup.Project.totalnvoiced = decimal.Parse((pd.totalInvoiced + montof - montoant).ToString()); pd.ProjSup.Project.toInvoiced = decimal.Parse((pd.totalContracted - pd.totalInvoiced).ToString()); //Actualizar Estado del SUplemento Supplement s = pd.ProjSup.Supplement; double facturado = s.ProjSup.Sum(z => z.ProjectDetails.Sum(ss => ss.totalInvoiced)); if (Math.Abs(facturado - decimal.ToDouble(s.amount)) < 0.1) { foreach (var state in s.StateCSupplement) { state.state = false; } StateC terminado = db.StateC.Find(10); StateCSupplement stateCSupplement = new StateCSupplement { stateCId = terminado.stateCId, Supplement = s, date = DateTime.Now, description = "Maximo de facturacion alcanzada", state = true }; db.StateCSupplement.Add(stateCSupplement); } else { if (s.StateCSupplement.First(a => a.state).stateCId == 10) { foreach (var state in s.StateCSupplement) { state.state = false; } StateC iniciado = db.StateC.Find(5); StateCSupplement stateCSupplement = new StateCSupplement { stateCId = iniciado.stateCId, Supplement = s, date = DateTime.Now, description = "Estado cambiado dinamicamente x Ediacion de Facturas", state = true }; db.StateCSupplement.Add(stateCSupplement); } } ///////////////////////// db.SaveChanges(); }