private void BtnDelete_Click(object sender, EventArgs e) { using (EntryArticle frm = new EntryArticle(vwarticlesBindingSource.Current as vw_articles)) { if (frm.ShowDialog() == DialogResult.OK) { vwarticlesBindingSource.DataSource = db.vw_articles.ToList(); } } art = vwarticlesBindingSource.Current as vw_articles; db.vw_articles.Remove(art); }
public EntryArticle(vw_articles obj) { InitializeComponent(); db = new asiainspEntities(); if (obj == null) { vwarticlesBindingSource.DataSource = new vw_articles(); art = new vw_articles(); //db.vw_articles.Add(vwarticlesBindingSource.Current as vw_articles); tbArticleCode.Focus(); } else { vwarticlesBindingSource.DataSource = obj; cboShape.SelectedItem = cboShape.FindString(art.ShapeName); db.vw_articles.Attach(vwarticlesBindingSource.Current as vw_articles); } }
private void BtnSave_Click(object sender, EventArgs e) { art = vwarticlesBindingSource.Current as vw_articles; //currency cbo string value = ""; bool isChecked = rb_idr.Checked; if (isChecked) { value = rb_idr.Text; } else { value = rb_usd.Text; } art.Currency = value; db.sp_insert_articles(art.ID, art.SupplierCode, art.TypeName, art.MaterialName, art.SizeName, art.FinishingName, art.AdditionalName, art.ShapeName, art.Description, art.SizeL, art.SizeW, art.SizeD, art.BoxSizeL, art.BoxSizeW, art.BoxSizeD, art.GrossWeight, art.NetWeight, art.PriceSales, art.PriceSupplier, art.Currency); vwarticlesBindingSource.EndEdit(); db.SaveChanges(); MetroMessageBox.Show(this, "New article with article-id = " + art.ID + " is saved.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }