public ActionResult DeleteConfirmed(string id) { billing billing = db.billings.Find(id); db.billings.Remove(billing); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "CustomerID,CustomerName,CustomerAddress,CustomerPostalCode,OrderId,OrderDate,OrderedQuantity,ProductID,ProductDescription,ProductFinish,ProductStandardPrice,ProductLineName")] billing billing) { if (ModelState.IsValid) { db.Entry(billing).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(billing)); }
// GET: billings/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } billing billing = db.billings.Find(id); if (billing == null) { return(HttpNotFound()); } return(View(billing)); }
private async void ExecuteDoWork(object sender, DoWorkEventArgs e) { int PriceWithoutVat = 0; int Vat = 0; int PatientId = SelectedPatient.AskId(); foreach (CreateBillM.PrintItem item in CreateBillM.PrintList) { PriceWithoutVat += item.PriceWithoutVat; Vat += item.VatPrice; } try { using (me = new MedicalModel(ConfigurationManager.Connect())) { await me.Database.Connection.OpenAsync(); CreateBillM.CompanyData from = me.companydata.Where(cd => cd.IdCD == GlobalVM.GlobalM.CompanyId).Select( cd => new CreateBillM.CompanyData() { Name = cd.NameCD, ZipCode = me.zipcode_fx.Where(z => z.IdZC == cd.ZipCodeCD).FirstOrDefault().DataZC, Settlement = me.settlement_fx.Where(s => s.IdS == cd.SettlementCD).FirstOrDefault().DataS, Address = cd.AddressCD, TaxNumber = cd.TAXNumberCD, RegistrationNumber = cd.RegistrationNumberCD, InvoiceNumber = cd.InvoiceNumberCD, Phone = cd.PhoneCD, Email = cd.EmailCD, WebPage = cd.WebPageCD }).Single(); CreateBillM.CompanyData to; if (CreateBillM.From) { to = me.patientdata.Where(p => p.IdPD == PatientId).Select( p => new CreateBillM.CompanyData() { Name = p.BillingNamePD, ZipCode = me.zipcode_fx.Where(z => z.IdZC == p.BillingZipCodePD).FirstOrDefault().DataZC, Settlement = me.settlement_fx.Where(s => s.IdS == p.BillingSettlementPD).FirstOrDefault().DataS, Address = p.AddressPD }).Single(); } else { int Id = CreateBillM.Companies.Where(cs => cs.Name == CreateBillM.SelectedCompany).Single().Id; companydata cd = me.companydata.Where(c => c.IdCD == Id).Single(); to = new CreateBillM.CompanyData() { Name = cd.NameCD, ZipCode = me.zipcode_fx.Where(z => z.IdZC == cd.ZipCodeCD).FirstOrDefault().DataZC, Settlement = me.settlement_fx.Where(s => s.IdS == cd.SettlementCD).FirstOrDefault().DataS, Address = cd.AddressCD, TaxNumber = cd.TAXNumberCD, RegistrationNumber = cd.RegistrationNumberCD, InvoiceNumber = cd.InvoiceNumberCD, Phone = cd.PhoneCD, Email = cd.EmailCD, WebPage = cd.WebPageCD }; } billing b = new billing() { PatientIdB = PatientId, UserIdB = (int)GlobalVM.GlobalM.UserID, CompanyIdFromB = (int)GlobalVM.GlobalM.CompanyId, CompanyIdToB = !CreateBillM.From ? CreateBillM.Companies.Where(c => c.Name == CreateBillM.SelectedCompany).Single().Id : (int?)null, CodeB = CreateBillM.Code, DateTimeB = DateTime.Now, BillB = new DocumentGenerator().Billing(CreateBillM.Code, from, to, CreateBillM.PrintList, PriceWithoutVat, Vat, CreateBillM.Price).ToArray() }; me.billing.Add(b); await me.SaveChangesAsync(); billId = b.IdB; foreach (CreateBillM.PrintItem item in CreateBillM.PrintList) { me.currentpricesforeachbill_st.Add(new currentpricesforeachbill_st() { IdB = billId, IdPFS = item.Id }); } await me.SaveChangesAsync(); } workingConn = true; } catch (Exception ex) { Log.WriteException(ex); workingConn = false; } }