public ActionResult VatsGridViewPartialUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] Vat item) { var model = db.Vats; ViewBag.VAT = item; if (ModelState.IsValid) { try { var modelItem = model.FirstOrDefault(it => it.id == item.id); if (modelItem != null) { this.UpdateModel(modelItem); db.SubmitChanges(); Session["VAT"] = IWSLookUp.GetVats(); return(PartialView("VatsGridViewPartial", Session["VAT"])); } } catch (Exception e) { ViewData["GenericError"] = e.Message; IWSLookUp.LogException(e); } } else { ViewData["GenericError"] = IWSLookUp.GetModelSateErrors(ModelState); } return(PartialView("VatsGridViewPartial", item)); }
private List <VAT> GetVat() { List <VAT> vatList = new List <VAT>(); // Zjistíme, jaké sazby jsou v systému uloženy IEnumerable <Vat> allVats = PASS.Storage.StorageSetup.GetAllVats(); foreach (Vat v in allVats) { VAT singleVAT = new VAT(v.id, v.rate + " %", 0.00m, 0.00m); vatList.Add(singleVAT); } foreach (ShoppingCartItem item in ShoppingCart) { Vat itemDbVat = PASS.Storage.StorageSetup.GetProductVatType(item.AddedProduct); decimal?totalPrice = item.TotalPrice; decimal?itemDbVatRate = Convert.ToDecimal(itemDbVat.rate); decimal?divide = itemDbVatRate / 100.00m; decimal?currentVatPrice = totalPrice * divide; // Přidáme do celkové kolekce foreach (VAT vatFromMainCollection in vatList) { if (vatFromMainCollection.id == itemDbVat.id) { vatFromMainCollection.vatValue += currentVatPrice; vatFromMainCollection.vatValueProducts += item.TotalPrice; } } } return(vatList); }
public ActionResult VatsGridViewPartialAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] Vat item) { var model = db.Vats; item.CompanyID = (string)Session["CompanyID"]; item.ModelId = (int)IWSLookUp.MetaModelId.VAT; DateTime dateTime = IWSLookUp.GetCurrentDateTime(); item.Posted = dateTime; item.Updated = dateTime; ViewBag.VAT = item; if (ModelState.IsValid) { try { model.InsertOnSubmit(item); db.SubmitChanges(); Session["VAT"] = IWSLookUp.GetVats(); return(PartialView("VatsGridViewPartial", Session["VAT"])); } catch (Exception e) { ViewData["GenericError"] = e.Message; IWSLookUp.LogException(e); } } else { ViewData["GenericError"] = IWSLookUp.GetModelSateErrors(ModelState); } return(PartialView("VatsGridViewPartial", item)); }
public List <Vat> GetAllVat() { try { Query = "Select * from tbl_Vat"; Connection.Open(); Command.CommandText = Query; Reader = Command.ExecuteReader(); List <Vat> vats = new List <Vat>(); while (Reader.Read()) { Vat vat = new Vat() { Id = (int)Reader["VatId"], Value = (double)Reader["Value"] }; vats.Add(vat); } Reader.Close(); return(vats); } finally { if (Connection != null && Connection.State != ConnectionState.Closed) { Connection.Close(); } } }
public Vat GetById(int id) { try { Query = "SELECT * FROM tbl_Vat WHERE VatId = @Id"; Command.CommandText = Query; Command.Parameters.Clear(); Command.Parameters.AddWithValue("Id", id); Connection.Open(); Reader = Command.ExecuteReader(); Vat vat = null; if (Reader.HasRows) { Reader.Read(); vat = new Vat() { Id = (int)Reader["VatId"], Value = (double)Reader["Value"] }; } Reader.Close(); return(vat); } finally { if (Connection != null && Connection.State != ConnectionState.Closed) { Connection.Close(); } } }
private void btnEditVat_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtVatCode.Text)) { MessageBox.Show("Please Enter Vat Code", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Vat vat = new Vat(); VatRepository repository = new VatRepository(); vat = repository.GetVat(txtVatCode.Text); if (vat != null) { Form form = new frmEditVat(vat) { vat1 = new Vat() }; form.ShowDialog(); txtVatCode_Leave(sender, e); } else { MessageBox.Show("Vat Code does not exist in the database", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public async Task <ActionResult <Vat> > PostVat(Vat vat) { _context.Vat.Add(vat); await _context.SaveChangesAsync(); return(CreatedAtAction("GetVat", new { id = vat.VatId }, vat)); }
public async Task <IActionResult> Edit(int id, [Bind("VatId,Vat1")] Vat vat) { if (id != vat.VatId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vat); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VatExists(vat.VatId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(vat)); }
public frmEditVat(Vat vat) { InitializeComponent(); vat1 = vat; txtVatCode.Text = vat1.VatCd; txtVatPercentage.Text = vat1.VatPercentage.ToString(); }
public void AmountIsCorrect(int expected) { var sut = new Vat(expected); decimal actual = sut; Assert.Equal(expected, actual); }
public async Task <IActionResult> PutVat([FromRoute] int id, [FromBody] Vat Vat) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != Vat.ID) { return(BadRequest()); } _context.Entry(Vat).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VatExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task CreateVat(Guid subscriptionId, string country, decimal rate, string description) { if (subscriptionId == Guid.Empty) { throw new ArgumentException("value cannot be empty", nameof(subscriptionId)); } if (string.IsNullOrWhiteSpace(country)) { throw new ArgumentException("value cannot be empty", nameof(country)); } if (rate < 0) { throw new ArgumentException("value cannot be less than zero", nameof(rate)); } if (string.IsNullOrWhiteSpace(description)) { throw new ArgumentException("value cannot be empty", nameof(description)); } var vat = new Vat { Id = Guid.NewGuid(), SubscriptionId = subscriptionId, Country = country, Description = description, Rate = rate, Unlisted = false }; _context.Add(vat); await _context.SaveChangesAsync(); }
public Vat GetVat(int VatId) { Vat Vat = null; string queryString = SelectString + "WHERE VatId = @VatId;"; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = connection.CreateCommand(); command.CommandText = queryString; command.Parameters.Add(new SqlParameter("@VatId", VatId)); connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { Vat = Read(reader); } } } return(Vat); }
private void btnSave_Click(object sender, EventArgs e) { VatRepository repository = new VatRepository(); if (String.IsNullOrEmpty(txtVatCode.Text)) { MessageBox.Show("Please Enter Vat Code.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (repository.GetVat(txtVatCode.Text) != null) { MessageBox.Show("Vat Code Provided Already exist in Database.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Vat vat = new Vat(); vat.VatCd = txtVatCode.Text.ToUpper(); vat.VatPercentage = Convert.ToDecimal(txtVatPercentage.Text); vat.CreatedBy = "Admin"; if (repository.AddVat(vat)) { MessageBox.Show("Vat Saved Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Vat1.VatCd = txtVatCode.Text; Close(); } else { MessageBox.Show("Error Occurred", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void create_one_complete_order() { IManager manager = new Manager(); ICustomer customer = FactoryCustomer.CreateNew(); manager.AddCustomer(customer); // create Vat Vat vat = new Vat(20); manager.AddVat(vat); var random = new Random(); ICompany store = new Company(); manager.AddCompany(store); // create products List <IProduct> products = FactoryProduct.CreateMultipleProducts(random.Next(5, 15), random.Next(50, 150), vat, manager, store); foreach (Product _product in products) { manager.AddProduct(_product); Console.WriteLine($"Product #{_product.Id}: {_product.Name}, vat : {_product.Vat.percent}%, price without vat : {_product.Price} €, price with vat : {_product.GetPriceWithVAT()} €"); } // create an order Order order = new Order(customer, products); Console.WriteLine($"Order #{order.Id}: {order.Products.Count} products, price : {order.GetTotalPrice()} €, price with vat : {order.GetTotalPriceWithVAT()} €, vat margin : {order.GetVatMargin()} € "); Assert.Greater(products.Count, 1); //Assert.IsTrue(order.Products.Count > 1); }
public async Task <IActionResult> PutVat(int id, Vat vat) { if (id != vat.VatId) { return(BadRequest()); } _context.Entry(vat).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VatExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IHttpActionResult> PutVat(int id, Vat vat) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != vat.id) { return(BadRequest()); } db.Entry(vat).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VatExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnBurningImmobile(TargetIndex.A); yield return(Toils_Reserve.Reserve(TargetIndex.A, 1)); Toil reserveThing = Toils_Reserve.Reserve(TargetIndex.B, 1); yield return(reserveThing); yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B)); yield return(Toils_Haul.StartCarryThing(TargetIndex.B, false, false).FailOnDestroyedNullOrForbidden(TargetIndex.B)); yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserveThing, TargetIndex.B, TargetIndex.None, false, null)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); yield return(Toils_General.Wait(200).FailOnDestroyedNullOrForbidden(TargetIndex.B).FailOnDestroyedNullOrForbidden(TargetIndex.A).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f)); yield return(new Toil { initAction = delegate { Vat.AddInput(InputThing); }, defaultCompleteMode = ToilCompleteMode.Instant }); }
public int Add(Vat vat) { try { CommandObj.CommandText = "UDSP_AddVat"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@ProductId", vat.ProductId); CommandObj.Parameters.AddWithValue("@VatAmount", vat.VatAmount); CommandObj.Parameters.AddWithValue("@UpdateDate", vat.UpdateDate); CommandObj.Parameters.AddWithValue("@UpdateByUserId", vat.UpdateByUserId); CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int); CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output; ConnectionObj.Open(); CommandObj.ExecuteNonQuery(); int rowAffected = Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value); return(rowAffected); } catch (Exception exception) { throw new Exception("Could not save Vat info", exception); } finally { ConnectionObj.Close(); CommandObj.Dispose(); CommandObj.Parameters.Clear(); } }
public void InitialAmountIsCorrect() { var sut = new Vat(); decimal actual = sut; Assert.Equal(0, actual); }
public static decimal TienVatNkByCongThuc(decimal tienHang, decimal tienChietkhau, List <Vat> DT_VAT, string maVat) { try { decimal tienvat = 0; string congthucvat = ""; Vat row_vat = DT_VAT.Where(d => d.Mavat == maVat).FirstOrDefault(); if (row_vat != null) { congthucvat = row_vat.Congthuc.ToString(); } Dictionary <string, decimal> giaTriBien = new Dictionary <string, decimal>(); giaTriBien.Add(PublicValue.TIEN_HANG, tienHang); giaTriBien.Add(PublicValue.TIEN_CK, tienChietkhau); if (!string.IsNullOrEmpty(congthucvat)) { tienvat = TINHBIEUTHUC(congthucvat, giaTriBien); } return(tienvat); } catch { return(0); } }
public ActionResult DeleteConfirmed(int id) { Vat vat = db.vats.Find(id); db.vats.Remove(vat); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Put(Vat vat) { _context.Entry(vat).State = EntityState.Modified; SaveVatHistories(vat.VatHistories); await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <IActionResult> Post(Vat vat) { _context.Add(vat); SaveVatHistories(vat.VatHistories); await _context.SaveChangesAsync(); return(Ok(vat.Id)); }
/// <summary> /// /// </summary> /// <param name="discountvat"></param> public void Calculate_UnitDiscount(decimal discountvat) { decimal calc_discount = Vat.return_ValueWithoutVAT((int)id_vat_group, discountvat); ApplyDiscount_UnitPrice(_discount, calc_discount, unit_price); _discount = calc_discount; Calculate_SubTotalDiscount(_discount); RaisePropertyChanged("discount"); }
public void assign_a_vat_to_product() { IVat vat = new Vat(); vat.percent = 20; IProduct product = new Product("sandwitch", 2.0f, vat); Assert.NotNull(product.Vat); }
public void DeleteVat(Vat vat) { var command = new DeleteVatCommand { Vat = vat }; processXml.Process(command.ToXml()); }
public ActionResult Edit([Bind(Include = "ID,vat,exempt,standardRated,zeroRated")] Vat vat) { if (ModelState.IsValid) { db.Entry(vat).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(vat)); }
// some other actions private void FillAddressInfoInternal(ClientPurchaseInfo clientInfo) { Country.SelectByText(clientInfo.Country); FullName.SendKeys(clientInfo.FullName); Address.SendKeys(clientInfo.Address); City.SendKeys(clientInfo.City); Zip.SendKeys(clientInfo.Zip == null ? string.Empty : clientInfo.Zip); Phone.SendKeys(clientInfo.Phone == null ? string.Empty : clientInfo.Phone); Vat.SendKeys(clientInfo.Vat == null ? string.Empty : clientInfo.Vat); }
public void SutCorrectlyConvertsToDecimal( double d) { var expected = (decimal)d; var sut = new Vat(expected); decimal actual = sut; Assert.Equal(expected, actual); }