private Models.myItem GetNewItem() { var myFamilies = new List <Models.myFamilies>(); myFamilies.Add(new Models.myFamilies() { Code = "F1" }); myFamilies.Add(new Models.myFamilies() { Code = "F3" }); Models.myItem item = new Models.myItem() { Code = "ART2", Category = "1", Description = "Artigo 2", Abbreviation = "AR 2", VATRateSale = 3, VATRatePurchase = 3, MeasureOfStock = "UN", MeasureOfSale = "UN", MeasureOfPurchase = "UN", Families = myFamilies, }; return(item); }
public void LoadData() { try { var sql = "SELECT id, title, detail,size, date, selected FROM " + TABLE_NAME; using (var statement = _connection.Prepare(sql)) { while (SQLiteResult.ROW == statement.Step()) { string id = (string)statement[0]; string title = (string)statement[1]; string detail = (string)statement[2]; double size = (double)statement[3]; DateTime date = Convert.ToDateTime(statement[4]); bool selected = Convert.ToBoolean(statement[5]); Models.myItem temp = new Models.myItem(id, title, detail, size, date, selected); Models.TodoItem todoitem = new Models.TodoItem(temp); ViewModels.TodoItemViewModel.GetInstance().AllItems.Add(todoitem); } } } catch (Exception) { throw; } }
public IHttpActionResult GenerateItem([FromBody] Models.myItem pItem) { var items = Eti.Aplicacao.Tabelas.Artigos.Clone(); var errorDescription = ""; try { //pItem = GetNewItem(); var item = Eti.Aplicacao.Tabelas.Artigos.Find(pItem.Code); item.CodigoCategoria = pItem.Category; item.Descricao = pItem.Description; item.Abreviatura = pItem.Abbreviation; item.CodigoTaxaIvaVenda = pItem.VATRateSale; item.CodigoTaxaIvaVenda2 = pItem.VATRateSale; item.CodigoTaxaIvaCompra = pItem.VATRatePurchase; item.AbrevMedStk = pItem.MeasureOfStock; item.AbrevMedVnd = pItem.MeasureOfSale; item.AbrevMedCmp = pItem.MeasureOfPurchase; item.NaoAfectaIntrastat = true; if (item.IsNew) { item.CodigoInterno = Eti.Aplicacao.Tabelas.Artigos.DaCodigoInterno(); } if (item.Validate()) { items.Update(ref item); } if (item.EtiErrorDescription != "") { errorDescription = $"Erro ao criar o artigo [{item.Codigo} - {item.Descricao}]: {item.EtiErrorDescription}"; throw new Exception(errorDescription); } } catch (Exception ex) { errorDescription = string.Format("{0}.{1}.{2}", MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, ex.Message); return(BadRequest(errorDescription)); } return(Ok("")); }
private Models.myItem GetNewItem() { Models.myItem item = new Models.myItem() { Code = "ART2", Category = "1", Description = "Artigo 2", Abbreviation = "AR 2", VATRateSale = 3, VATRatePurchase = 3, MeasureOfStock = "UN", MeasureOfSale = "UN", MeasureOfPurchase = "UN", }; return(item); }
public IHttpActionResult GenerateItem([FromBody] Models.myItem pItem) { var items = Eti.Aplicacao.Tabelas.Artigos.Clone(); var errorDescription = ""; try { //string output = JsonConvert.SerializeObject(GetNewItem()); var item = Eti.Aplicacao.Tabelas.Artigos.Find(pItem.Code); item.CodigoCategoria = pItem.Category; item.Descricao = pItem.Description; item.Abreviatura = pItem.Abbreviation; item.CodigoTaxaIvaVenda = pItem.VATRateSale; item.CodigoTaxaIvaVenda2 = pItem.VATRateSale; item.CodigoTaxaIvaCompra = pItem.VATRatePurchase; item.AbrevMedStk = pItem.MeasureOfStock; item.AbrevMedVnd = pItem.MeasureOfSale; item.AbrevMedCmp = pItem.MeasureOfPurchase; item.NaoAfectaIntrastat = true; if (item.IsNew) { item.CodigoInterno = Eti.Aplicacao.Tabelas.Artigos.DaCodigoInterno(); } pItem.Families.ForEach(f => { var familyCode = f.Code; var family = Eti.Aplicacao.Tabelas.Familias.Find(familyCode); var newLineNumber = item.get_LinhaCodigoTpNivel(family.CodTpFamilia); item.set_Familia(newLineNumber, familyCode); }); pItem.PricesLines.ForEach(l => { item.set_PrecoNumLin(l.Number, l.SalePrice); item.set_MoedaNumLin(l.Number, l.Currency); item.set_IvaNumLin(l.Number, l.VATIncluded); }); if (item.Validate()) { items.Update(ref item); } if (item.EtiErrorDescription != "") { errorDescription = $"Erro ao criar o artigo [{item.Codigo} - {item.Descricao}]: {item.EtiErrorDescription}"; throw new Exception(errorDescription); } } catch (Exception ex) { errorDescription = string.Format("{0}.{1}.{2}", MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, ex.Message); return(BadRequest(errorDescription)); } return(Ok("")); }