public void UpdateArticleTest() { ar.InsertCaffeArticle(a); CaffeArticle c = ar.GetCaffeArticles().Where(x => x.Name == a.Name).ToList()[0]; int result = ar.UpdateArticle(c); Assert.IsTrue(result > 0); }
public void DeleteArticleTest() { ar.InsertCaffeArticle(a); CaffeArticle c = ar.GetCaffeArticles().Where(x => x.Name == a.Name).ToList()[0]; Assert.IsTrue(ar.DeleteArticle(c.Article_ID) > 0); ar.InsertCaffeArticle(a); }
public bool UpdateArticle(CaffeArticle caffeArticle) { int result = this.articleRepository.UpdateArticle(caffeArticle); if (result != 0) { return(true); } else { return(false); } }
public int InsertCaffeArticle(CaffeArticle caffeArticle) { int result; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = connection; sqlCommand.CommandText = $"Insert into Articles(Name, Price, Packaging) values('{caffeArticle.Name}',{caffeArticle.Price},'{caffeArticle.Packaging}')"; result = sqlCommand.ExecuteNonQuery(); } return(result); }
public int UpdateArticle(CaffeArticle caffeArticle) { int result; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = connection; sqlCommand.CommandText = "Update Articles SET Name =@name, Price= @price, Packaging=@package where Article_ID = @articleID"; sqlCommand.Parameters.AddWithValue("@name", caffeArticle.Name); sqlCommand.Parameters.AddWithValue("@price", caffeArticle.Price); sqlCommand.Parameters.AddWithValue("@package", caffeArticle.Packaging); sqlCommand.Parameters.AddWithValue("@articleID", caffeArticle.Article_ID); result = sqlCommand.ExecuteNonQuery(); } return(result); }
public void refresh() { comboBox1.Text = "Bezalkoholna pica"; comboBox2.Text = "Zestina"; comboBox3.Text = "Pivo"; comboBox4.Text = "Topli napici"; listBox1.Items.Clear(); textBox1.Text = BillBusiness.currentBill.Total_Price.ToString(); ArticleBusiness ab = new ArticleBusiness(); BillItemBusiness bib = new BillItemBusiness(); foreach (CaffeBillItem b in bib.GetCaffeBillItems()) { if (b.Bill_ID == BillBusiness.currentBill.Bill_ID) { CaffeArticle temp = ab.GetCaffeArticles().Where(x => x.Article_ID == b.Article_ID).ToList()[0]; listBox1.Items.Add(temp.ToString() + " x" + b.Quantity); } } }
private void button1_Click(object sender, EventArgs e) { BillBusiness billb = new BillBusiness(); BillItemBusiness bb = new BillItemBusiness(); ArticleBusiness ab = new ArticleBusiness(); if (comboBox1.Text != "Bezalkoholna pica") { string tempname = comboBox1.Text.Split('-')[0]; CaffeArticle ca = ab.GetCaffeArticles().Where(x => x.Name == tempname).ToList()[0]; BillBusiness.currentBill.Total_Price += ca.Price; billb.UpdateCaffeBill(BillBusiness.currentBill); try { CaffeBillItem cb = new CaffeBillItem(ca.Article_ID, BillBusiness.currentBill.Bill_ID, 1); bb.InsertBillItem(cb); } catch { CaffeBillItem zeka = bb.GetCaffeBillItems().Where(x => x.Article_ID == ca.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0]; zeka.Quantity++; bb.UpdateBillItem(zeka); } refresh(); } if (comboBox2.Text != "Zestina") { string tempname = comboBox2.Text.Split('-')[0]; CaffeArticle ca = ab.GetCaffeArticles().Where(x => x.Name == tempname).ToList()[0]; BillBusiness.currentBill.Total_Price += ca.Price; billb.UpdateCaffeBill(BillBusiness.currentBill); try { CaffeBillItem cb = new CaffeBillItem(ca.Article_ID, BillBusiness.currentBill.Bill_ID, 1); bb.InsertBillItem(cb); } catch { CaffeBillItem zeka = bb.GetCaffeBillItems().Where(x => x.Article_ID == ca.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0]; zeka.Quantity++; bb.UpdateBillItem(zeka); } refresh(); } if (comboBox3.Text != "Pivo") { string tempname = comboBox3.Text.Split('-')[0]; CaffeArticle ca = ab.GetCaffeArticles().Where(x => x.Name == tempname).ToList()[0]; BillBusiness.currentBill.Total_Price += ca.Price; billb.UpdateCaffeBill(BillBusiness.currentBill); try { CaffeBillItem cb = new CaffeBillItem(ca.Article_ID, BillBusiness.currentBill.Bill_ID, 1); bb.InsertBillItem(cb); } catch { CaffeBillItem zeka = bb.GetCaffeBillItems().Where(x => x.Article_ID == ca.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0]; zeka.Quantity++; bb.UpdateBillItem(zeka); } refresh(); } if (comboBox4.Text != "Topli napici") { string tempname = comboBox4.Text.Split('-')[0]; CaffeArticle ca = ab.GetCaffeArticles().Where(x => x.Name == tempname).ToList()[0]; BillBusiness.currentBill.Total_Price += ca.Price; billb.UpdateCaffeBill(BillBusiness.currentBill); try { CaffeBillItem cb = new CaffeBillItem(ca.Article_ID, BillBusiness.currentBill.Bill_ID, 1); bb.InsertBillItem(cb); } catch { CaffeBillItem zeka = bb.GetCaffeBillItems().Where(x => x.Article_ID == ca.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0]; zeka.Quantity++; bb.UpdateBillItem(zeka); } refresh(); } }
protected void dodaj_ServerClick(object sender, EventArgs e) { ArticleRepository ab = new ArticleRepository(); BillItemRepository billItem = new BillItemRepository(); BillBusiness bp = new BillBusiness(); String s = toplinapici.Value; if (s != null && s != "Topli napici") { CaffeArticle c = ab.GetCaffeArticles().Where(x => x.Name.Equals(s)).ToList()[0]; BillBusiness.currentBill.Total_Price += c.Price; HtmlGenericControl par = new HtmlGenericControl("p"); par.InnerText = c.ToString(); // contentmain.Controls.Add(par); BillItemRepository br = new BillItemRepository(); try { billItem.InsertCaffeBillItem(new CaffeBillItem(c.Article_ID, BillBusiness.currentBill.Bill_ID, 1)); } catch (Exception xr) { CaffeBillItem cs = cb.Where(x => x.Article_ID == c.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0]; cs.Quantity = cs.Quantity + 1; billItem.UpdateBillItem(cs); } Label1.Text = "Total: " + BillBusiness.currentBill.Total_Price + " RSD"; bp.UpdateCaffeBill(BillBusiness.currentBill); } String s1 = zestina.Value; if (s1 != null && s1 != "Žestina") { CaffeArticle c = ab.GetCaffeArticles().Where(x => x.Name.Equals(s1)).ToList()[0]; BillBusiness.currentBill.Total_Price += c.Price; HtmlGenericControl par = new HtmlGenericControl("p"); par.InnerText = c.ToString(); // contentmain.Controls.Add(par); BillItemRepository br = new BillItemRepository(); try { billItem.InsertCaffeBillItem(new CaffeBillItem(c.Article_ID, BillBusiness.currentBill.Bill_ID, 1)); } catch (Exception xr) { CaffeBillItem cs = cb.Where(x => x.Article_ID == c.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0]; cs.Quantity = cs.Quantity + 1; billItem.UpdateBillItem(cs); } Label1.Text = "Total: " + BillBusiness.currentBill.Total_Price + " RSD"; bp.UpdateCaffeBill(BillBusiness.currentBill); } String s2 = Pivo.Value; if (s2 != null && s2 != "Pivo") { CaffeArticle c = ab.GetCaffeArticles().Where(x => x.Name.Equals(s2)).ToList()[0]; BillBusiness.currentBill.Total_Price += c.Price; HtmlGenericControl par = new HtmlGenericControl("p"); par.InnerText = c.ToString(); // contentmain.Controls.Add(par); BillItemRepository br = new BillItemRepository(); try { billItem.InsertCaffeBillItem(new CaffeBillItem(c.Article_ID, BillBusiness.currentBill.Bill_ID, 1)); } catch (Exception xr) { CaffeBillItem cs = cb.Where(x => x.Article_ID == c.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0]; cs.Quantity = cs.Quantity + 1; billItem.UpdateBillItem(cs); } Label1.Text = "Total: " + BillBusiness.currentBill.Total_Price + " RSD"; bp.UpdateCaffeBill(BillBusiness.currentBill); } String s3 = bezalkohola.Value; if (s3 != null && s3 != "Bezalkoholna pića") { CaffeArticle c = ab.GetCaffeArticles().Where(x => x.Name.Equals(s3)).ToList()[0]; BillBusiness.currentBill.Total_Price += c.Price; HtmlGenericControl par = new HtmlGenericControl("p"); par.InnerText = c.ToString(); // contentmain.Controls.Add(par); BillItemRepository br = new BillItemRepository(); try { billItem.InsertCaffeBillItem(new CaffeBillItem(c.Article_ID, BillBusiness.currentBill.Bill_ID, 1)); } catch (Exception xr) { CaffeBillItem cs = cb.Where(x => x.Article_ID == c.Article_ID && x.Bill_ID == BillBusiness.currentBill.Bill_ID).ToList()[0]; cs.Quantity = cs.Quantity + 1; billItem.UpdateBillItem(cs); } Label1.Text = "Total: " + BillBusiness.currentBill.Total_Price + " RSD"; bp.UpdateCaffeBill(BillBusiness.currentBill); } Response.Redirect("Bill.aspx"); }
public void clean() { CaffeArticle c = ar.GetCaffeArticles().Where(x => x.Name == a.Name).ToList()[0]; ar.DeleteArticle(c.Article_ID); }
public void init() { a = new CaffeArticle(9999, "TestTestTest1", 100, "TestTestTest"); ar = new ArticleRepository(); }