public Bill Save( HttpContext context ) { HttpRequest req = context.Request; Bill bill = new Bill { ID = req.GetInt( "ElectricBill_ID" ), TotalUsedKWh = req.GetDouble( "TotalUsedKWh" ), TotalPriceElectricity = req.GetDouble( "TotalPriceElectricity" ), TotalPriceGroundFee = req.GetDouble( "TotalPriceGroundFee" ), GuestLastReadingTicks = req.GetLong( "GuestLastReadingTicks" ), GuestLastReadingKWh = req.GetDouble( "GuestLastReadingKWh" ), GuestCurrentReadingTicks = req.GetLong( "GuestCurrentReadingTicks" ), GuestCurrentReadingKWh = req.GetDouble( "GuestCurrentReadingKWh" ), GuestPartInGroundFee = req.GetInt( "GuestPartInGroundFee" ), OCR = req.GetString( "OCR" ), CreatedDate = new DateTime( req.GetLong( "CreatedDate" ) ), CreatedByUserID = req.GetInt( "CreatedByUser_ID" ) }; using( DBCommand cmd = DBCommand.New ) { cmd.CommandText = "UpdateElectricBill"; SqlParameter id = cmd.Add( "@ElectricBill_ID", SqlDbType.Int, ParameterDirection.InputOutput, bill.ID ); cmd.AddWithValue( "@TotalUsedKWh", bill.TotalUsedKWh ); cmd.AddWithValue( "@TotalPriceElectricity", bill.TotalPriceElectricity ); cmd.AddWithValue( "@TotalPriceGroundFee", bill.TotalPriceGroundFee ); cmd.AddWithValue( "@GuestLastReadingTicks", bill.GuestLastReadingTicks ); cmd.AddWithValue( "@GuestLastReadingKWh", bill.GuestLastReadingKWh ); cmd.AddWithValue( "@GuestCurrentReadingTicks", bill.GuestCurrentReadingTicks ); cmd.AddWithValue( "@GuestCurrentReadingKWh", bill.GuestCurrentReadingKWh ); cmd.AddWithValue( "@GuestPartInGroundFee", bill.GuestPartInGroundFee ); cmd.AddWithValue( "@OCR", DBCommand.NullZero( bill.OCR ) ); FinanceUser user = FinanceUser.Load( context.User.Identity.Name ); cmd.AddWithValue( "@CreatedByUser_ID", user.ID ); cmd.ExecuteNonQuery(); if( bill.ID <= 0 ) { bill.ID = (int)id.Value; } bill.CreatedByUserID = user.ID; } return bill; }
public IList<Bill> PopulateSelectedData() { if (this.GV_List.Rows != null && this.GV_List.Rows.Count > 0) { IList<Bill> billList = new List<Bill>(); foreach (GridViewRow row in this.GV_List.Rows) { CheckBox checkBoxGroup = row.FindControl("CheckBoxGroup") as CheckBox; if (checkBoxGroup.Checked) { HiddenField hfBillNo = row.FindControl("hfBillNo") as HiddenField; TextBox tbThisBackwashAmount = row.FindControl("tbThisBackwashAmount") as TextBox; Bill bill = new Bill(); bill.BillNo = hfBillNo.Value; if (tbThisBackwashAmount.Text != null && tbThisBackwashAmount.Text.Trim().Length > 0 && decimal.Parse(tbThisBackwashAmount.Text.Trim()) >= 0) { bill.ThisBackwashAmount = decimal.Parse(tbThisBackwashAmount.Text.Trim()); } else { bill.ThisBackwashAmount = 0; } billList.Add(bill); } } return billList; } return null; }
// bill users for transactions made in the last month // this can be automated, if desired by management private void billButton_Click(object sender, EventArgs e) { List<Bill> bills = new List<Bill>(); // get lists of customers and transactions IEnumerable<Customer> customers = Database.GetCustomerList(); IEnumerable<Transaction> transactions = Database.GetTransactionList(); // for each customer, add those transactions made in the last month to a bill // add this bill to the list of bills to send out foreach (Customer cust in customers) { var transaction = from trans in transactions where cust.CustomerID == trans.CustomerID where trans.TransactionDate.Month == AdminClock.Now.AddMonths(-1).Month select trans; IEnumerable<Transaction> custTransList = transaction.AsEnumerable(); // only send out bill if customer has transactions for last month if (custTransList.Count() > 0) { Bill bill = new Bill(cust, custTransList); bills.Add(bill); } } // send out bills to mailer Mailer.MailMonthlyBills(bills); }
public void TakeMoney(Bill bill) { if (billCashDesk.ContainsKey(bill)) billCashDesk[bill]++; else billCashDesk.Add(bill, 1); }
void Start() { GameObject b = GameObject.FindGameObjectWithTag ("BillRizer"); bill = b.GetComponent<Bill>(); dam = -2; ResetPosition (); canMove = false; Invoke ("CanMove", waitTime); }
public static void DeleteBill(Bill bill) { using (var context = DatabaseContext.Initialize()) { context.Bills.Remove(context.Bills.FirstOrDefault(x => x.UID == bill.UID)); context.SaveChanges(); } }
private void BindData() { int billId = Int32.Parse(Request.QueryString["billId"]); CurrentBill = TarpaDataProvider.GetBillById(billId); Page.DataBind(); gridViewBillRows.DataSource = CurrentBill.Rows; gridViewBillRows.DataBind(); }
public void ClearBill() { CurrentBill = new Bill(); CurrentBill.DueDate = CurrentBill.DueDate.AddDays(14); CurrentBill.BillId = TarpaDataProvider.GetLastBillId() + 1; CurrentBill.PaymentType = 0; CurrentBill.ReferenceNumber = Tarpa.Data.ReferenceNumber.Create(CurrentBill.BillId.ToString(), true); CurrentBill.Rows.Add(new BillRow()); ShowCurrentBill(); }
public static bool Validate(Bill bill) { for (int i = 0; i < ValidBills.Length; i++) { if (ValidBills[i] == bill.value) return true; } return false; }
private void btnNew_Click(object sender, EventArgs e) { //lose the previous changes context = new LocalDBEntities(); bill = new Bill(); bill.Date = DateTime.Now.Date; context.Bills.AddObject(bill); bindBillToUI(bill); cmbOrderNo.Text = ""; loadUnbilledOrders(); }
static void Main(string[] args) { decimal grossAmount = 4900; decimal costOfGrocery = 1000; int userEnum = 0; DateTime userCreatedDate = DateTime.Parse("05/09/2013"); Bill billObj1 = new Bill(grossAmount,costOfGrocery,userEnum,userCreatedDate); decimal netPayableAmount1 = billObj1.GetNetPayableAmount(); Console.WriteLine("Net Payable Amount: {0}", netPayableAmount1); }
public void When_constructed_with_applicable_quantity_discount_but_no_matching_items() { var productCatalog = new ProductCatalog(); productCatalog.AddProduct("apple", 0.75m); productCatalog.AddProduct("banana", 1.00m); productCatalog.AddQuantityDiscount("apple", 2, 2.00m); var sut = new Bill(new List<string>() { "banana" }, productCatalog, new Promotions(new List<IPromotionalDiscountRule>() { new AdditionalItemDiscountRule(productCatalog), new QuantityDiscountRule(productCatalog)})); Assert.That(sut.Total, Is.EqualTo(1.00m)); Assert.That(sut.LineItems.Count(), Is.EqualTo(1)); }
private void bindBillToUI(Bill bill) { lblBillNoValue.Text = bill.Id == 0 ? "[New]" : bill.Id.ToString(); if (bill.Order != null) { grdBillLines.AutoGenerateColumns = true; cmbOrderNo.Text = bill.Order.Id.ToString(); cmbOrderNo.DisplayMember = "Id"; RefreshBillLines(); } cmbOrderNo.Enabled = (bill.Id == 0); }
public void GetBillUser_WithInvalidUserType_ShouldPass() { decimal grossAmount = 1900; int userEnum = 5; decimal costOfGrocery = 1000; DateTime userCreatedDate = DateTime.Parse("05/09/2013"); Bill actual = new Bill(grossAmount, costOfGrocery, userEnum, userCreatedDate); Bill expected = new Bill(grossAmount,costOfGrocery,1,userCreatedDate); Assert.AreNotEqual(expected.BillUser, actual.BillUser); }
public void GetGrossAmount_WithValidUserType_ShouldPass() { decimal grossAmount = 1900; int userEnum = 0; decimal costOfGrocery = 1000; DateTime userCreatedDate = DateTime.Parse("05/09/2013"); Bill billObj = new Bill(grossAmount, costOfGrocery, userEnum, userCreatedDate); decimal actual = billObj.GrossAmount; Assert.AreEqual(grossAmount, actual); }
public void Should_charge_car_in_overlapping_rates() { //arrange var bill = new Bill(Vehicle.Car, new DateTime(2013, 04, 30, 9, 45, 0), new DateTime(2013, 04, 30, 15, 15, 0)); //act var charge = CongestionCharger.Charge(bill); //assert charge.AmRateChargeRounded.Should().Be(4.5f); charge.PmRateChargeRounded.Should().Be(8.1f); charge.TotalCharge.Should().Be(12.6f); }
public void GetNetPayableAmountProperty_WithValidUserType_ShouldPass() { decimal grossAmount = 4900; decimal costOfGrocery = 1000; int userEnum = 0; DateTime userCreatedDate = DateTime.Parse("05/09/2013"); Bill billObj = new Bill(grossAmount, costOfGrocery, userEnum, userCreatedDate); decimal actual = billObj.GetNetPayableAmount(); decimal expected = 4460; Assert.AreEqual(expected, billObj.NetPayableAmount); }
public void When_constructed_with_applicable_additional_item_discount() { var productCatalog = new ProductCatalog(); productCatalog.AddProduct("apple", 0.75m); productCatalog.AddProduct("banana", 1.00m); productCatalog.AddAdditionalItemDiscount("apple", 1, 1, 100); var sut = new Bill(new List<string>() { "apple", "banana", "apple", "apple", "apple", "apple" }, productCatalog, new Promotions(new List<IPromotionalDiscountRule>() {new AdditionalItemDiscountRule(productCatalog), new QuantityDiscountRule(productCatalog)})); Assert.That(sut.Total, Is.EqualTo(3.25m)); Assert.That(sut.LineItems.Count(), Is.EqualTo(2)); Assert.That(sut.LineItems.ElementAt(0).PricePerUnit, Is.EqualTo(0.75m)); Assert.That(sut.LineItems.ElementAt(0).DiscountNote, Is.EqualTo("***Discount on apple: Buy 1 apple get 1 at $0.00, New Price $2.25, Savings $1.50")); }
public bool TryEmitBill(Bill bill, out string billingCode) { billingCode = string.Empty; try { //TODO: Implement a mock code. return true; } catch (Exception) { return false; } }
public void GetNetPayableAmount_WithFutureUserCreatedDate_ShouldPass() { decimal grossAmount = 4900; int userEnum = 0; decimal costOfGrocery = 1000; DateTime userCreatedDate = DateTime.Parse("05/09/2016"); Bill billObj = new Bill(grossAmount, costOfGrocery, userEnum, userCreatedDate); decimal actual = billObj.GetNetPayableAmount(); decimal expected = -1; Assert.AreEqual(expected, actual); }
public void Should_charge_car_in_pm_rate() { //arrange var bill = new Bill(Vehicle.Car, new DateTime(2013, 04, 30, 12, 45, 0), new DateTime(2013, 04, 30, 15, 15, 0)); //act var charge = CongestionCharger.Charge(bill); //assert charge.AmRateChargeRounded.Should().Be(0f); charge.PmRateChargeRounded.Should().Be(6.2f); charge.TotalCharge.Should().Be(6.2f); }
public void UpdateFamily(string eventKeyword, Bill[] b) { bool foodFam = false, foodJew = false, heat = false; ArrayList medicineNames = new ArrayList(); int sickIndex = 0; for(int i = 0; i < b.Length; i++){ string[] temp = b[i].GetName ().Split ('('); if(b[i].GetName () == "Food (family)"){ foodFam = b[i].paid; } else if(b[i].GetName () == "Food (Jews)"){ foodJew = b[i].paid; } else if(b[i].GetName () == "Heat"){ heat = b[i].paid; } else if(temp[0] == "Medicine"){ for(int k = 0; k < b[i].howManyPaid; k++){ bool found = false; for(int j = sickIndex; j < family.Length; j++){ if(family[j].IsSick ()){ medicineNames.Add (family[j].firstName); sickIndex = j+1; found = true; break; } } if(!found){ if(sickIndex < family.Length){ sickIndex = family.Length; } for(int j = sickIndex-family.Length; j < jews.Length; j++){ if(jews[j].IsSick()){ medicineNames.Add (jews[j].firstName); sickIndex = j+1; found = true; break; } } } } } } for(int i = 0; i < family.Length; i++){ family[i].UpdatePerson (eventKeyword, foodFam, heat, medicineNames.Contains (family[i].firstName)); } for(int i = 0; i < jews.Length; i++){ jews[i].UpdatePerson (eventKeyword, foodJew, heat, medicineNames.Contains (jews[i].firstName)); } }
public void When_constructed_with_some_items() { var productCatalog = new ProductCatalog(); productCatalog.AddProduct("apple", 0.75m); productCatalog.AddProduct("banana", 1.00m); var sut = new Bill(new List<string>() { "apple", "banana", "apple" }, productCatalog, new Promotions(new List<IPromotionalDiscountRule>())); Assert.That(sut.Total, Is.EqualTo(2.50m)); Assert.That(sut.LineItems.Count(), Is.EqualTo(2)); Assert.That(sut.LineItems.ElementAt(0).Barcode, Is.EqualTo("apple")); Assert.That(sut.LineItems.ElementAt(0).SubTotal, Is.EqualTo(1.50m)); Assert.That(sut.LineItems.ElementAt(1).Barcode, Is.EqualTo("banana")); Assert.That(sut.LineItems.ElementAt(1).SubTotal, Is.EqualTo(1.00m)); }
public void InitPageParameter(bool isPopup, Bill bill) { if (isPopup) { this.billNo = bill.BillNo; this.tbPartyCode.Visible = false; this.ltlParty.Text = bill.BillAddress.Party.Name; this.ltlParty.Visible = true; this.IsRelease.Visible = false; this.btnConfirm.Visible = false; this.btnBack.Visible = false; this.btnAddDetail.Visible = true; this.btnClose.Visible = true; } }
public void Should_charge_car_in_overlapping_rates_for_input1() { //arrange var bill = new Bill(Vehicle.Car, new DateTime(2008, 04, 24, 11, 32, 0), new DateTime(2008, 04, 24, 14, 42, 0)); //act var charge = CongestionCharger.Charge(bill); //assert charge.AmRateChargeRounded.Should().Be(0.9f); charge.PmRateChargeRounded.Should().Be(6.7f); charge.TotalCharge.Should().Be(7.6f); charge.ToString().Should().Be("Charge for 0h 28m (AM rate): £0,90\n\n" + "Charge for 2h 42m (PM rate): £6,70\n\n" + "Total Charge: £7,60"); }
public void Should_charge_motorcycle_in_overlapping_rates_for_input2() { //arrange var bill = new Bill(Vehicle.Motorbike, new DateTime(2008, 04, 24, 17, 0, 0), new DateTime(2008, 04, 24, 22, 11, 0)); //act var charge = CongestionCharger.Charge(bill); //assert charge.AmRateChargeRounded.Should().Be(0f); charge.PmRateChargeRounded.Should().Be(2f); charge.TotalCharge.Should().Be(2f); charge.ToString().Should().Be("Charge for 0h 0m (AM rate): £0,00\n\n" + "Charge for 2h 0m (PM rate): £2,00\n\n" + "Total Charge: £2,00"); }
public int Create() { var bill = new Bill { Name = "NORM Example bill", Date = DateTime.Now, StartDate = DateTime.Now.AddMonths(-1), EndDate = DateTime.Now.AddMonths(1), UserId = 0, NextBillId = null, PrevBillId = null, Type = Bill.BillType.Simple }; bill.Save(); return bill.Id; }
public void paybill(float price, Bill thebill, bool mandatory) { if(totalprofit >= price) { //you have enough money int BillstoPay = thebill.GetCount();//local variable for how manby bills you have to pay if(thebill.howManyPaid < BillstoPay){ //if you haven't reached your cap on how many bills to pay //pay bill totalprofit -= price; //subtract from your money thebill.paid = true; //bill has been paid thebill.howManyPaid++; //increments how many bills youve paid expen += price; //adds to how much youre spending if(mandatory) //is it mandatory? howmanymandatory--; } else Debug.Log("Already paid bill"); } else Debug.Log("not enough money"); }
public static void SaveBill(Bill bill) { using (var context = DatabaseContext.Initialize()) { var dbBill = context.Bills.FirstOrDefault(x => x.UID == bill.UID); if (dbBill == null) { dbBill = context.Bills.Add(bill); } else { dbBill.Name = bill.Name; dbBill.Description = bill.Description; dbBill.Balance = bill.Balance; dbBill.TemplatePath = bill.TemplatePath; dbBill.ReceiptUid = bill.ReceiptUid; } context.SaveChanges(); } }
public Job(Database db, string id = "") : base(db, "jobs", "Aufträge", id) { if (String.IsNullOrEmpty(id)) { base.Name = ""; this.services = new Dictionary<Service, int>(); this.reminders = new Dictionary<Reminder, DateTime>(); this.discounts = new List<Discount>(); this.bill = new Bill(db); this.items = new Dictionary<Item, int>(); this.status = JobStatus.S0_SAVED; this.offer_sent = DateTime.MinValue; this.delivery_date = DateTime.MinValue; this.offer_created = DateTime.Now; this.customer = new Customer(db); this.worker = new Worker(db); this.address = "C"; } else { Result d = base.DB.getRow(base.Tablename, new string[] { "name", "address", "jdate_sent", "worker_id", "jstatus", "customer_id", "jdate_created","jdate_target" }, "`id`='" + id + "'", "", 1); base.Name = d.FirstRow["name"]; this.status = (JobStatus)Enum.Parse(typeof(JobStatus), d.FirstRow["jstatus"]); this.offer_sent = DateTime.Parse(d.FirstRow["jdate_sent"]); this.offer_created = DateTime.Parse(d.FirstRow["jdate_created"]); this.delivery_date = DateTime.Parse(d.FirstRow["jdate_target"]); this.customer = new Customer(db, d.FirstRow["customer_id"]); this.worker = new Worker(db, d.FirstRow["worker_id"]); this.address = d.FirstRow["address"]; this.services = loadServices(); this.reminders = loadReminders(); this.discounts = loadDiscounts(); this.bill = loadBill(); this.items = loadItems(); } }
public override IEnumerable <Toil> MakeNewToils() { Bill bill = job.bill; AddEndCondition(delegate { Thing thing = GetActor().jobs.curJob.GetTarget(TargetIndex.A).Thing; if (thing is Building && !thing.Spawned) { return(JobCondition.Incompletable); } return(JobCondition.Ongoing); }); this.FailOnBurningImmobile(TargetIndex.A); this.FailOn(delegate() { IBillGiver billGiver = job.GetTarget(TargetIndex.A).Thing as IBillGiver; if (billGiver != null) { if (job.bill.DeletedOrDereferenced) { return(true); } if (!billGiver.CurrentlyUsableForBills()) { return(true); } } return(false); }); AddFinishAction(delegate() { if (pawn.equipment.Primary != null && !practice) { if (pawn.equipment.Primary == (ThingWithComps)job.targetB.Thing) { ThingWithComps thingWithComps = (ThingWithComps)job.targetB.Thing; pawn.equipment.TryDropEquipment(thingWithComps, out thingWithComps, pawn.Position, false); } if (job.GetTarget(TargetIndex.C).IsValid) { Equip(TargetIndex.C, false); } } }); Toil gotoBillGiver = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell); if (!practice) { yield return(Toils_Jump.JumpIf(gotoBillGiver, () => job.GetTargetQueue(TargetIndex.B).NullOrEmpty <LocalTargetInfo>())); Toil extract = Toils_JobTransforms.ExtractNextTargetFromQueue(TargetIndex.B, true); yield return(extract); Toil getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B); yield return(getToHaulTarget); yield return(new Toil { initAction = delegate() { Equip(TargetIndex.B, true); }, defaultCompleteMode = ToilCompleteMode.Instant }); yield return(Toils_Jump.JumpIfHaveTargetInQueue(TargetIndex.B, extract)); } Thing currentWeapon = practice ? pawn.equipment.Primary : job.targetB.Thing; yield return(gotoBillGiver); yield return(Toils_Combat.TrySetJobToUseAttackVerb(TargetIndex.A)); yield return(Train(currentWeapon).FailOnDespawnedNullOrForbiddenPlacedThings().FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell)); yield return(FinalizeTraining()); yield break; }
public void PostBill(Bill bill) { Repository.Add(bill); Repository.Save(); }
protected bool CheckSurgeryFailAndroid(Pawn surgeon, Pawn patient, List <Thing> ingredients, BodyPartRecord part, Bill bill) { float num = 1f; if (!patient.RaceProps.IsMechanoid) { num *= surgeon.GetStatValue(StatDefOf.AndroidSurgerySuccessChance, true); } if (patient.InBed()) { num *= patient.CurrentBed().GetStatValue(StatDefOf.AndroidSurgerySuccessChance, true); } num *= this.recipe.surgerySuccessChanceFactor; if (surgeon.InspirationDef == InspirationDefOf.Inspired_Surgery && !patient.RaceProps.IsMechanoid) { if (num < 1f) { num = 1f - (1f - num) * 0.1f; } surgeon.mindState.inspirationHandler.EndInspiration(InspirationDefOf.Inspired_Surgery); } if (!Rand.Chance(num)) { if (Rand.Chance(this.recipe.deathOnFailedSurgeryChance)) { HealthUtility.GiveInjuriesOperationFailureCatastrophic(patient, part); if (!patient.Dead) { patient.Kill(null, null); } Messages.Message("MessageMedicalOperationFailureFatalAndroid".Translate(surgeon.LabelShort, patient.LabelShort, this.recipe.label), patient, MessageTypeDefOf.NegativeHealthEvent); } else if (Rand.Chance(0.5f)) { if (Rand.Chance(0.1f)) { Messages.Message("MessageMedicalOperationFailureRidiculousAndroid".Translate(surgeon.LabelShort, patient.LabelShort), patient, MessageTypeDefOf.NegativeHealthEvent); HealthUtility.GiveInjuriesOperationFailureRidiculous(patient); } else { Messages.Message("MessageMedicalOperationFailureCatastrophicAndroid".Translate(surgeon.LabelShort, patient.LabelShort), patient, MessageTypeDefOf.NegativeHealthEvent); HealthUtility.GiveInjuriesOperationFailureCatastrophic(patient, part); } } else { Messages.Message("MessageMedicalOperationFailureMinorAndroid".Translate(surgeon.LabelShort, patient.LabelShort), patient, MessageTypeDefOf.NegativeHealthEvent); HealthUtility.GiveInjuriesOperationFailureMinor(patient, part); } if (!patient.Dead) { this.TryGainBotchedSurgeryThought(patient, surgeon); } return(true); } return(false); }
public async Task <IActionResult> PutBill([FromRoute] int id, [FromBody] Bill bill) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bill.BillId) { return(BadRequest()); } //https://stackoverflow.com/questions/42735368/updating-related-data-with-entity-framework-core var billDBState = billsContext.Bill.Include(b => b.Logs).FirstOrDefault(b => b.BillId == id); billsContext.Entry(billDBState).CurrentValues.SetValues(bill); var logsDB = billDBState.Logs.ToList(); foreach (var log in logsDB) //iterate over logs in the DB { var incomingLog = bill.Logs.SingleOrDefault(l => l.LogEntryId == log.LogEntryId); if (incomingLog != null) { billsContext.Entry(log).CurrentValues.SetValues(incomingLog); } else { billsContext.Remove(log); } } foreach (var log in bill.Logs) { if (logsDB.All(i => i.LogEntryId != log.LogEntryId)) { billDBState.Logs.Add(log); } } //billsContext.Entry(bill).State = EntityState.Modified; //result in ALL properties being included in the SQL update (whether they've actually changed or not), //EXCEPT for the reference properties for related entities //billsContext.Update(bill); //even if log entry ID is the same, log is inserted multiple times. //will do the same as above, but will include the reference properties, //also include ALL properties on those entities in the update, whether they've changed or not //https://stackoverflow.com/questions/51046340/ef-core-2-0-trouble-cascading-inserts-for-related-entities-when-updating-princ try { await billsContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BillExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
protected override void FillTab() { if (SelTable.def.defName == "VPE_GasStove") { billsOriginator = "FueledStove"; } else if (SelTable.def.defName == "VPE_GasSmelter") { billsOriginator = "ElectricSmelter"; } else if (SelTable.def.defName == "VPE_GasCrematorium") { billsOriginator = "ElectricCrematorium"; } PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed); Rect rect2 = new Rect(WinSize.x - PasteX, PasteY, PasteSize, PasteSize); if (BillUtility.Clipboard == null) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect2, GraphicsCache.Paste, 1f); GUI.color = Color.white; TooltipHandler.TipRegionByKey(rect2, "PasteBillTip"); } else if (!SelTable.def.AllRecipes.Contains(BillUtility.Clipboard.recipe) || !BillUtility.Clipboard.recipe.AvailableNow) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect2, GraphicsCache.Paste, 1f); GUI.color = Color.white; TooltipHandler.TipRegionByKey(rect2, "ClipboardBillNotAvailableHere"); } else if (SelTable.billStack.Count >= 15) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect2, GraphicsCache.Paste, 1f); GUI.color = Color.white; if (Mouse.IsOver(rect2)) { TooltipHandler.TipRegion(rect2, "PasteBillTip".Translate() + " (" + "PasteBillTip_LimitReached".Translate() + ")"); } } else { if (Widgets.ButtonImageFitted(rect2, GraphicsCache.Paste, Color.white)) { Bill bill = BillUtility.Clipboard.Clone(); bill.InitializeAfterClone(); SelTable.billStack.AddBill(bill); SoundDefOf.Tick_Low.PlayOneShotOnCamera(); } TooltipHandler.TipRegionByKey(rect2, "PasteBillTip"); } Rect rect3 = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f); Func <List <FloatMenuOption> > recipeOptionsMaker = delegate { List <FloatMenuOption> list = new List <FloatMenuOption>(); ITab_BillsInherit tab_Bills = default(ITab_BillsInherit); RecipeDef recipe = default(RecipeDef); for (int i = 0; i < ThingDef.Named(billsOriginator).AllRecipes.Count; i++) { tab_Bills = this; if (ThingDef.Named(billsOriginator).AllRecipes[i].AvailableNow) { recipe = ThingDef.Named(billsOriginator).AllRecipes[i]; list.Add(new FloatMenuOption(recipe.LabelCap, delegate { if (!tab_Bills.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col))) { Bill.CreateNoPawnsWithSkillDialog(recipe); } Bill bill2 = recipe.MakeNewBill(); tab_Bills.SelTable.billStack.AddBill(bill2); if (recipe.conceptLearned != null) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total); } if (TutorSystem.TutorialMode) { TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap.Resolve()); } }, recipe.ProducedThingDef, MenuOptionPriority.Default, null, null, 29f, delegate(Rect rect) { if (recipe.products.Count == 1) { ThingDef thingDef = recipe.products[0].thingDef; return(Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, thingDef, GenStuff.DefaultStuffFor(thingDef))); } return(Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe)); })); } } if (!list.Any()) { list.Add(new FloatMenuOption("NoneBrackets".Translate(), null)); } return(list); }; mouseoverBill = SelTable.billStack.DoListing(rect3, recipeOptionsMaker, ref scrollPosition, ref viewHeight); }
// GET: Bills/Create public ActionResult Create() { Bill bill = new Bill(); return(View(bill)); }
public int AddBillAndDetailBill(Bill bill) { int result = new CoffeeDAO().AddBillAndDetailBill(bill); return(result); }
public bool addBill(string id, DateTime date, string totalAmount, string Recieved, string returned, int totalQuantity, string POS, string IDAcc, int[] idpro, string[] quantity, string[] unitprice) { db = new CMART1Entities1(); Bill billl = null; List <Bill> lst = db.Bills.ToList(); foreach (Bill bi in lst) { billl = bi; } if (billl != null) { int t = int.Parse(id.Substring(6, 6)) + 1; string Month = date.Month.ToString(); string Date = date.Day.ToString(); if (Month.Length < 2) { Month = "0" + Month; } if (Date.Length < 2) { Date = "0" + Date; } string idnew = date.Year.ToString() + Month + Date; idnew = idnew.Substring(2, 6); if (idnew == id.Substring(0, 6)) { for (int i = t.ToString().Length; i < 6; i++) { idnew = idnew + "0"; } idnew = idnew + t; } else { idnew = idnew + "000001"; } Bill bill = new Bill(); try { bill.IDBill = idnew; bill.BillDate = date; bill.TotalAmount = totalAmount; bill.TotalQuantity = totalQuantity; bill.Recieved = Recieved; bill.Returned = returned; bill.POS = POS; bill.IDAcc = IDAcc; db.Bills.Add(bill); db.SaveChanges(); addBillList(idnew, idpro, quantity, unitprice); return(true); } catch (Exception) { return(false); } } else { Bill bill = new Bill(); string Month = date.Month.ToString(); string Date = date.Day.ToString(); if (Month.Length < 2) { Month = "0" + Month; } if (Date.Length < 2) { Date = "0" + Date; } string idnew = date.Year.ToString() + Month + Date; idnew = idnew.Substring(2, 6); idnew = idnew + "000001"; try { bill.IDBill = idnew; bill.BillDate = date; bill.TotalAmount = totalAmount; bill.TotalQuantity = totalQuantity; bill.Recieved = Recieved; bill.Returned = returned; bill.POS = POS; bill.IDAcc = IDAcc; db.Bills.Add(bill); db.SaveChanges(); addBillList(idnew, idpro, quantity, unitprice); return(true); } catch (Exception) { return(false); } } }
public static string GetSelectedDocument(string docId, string docType) { Document docToResponce = null; using (document_dbEntities db = new document_dbEntities()) { if (docType == "Счет") { var doc = db.Bills.Find(docId); if (doc != null) { docToResponce = new Bill(doc.DocId, doc.DocDate.ToString(), doc.Provider, doc.Client, doc.ClientId); ((Bill)docToResponce).Products = doc.Products.Select(p => new Product { Name = p.Name, MeasureUnit = p.MeasureUnit, Count = p.Count, Price = (double)p.Price, Sum = (double)p.Sum }).ToList(); ((Bill)docToResponce).CalcGoodsSum(); } } else if (docType == "Квитанция") { var doc = db.Reciepts.Find(docId); if (doc == null) { return(""); } docToResponce = new Reciept(doc.DocId, doc.DocDate.ToString(), doc.Provider, doc.Client, doc.PaymentName); ((Reciept)docToResponce).Products = doc.Products.Select(p => new Product { Name = p.Name, MeasureUnit = p.MeasureUnit, Count = p.Count, Price = (double)p.Price, Sum = (double)p.Sum }).ToList(); ((Reciept)docToResponce).CalcGoodsSum(); } else if (docType == "Накладная") { var doc = db.Invoices.Find(docId); if (doc == null) { return(""); } docToResponce = new Invoice(doc.DocId, doc.DocDate.ToString(), doc.Provider, doc.Client, doc.ProviderId, doc.ClientId); ((Invoice)docToResponce).Products = doc.Products.Select(p => new Product { Name = p.Name, MeasureUnit = p.MeasureUnit, Count = p.Count, Price = (double)p.Price, Sum = (double)p.Sum }).ToList(); ((Invoice)docToResponce).CalcGoodsSum(); } } return(docToResponce.HtmlPrint()); }
public User(string login) { Login = login; _billList = new List <Bill>(); _currentBill = new Bill(); }
protected override IEnumerable <Toil> MakeNewToils() { Bill bill = job.bill; AddEndCondition(delegate { Thing thing = GetActor().jobs.curJob.GetTarget(TargetIndex.A).Thing; if (thing is Building && !thing.Spawned) { return(JobCondition.Incompletable); } return(JobCondition.Ongoing); }); this.FailOnBurningImmobile(TargetIndex.A); this.FailOn(delegate() { IBillGiver billGiver = job.GetTarget(TargetIndex.A).Thing as IBillGiver; if (billGiver != null) { if (job.bill.DeletedOrDereferenced) { return(true); } if (!billGiver.CurrentlyUsableForBills()) { return(true); } } return(false); }); AddFinishAction(delegate() { //Log.Message("LearnWeapon: finishing"); ThingWithComps thingWithComps = (ThingWithComps)job.targetB.Thing; if (pawn.equipment.Primary != null) { pawn.equipment.TryDropEquipment(thingWithComps, out thingWithComps, pawn.Position, false); } }); Toil gotoBillGiver = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell); yield return(Toils_Jump.JumpIf(gotoBillGiver, () => job.GetTargetQueue(TargetIndex.B).NullOrEmpty <LocalTargetInfo>())); Toil extract = Toils_JobTransforms.ExtractNextTargetFromQueue(TargetIndex.B, true); yield return(extract); Toil getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B); yield return(getToHaulTarget); //temporary equip yield return(new Toil { initAction = delegate() { ThingWithComps thingWithComps = (ThingWithComps)job.targetB.Thing; ThingWithComps thingWithComps2; if (thingWithComps.def.stackLimit > 1 && thingWithComps.stackCount > 1) { thingWithComps2 = (ThingWithComps)thingWithComps.SplitOff(1); } else { thingWithComps2 = thingWithComps; thingWithComps2.DeSpawn(DestroyMode.Vanish); } pawn.equipment.MakeRoomFor(thingWithComps2); pawn.equipment.AddEquipment(thingWithComps2); if (thingWithComps.def.soundInteract != null) { thingWithComps.def.soundInteract.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map, false)); } }, defaultCompleteMode = ToilCompleteMode.Instant }); yield return(Toils_Jump.JumpIfHaveTargetInQueue(TargetIndex.B, extract)); yield return(gotoBillGiver); yield return(Toils_Combat.TrySetJobToUseAttackVerb(TargetIndex.A)); Toil train = new Toil(); train.initAction = delegate() { Pawn actor = train.actor; Job curJob = actor.jobs.curJob; ThingDef weapon = job.targetB.Thing.def; workLeft = curJob.bill.recipe.WorkAmountTotal(null); billStartTick = Find.TickManager.TicksGame; ticksSpentDoingRecipeWork = 0; curJob.bill.Notify_DoBillStarted(actor); //sound: //if (weapon.soundInteract != null) weapon.soundInteract.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map, false)); }; train.tickAction = delegate() { Pawn actor = train.actor; Job curJob = actor.jobs.curJob; ThingDef weapon = job.targetB.Thing.def; ticksSpentDoingRecipeWork++; curJob.bill.Notify_PawnDidWork(actor); IBillGiverWithTickAction billGiverWithTickAction = train.actor.CurJob.GetTarget(TargetIndex.A).Thing as IBillGiverWithTickAction; if (billGiverWithTickAction != null) { billGiverWithTickAction.UsedThisTick(); } float num = (curJob.RecipeDef.workSpeedStat != null) ? actor.GetStatValue(curJob.RecipeDef.workSpeedStat, true) : 1f; if (curJob.RecipeDef.workTableSpeedStat != null) { Building_WorkTable building_WorkTable = BillGiver as Building_WorkTable; if (building_WorkTable != null) { num *= building_WorkTable.GetStatValue(curJob.RecipeDef.workTableSpeedStat, true); } } if (DebugSettings.fastCrafting) { num *= 30f; } workLeft -= num; actor.GainComfortFromCellIfPossible(); if (workLeft <= 0f) { ReadyForNextToil(); } //pawn posture Verb verbToUse = actor.jobs.curJob.verbToUse; LocalTargetInfo target = actor.jobs.curJob.GetTarget(TargetIndex.A); pawn.stances.SetStance(new Stance_Warmup(1, target, verbToUse)); //sound: if (verbToUse.verbProps != null && verbToUse.verbProps.warmupTime > 0) { if ((ticksSpentDoingRecipeWork % verbToUse.verbProps.AdjustedFullCycleTime(verbToUse, actor).SecondsToTicks()) == 0) { if (verbToUse.verbProps.soundCast != null) { verbToUse.verbProps.soundCast.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map, false)); } if (verbToUse.verbProps.soundCastTail != null) { verbToUse.verbProps.soundCastTail.PlayOneShotOnCamera(pawn.Map); } } } if (job.RecipeDef.workSkill != null) { //float xpDelta = techComp.proficientWeapons.Contains(job.targetB.Thing.def) ? 1f : 0.1f; float xp = 0.1f * job.RecipeDef.workSkillLearnFactor; actor.skills.GetSkill(job.RecipeDef.workSkill).Learn(xp, false); } }; train.defaultCompleteMode = ToilCompleteMode.Never; train.WithEffect(() => train.actor.CurJob.bill.recipe.effectWorking, TargetIndex.A); train.PlaySustainerOrSound(() => train.actor.CurJob.bill.recipe.soundWorking); train.WithProgressBar(TargetIndex.A, delegate { Pawn actor = train.actor; Job curJob = actor.CurJob; //return 1f - ((JobDriver_DoBill)actor.jobs.curDriver).workLeft / curJob.bill.recipe.WorkAmountTotal(null); return(1f - (workLeft / curJob.bill.recipe.WorkAmountTotal(null))); }, false, -0.5f); train.FailOn(() => train.actor.CurJob.bill.suspended); train.activeSkill = () => train.actor.CurJob.bill.recipe.workSkill; yield return(train.FailOnDespawnedNullOrForbiddenPlacedThings().FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell)); Toil finalizeTraining = new Toil(); finalizeTraining.initAction = delegate { Pawn actor = finalizeTraining.actor; CompKnowledge techComp = actor.TryGetComp <CompKnowledge>(); if (!techComp.proficientWeapons.Contains(job.targetB.Thing.def)) { techComp.proficientWeapons.Add(TargetThingB.def); } job.bill.Notify_IterationCompleted(actor, new List <Thing> { }); actor.jobs.EndCurrentJob(JobCondition.Succeeded, false); }; finalizeTraining.defaultCompleteMode = ToilCompleteMode.Instant; finalizeTraining.FailOnDespawnedOrNull(TargetIndex.A); yield return(finalizeTraining); //testing yield return(Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null)); Toil findPlaceTarget = Toils_Haul.CarryHauledThingToCell(TargetIndex.B); yield return(findPlaceTarget); yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, findPlaceTarget, true, true)); yield break; }
public ActionResult SettleForm(Bill bill) { Require.NotNull(bill, "bill"); return(View("Settle", bill)); }
public ActionResult RefuseBillForm(Bill bill, User currentUser) { return(View("RefuseBill", new BillRefuseViewModel(bill, currentUser))); }
//Retorna todas as faturas public async Task <IEnumerable <Bill> > GetByAnythingAsync(Bill Bill, IDictionary <FilterSearch, String> Query = null, Int32 Page = 1, Int32 PerPage = 20, FilterSearch filterSearch = FilterSearch.id, SortOrder sortOrder = SortOrder.asc) { var list = await SearchByAnythingAsync("bills", Query, Page, PerPage, filterSearch, sortOrder); return(FromDynamicTo <IEnumerable <Bill> >(list?.bills)); }
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill) { CompAndroidState cas = pawn.TryGetComp <CompAndroidState>(); if (cas == null) { return; } cas.customColor = (int)AndroidPaintColor.Red; this.applyFrameworkColor(pawn); }
public BillEventArgs(Bill b) { this.bill = b; }
public void bill(Bill b) { _context.Bills.Add(b); _context.SaveChanges(); }
public static bool CheckSurgeryFail(Recipe_Surgery __instance, ref bool __result, Pawn surgeon, Pawn patient, List <Thing> ingredients, BodyPartRecord part, Bill bill) { var num = 1f; if (!patient.RaceProps.IsMechanoid) { num *= surgeon.GetStatValue(StatDefOf.MedicalSurgerySuccessChance); } if (patient.InBed()) { num *= patient.CurrentBed().GetStatValue(StatDefOf.SurgerySuccessChanceFactor); } num *= Traverse.Create(__instance).Field("MedicineMedicalPotencyToSurgeryChanceFactor") .GetValue <SimpleCurve>().Evaluate(Traverse.Create(__instance) .Method("GetAverageMedicalPotency", new[] { typeof(List <Thing>), typeof(Bill) }) .GetValue <float>(ingredients, bill)); num *= __instance.recipe.surgerySuccessChanceFactor; if (surgeon.InspirationDef == InspirationDefOf.Inspired_Surgery && !patient.RaceProps.IsMechanoid) { num *= 2f; surgeon.mindState.inspirationHandler.EndInspiration(InspirationDefOf.Inspired_Surgery); } num = Mathf.Min(num, 0.98f); if (!Rand.Chance(num)) // Failed check { if (Rand.Chance(num)) // Successful check { //One more chance to get it right with minor injuries if (!Rand.Chance(Mathf.InverseLerp(0, 20, surgeon.skills.GetSkill(SkillDefOf.Medicine).Level) - (1f - surgeon.health.capacities.GetLevel(PawnCapacityDefOf.Consciousness)))) { // Failed check __instance.GiveInfection(patient, part, ingredients); } GiveNonLethalSurgeryInjuries(patient, part); //if (!patient.health.hediffSet.PartIsMissing(part)) //This was breaking some crap //{ __result = false; return(false); //} } if (!Rand.Chance(Mathf.InverseLerp(0, 20, surgeon.skills.GetSkill(SkillDefOf.Medicine).Level) - (1f - surgeon.health.capacities.GetLevel(PawnCapacityDefOf.Consciousness)))) { // Failed check //The surgeon has a chance based on their skill to avoid potentially lethal failures. if (!Rand.Chance(__instance.recipe.deathOnFailedSurgeryChance - num)) { //Failed surgery death chance is influenced by the surgery success chance. HealthUtility.GiveInjuriesOperationFailureCatastrophic(patient, part); if (!patient.Dead) { patient.Kill(null); } Messages.Message( "MessageMedicalOperationFailureFatal".Translate(surgeon.LabelShort, patient.LabelShort, __instance.recipe.LabelCap, surgeon.Named("SURGEON"), patient.Named("PATIENT")), patient, MessageTypeDefOf.NegativeHealthEvent); } else if (!Rand.Chance(num)) // Failed check { //Instead of a 50-50 chance, it's based on how likely you were to successfully complete the surgery. if (!Rand.Chance(surgeon.health.capacities.GetLevel(PawnCapacityDefOf.Consciousness))) { //Only impaired surgeons will ever perform ridiculous failures. Messages.Message( "MessageMedicalOperationFailureRidiculous".Translate(surgeon.LabelShort, patient.LabelShort, surgeon.Named("SURGEON"), patient.Named("PATIENT")), patient, MessageTypeDefOf.NegativeHealthEvent); HealthUtility.GiveInjuriesOperationFailureRidiculous(patient); } else { Messages.Message( "MessageMedicalOperationFailureCatastrophic".Translate(surgeon.LabelShort, patient.LabelShort, surgeon.Named("SURGEON"), patient.Named("PATIENT")), patient, MessageTypeDefOf.NegativeHealthEvent); HealthUtility.GiveInjuriesOperationFailureCatastrophic(patient, part); } } else { Messages.Message( "MessageMedicalOperationFailureMinor".Translate(surgeon.LabelShort, patient.LabelShort, surgeon.Named("SURGEON"), patient.Named("PATIENT")), patient, MessageTypeDefOf.NegativeHealthEvent); RecreateIngredient(surgeon, ingredients); } __instance.GiveInfection(patient, part, ingredients); } else { //Non-lethal surgery injuries. Messages.Message( "MessageMedicalOperationFailureMinor".Translate(surgeon.LabelShort, patient.LabelShort, surgeon.Named("SURGEON"), patient.Named("PATIENT")), patient, MessageTypeDefOf.NegativeHealthEvent); GiveNonLethalSurgeryInjuries(patient, part); __instance.GiveInfection(patient, part, ingredients); RecreateIngredient(surgeon, ingredients); } if (!patient.Dead) { Traverse.Create(__instance) .Method("TryGainBotchedSurgeryThought", new[] { typeof(Pawn), typeof(Pawn) }) .GetValue(patient, surgeon); } __result = true; return(false); } __result = false; return(false); }
public void Init(Bill bill = null) { _bill = bill == null ? new Bill() : bill; _gratuity = (int)_calculation.Gratuity(_bill.SubTotal, bill.Tip); RaiseAllPropertiesChanged(); }
protected override void PostSuccessfulApply(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill) { if (pawn.BillStack.Bills.Count == 0) { pawn.jobs.EndCurrentJob(JobCondition.InterruptForced); } }
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill) { if (pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_pregnancy"))) { Hediff_HumanlikePregnancy pregnancy = (Hediff_HumanlikePregnancy)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy")); pregnancy.CheckPregnancy(); } else if (pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_pregnancy_beast"))) { Hediff_BestialPregnancy pregnancy = (Hediff_BestialPregnancy)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_beast")); pregnancy.CheckPregnancy(); } else if (pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_pregnancy_mech"))) { Hediff_MechanoidPregnancy pregnancy = (Hediff_MechanoidPregnancy)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_mech")); pregnancy.CheckPregnancy(); } else { Messages.Message(xxx.get_pawnname(billDoer) + " has determined " + xxx.get_pawnname(pawn) + " is not pregnant.", MessageTypeDefOf.NeutralEvent); } }
//private static bool TryFindBestBillIngredients(Bill bill, Pawn pawn, Thing billGiver, List<ThingCount> chosen) public static void Prefix(Bill bill) { HackityGetBill.bill = bill; }
public int Add() { string cusID = HttpContext.Session.GetString("CusID") ?? string.Empty; DateTime sDate = DateTime.ParseExact(HttpContext.Session.GetString("sDate"), "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); DateTime eDate = DateTime.ParseExact(HttpContext.Session.GetString("eDate"), "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); if (cusID == null) { return(0); } double discount = 0; if (HttpContext.Session.GetInt32("Voucher") != null) { discount = (double)HttpContext.Session.GetInt32("Voucher"); } double grandtotal = (double)(HttpContext.Session.GetInt32("GrandTotal") ?? 0); Bill bill = new Bill { Emp_ID = "admin", Cus_ID = cusID, Bill_Status = 1, Bill_CheckInDate = sDate, Bill_CheckOutDate = eDate, Bill_CusNum = HttpContext.Session.GetInt32("numC") ?? 0, Bill_BookCost = grandtotal * (double)((100 - discount) / 100), Bill_ExtraCost = 0, Bill_Total = grandtotal * ((100 - discount) / 100) }; _context.Add(bill); _context.SaveChanges(); int billid = bill.Bill_ID; string cartStr = HttpContext.Session.GetString("cart") ?? ""; if (cartStr == "") { return(0); } JObject json = null; if (cartStr != "") { json = JObject.Parse(cartStr); } if (!json.HasValues) { return(0); } foreach (var item in json) { int roomid = (int)item.Value.SelectToken("Room"); for (var day = sDate.Date; day < eDate.Date; day = day.AddDays(1)) { RoomBooking roomBooking = new RoomBooking { Bill_ID = billid, Room_ID = roomid, Booking_Date = day.Year * 10000 + day.Month * 100 + day.Day }; _context.Add(roomBooking); } } _context.SaveChanges(); //Mail var message = new MimeMessage(); string cusEmail = HttpContext.Session.GetString("cusEmail"); message.From.Add(new MailboxAddress("Royal HS", "*****@*****.**")); message.To.Add(new MailboxAddress("Mr. Luong Do", $"{cusEmail}")); string billID = "#" + billid.ToString(); string currDateTime = DateTime.Now.ToString(new CultureInfo("vi-vn")); string cusName = HttpContext.Session.GetString("cusName"); string cusPhone = HttpContext.Session.GetString("cusPhone"); string cusAddress = HttpContext.Session.GetString("cusAddress"); string billCheckinDate = sDate.ToString(new CultureInfo("vi-vn")); string billCheckoutDate = eDate.ToString(new CultureInfo("vi-vn")); string grandTotal = (grandtotal * ((100 - discount) / 100)).ToString("C0", new CultureInfo("vi-vn")); message.Subject = $"Chi tiết hoá đơn đặt phòng {billID}"; message.Body = new TextPart("html") { Text = $"<table align=\"center\" bgcolor=\"#dcf0f8\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin:0;padding:0;background-color:#f2f2f2;width:100%!important;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#444;line-height:18px\" width=\"100%\"> <tbody> <tr> <td align=\"center\" style=\"font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#444;line-height:18px;font-weight:normal\" valign=\"top\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin-top:15px\" width=\"600\"> <tbody> <tr style=\"background:#fff\"> <td align=\"left\" height=\"auto\" style=\"padding:15px\" width=\"600\"> <table> <tbody> <tr> <td> <h1 style=\"font-size:17px;font-weight:bold;color:#444;padding:0 0 5px 0;margin:0\">Cảm ơn quý khách {cusName} đã đặt hàng tại Royal HS,</h1> <p style=\"margin:4px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#444;line-height:18px;font-weight:normal\">Royal HS rất vui thông báo đơn hàng {billID} của quý khách đã được tiếp nhận và lưu trữ trên hệ thống.</p> <h3 style=\"font-size:13px;font-weight:bold;color:#02acea;text-transform:uppercase;margin:20px 0 0 0;border-bottom:1px solid #ddd\">Thông tin đơn hàng {billID} <span style=\"font-size:12px;color:#777;text-transform:none;font-weight:normal\">{currDateTime}</span></h3> </td> </tr> <tr> <td style=\"font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#444;line-height:18px\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"> <thead> <tr> <th align=\"left\" style=\"padding:6px 9px 0px 9px;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#444;font-weight:bold\" width=\"50%\">Thông tin thanh toán</th> <th align=\"left\" style=\"padding:6px 9px 0px 9px;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#444;font-weight:bold\" width=\"50%\"> Thời gian nhận phòng </th> </tr> </thead> <tbody> <tr> <td style=\"padding:3px 9px 9px 9px;border-top:0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#444;line-height:18px;font-weight:normal\" valign=\"top\"><span style=\"text-transform:capitalize\">{cusName}</span><br> <a href=\"mailto:{cusEmail}\" target=\"_blank\">{cusEmail}</a><br> {cusPhone}<br> {cusAddress} </td> <td style=\"padding:3px 9px 9px 9px;border-top:0;border-left:0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#444;line-height:18px;font-weight:normal\" valign=\"top\"><span style=\"text-transform:capitalize\">{billCheckinDate}</span><br> <br> {billCheckoutDate}</td> </tr> <tr> </tr> </tbody> </table> </td> </tr> <tr> <td> <p style=\"margin:4px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#444;line-height:18px;font-weight:normal\"><i>Lưu ý: Khi đến nhận phòng Homestay, nhân viên lễ tân có thể yêu cầu người nhận phòng cung cấp CMND / giấy phép lái xe để chụp ảnh hoặc ghi lại thông tin.</i></p> </td> </tr> <tr> <td> <h2 style=\"text-align:left;margin:10px 0;border-bottom:1px solid #ddd;padding-bottom:5px;font-size:13px;color:#02acea\">CHI TIẾT ĐƠN HÀNG</h2> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"background:#f5f5f5\" width=\"100%\"> <thead> <tr> <th align=\"left\" bgcolor=\"#02acea\" style=\"padding:6px 9px;color:#fff;font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:14px\">STT</th> <th align=\"left\" bgcolor=\"#02acea\" style=\"padding:6px 9px;color:#fff;font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:14px\">Nội dung</th> <th align=\"right\" bgcolor=\"#02acea\" style=\"padding:6px 9px;color:#fff;font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:14px\">Thành tiền</th> </tr> </thead> <tbody bgcolor=\"#eee\" style=\"font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#444;line-height:18px\"> <tr> <td align=\"left\" style=\"padding:3px 9px\" valign=\"top\"><span>1</span><br> </td> <td align=\"left\" style=\"padding:3px 9px\" valign=\"top\"><span>Tiền thu thanh toán đặt phòng</span></td> <td align=\"right\" style=\"padding:3px 9px\" valign=\"top\"><span>{grandTotal}</span></td> </tr> </tbody> <tr bgcolor=\"#eee\"> <td align=\"right\" colspan=\"2\" style=\"padding:7px 9px\"><strong><big>Tổng tiền thu</big> </strong></td> <td align=\"right\" style=\"padding:7px 9px\"><strong><big><span>{grandTotal}</span> </big> </strong></td> </tr> </tfoot> </table> <div style=\"margin:auto\"><a href=\"\" style=\"display:inline-block;text-decoration:none;background-color:#00b7f1!important;margin-right:30px;text-align:center;border-radius:3px;color:#fff;padding:5px 10px;font-size:12px;font-weight:bold;margin-left:35%;margin-top:5px\" target=\"_blank\" data-saferedirecturl=\"https://www.google.com/url?q=https://tiki.vn/sales/order/trackingDetail?code%3D746504874&source=gmail&ust=1594303783242000&usg=AFQjCNGrZAnCVbnSON_VTkwd8buaWR8Okw\">Chi tiết đơn hàng tại Royal HS</a></div> </td> </tr> <tr> <td> <p style=\"margin:0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#444;line-height:18px;font-weight:normal\">Trường hợp quý khách có những băn khoăn về đơn hàng, có thể xem thêm mục <a href=\"\" title=\"Các câu hỏi thường gặp\" target=\"_blank\" data-saferedirecturl=\"https://www.google.com/url?q=http://hotro.Royal HS.vn/hc/vi/?utm_source%3Dtransactional%2Bemail%26utm_medium%3Demail%26utm_term%3Dlogo%26utm_campaign%3Dnew%2Border&source=gmail&ust=1594303783242000&usg=AFQjCNGmdmxJvF88Zd8x_1a2R67nUyDO1Q\"> <strong>các câu hỏi thường gặp</strong>.</a></p> <p style=\"font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#444;line-height:18px;font-weight:normal;border:1px #14ade5 dashed;padding:5px;list-style-type:none\">Từ ngày 14/2/2015, Royal HS sẽ không gởi tin nhắn SMS khi đơn hàng của bạn được xác nhận thành công.</p> <p style=\"margin:10px 0 0 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#444;line-height:18px;font-weight:normal\">Bạn cần được hỗ trợ ngay? Chỉ cần email <a href=\"mailto:hotro@Royal HS.vn\" style=\"color:#099202;text-decoration:none\" target=\"_blank\"> <strong>[email protected]</strong> </a>, hoặc gọi số điện thoại <strong style=\"color:#099202\">1900-6035</strong> (8-21h cả T7,CN). Đội ngũ Royal HS Care luôn sẵn sàng hỗ trợ bạn bất kì lúc nào.</p> </td> </tr> <tr> <td> <p style=\"font-family:Arial,Helvetica,sans-serif;font-size:12px;margin:0;padding:0;line-height:18px;color:#444;font-weight:bold\">Một lần nữa Royal HS cảm ơn quý khách.</p> <p style=\"font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#444;line-height:18px;font-weight:normal;text-align:right\"><strong><a style=\"color:#00a3dd;text-decoration:none;font-size:14px\" target=\"_blank\" data-saferedirecturl=\"https://www.google.com/url?q=http://Royal HS.vn?utm_source%3Dtransactional%2Bemail%26utm_medium%3Demail%26utm_term%3Dlogo%26utm_campaign%3Dnew%2Border&source=gmail&ust=1594303783242000&usg=AFQjCNEVrS3Bg5SZP6XsOKPbP6hMIB_CdA\">Royal HS</a> </strong></p> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> <tr> <td align=\"center\"> <table width=\"600\"> <tbody> <tr> <td> <p align=\"left\" style=\"font-family:Arial,Helvetica,sans-serif;font-size:11px;line-height:18px;color:#4b8da5;padding:10px 0;margin:0px;font-weight:normal\">Quý khách nhận được email này vì đã đặt phòng tại Royal HS.<br> Để chắc chắn luôn nhận được email thông báo, xác nhận đặt phòng từ Royal HS, quý khách vui lòng thêm địa chỉ <strong><a href=\"mailto:hotro@Royal HS.vn\" target=\"_blank\">[email protected]</a></strong> vào số địa chỉ (Address Book, Contacts) của hộp email.<br> <b>Văn phòng Royal HS:</b> 52 Út Tịch, phường 4, quận Tân Bình, thành phố Hồ Chí Minh, Việt Nam<br> Bạn không muốn nhận email từ Royal HS? Hủy đăng ký tại <a>đây</a>.</p> </td> </tr> </tbody> </table> </td> </tr> </tbody></table>" }; using (var client = new SmtpClient()) { client.Connect("smtp.gmail.com", 587); client.AuthenticationMechanisms.Remove("XOAUTH2"); // Note: only needed if the SMTP server requires authentication client.Authenticate("*****@*****.**", "**********"); client.Send(message); client.Disconnect(true); } HttpContext.Session.Clear(); return(1); }
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill) { CompUseEffect_HealHydraulicSystem.Apply(pawn); }
public void PutBill(Bill bill) { //var existed = Repository.Get(id); Repository.Update(bill); Repository.Save(); }
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill) { RecipeOutcomeProperties props = ingredients?.FirstOrDefault()?.def.GetModExtension <RecipeOutcomeProperties>() ?? null; if (props != null) { Thing genomeSequence = GenomeUtility.MakeGenomeSequence(pawn, props.outputThingDef); GenPlace.TryPlaceThing(genomeSequence, billDoer.Position, billDoer.Map, ThingPlaceMode.Near); } }
public static bool Listener(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill) { Utils.lastInstallImplantBillDoer = billDoer; return(true); }
public static void Listener(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill) { Utils.lastInstallImplantBillDoer = null; }
public ActionResult DeleteForm(Bill bill) { Require.NotNull(bill, "bill"); return(View("Delete", bill)); }
//Retorna a faturas pelo id informado public async Task <Bill> GetByIdAnythingAsync(Bill Bill) { var result = await SearchByIdAsync("bills", Bill.Id); return(FromDynamicTo <Bill>(result?.bill)); }