private void btnSave_Click(object sender, EventArgs e) { model.Name = txt1.Text.Trim(); model.INN = txt2.Text.Trim(); model.City = txt3.Text.Trim(); model.Street = txt4.Text.Trim(); model.DomAndKV = txt5.Text.Trim(); model.Status = txt6.Text.Trim(); using (КудашкинEntities1 db = new КудашкинEntities1()) { if (model.IdSuppler == 0)//Insert { db.Supplier.Add(model); } else //Update { db.Entry(model).State = EntityState.Modified; } db.SaveChanges(); } Clear(); PopulateDataGridView(); MessageBox.Show("Submitted Successfully"); }
void PopulateDataGridView() { dgvS.AutoGenerateColumns = false; using (КудашкинEntities1 db = new КудашкинEntities1()) { dgvS.DataSource = db.DannyS.ToList <DannyS>(); } }
void PopulateDataGridView() { dgvIdProdukts.AutoGenerateColumns = false; using (КудашкинEntities1 db = new КудашкинEntities1()) { dgvIdProdukts.DataSource = db.IdProdukts.ToList <IdProdukts>(); } }
void PopulateDataGridView() { dgvSupplier.AutoGenerateColumns = false; using (КудашкинEntities1 db = new КудашкинEntities1()) { dgvSupplier.DataSource = db.Supplier.ToList <Supplier>(); } }
private void dgvIdProdukts_DoubleClick(object sender, EventArgs e) { if (dgvIdProdukts.CurrentRow.Index != -1) { model.IdGoods = Convert.ToInt32(dgvIdProdukts.CurrentRow.Cells["idGoodsDataGridViewTextBoxColumn"].Value); using (КудашкинEntities1 db = new КудашкинEntities1()) { model = db.IdProdukts.Where(x => x.IdGoods == model.IdGoods).FirstOrDefault(); txtArt.Text = model.Article; txtName.Text = model.Name; txtRemove.Text = model.Remove; } btnSave.Text = "Update"; btnDelete.Enabled = true; } }
private void dgvD_DoubleClick(object sender, EventArgs e) { if (dgvD.CurrentRow.Index != -1) { model.IdContract = Convert.ToInt32(dgvD.CurrentRow.Cells["idContractDataGridViewTextBoxColumn"].Value); using (КудашкинEntities1 db = new КудашкинEntities1()) { model = db.DannyDZ.Where(x => x.IdContract == model.IdContract).FirstOrDefault(); txt1.Text = Convert.ToString(model.IdContract); txt2.Text = Convert.ToString(model.NumberContract); txt3.Text = Convert.ToString(model.IdSuppler); txt4.Text = Convert.ToString(model.Date); txt5.Text = Convert.ToString(model.Status); } btnSave.Text = "Update"; btnDelete.Enabled = true; } }
private void btnDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("Are You Sure to Delete this Record ?", "EF CRUD Operation", MessageBoxButtons.YesNo) == DialogResult.Yes) { using (КудашкинEntities1 db = new КудашкинEntities1()) { var entry = db.Entry(model); if (entry.State == EntityState.Detached) { db.DannyS.Attach(model); } db.DannyS.Remove(model); db.SaveChanges(); PopulateDataGridView(); Clear(); MessageBox.Show("Deleted Successfully"); } } }
private void dgvSupplier_DoubleClick(object sender, EventArgs e) { if (dgvSupplier.CurrentRow.Index != -1) { model.IdSuppler = Convert.ToInt32(dgvSupplier.CurrentRow.Cells["idSupplerDataGridViewTextBoxColumn"].Value); using (КудашкинEntities1 db = new КудашкинEntities1()) { model = db.Supplier.Where(x => x.IdSuppler == model.IdSuppler).FirstOrDefault(); txt1.Text = model.Name; txt2.Text = model.INN; txt3.Text = model.City; txt4.Text = model.Street; txt5.Text = model.DomAndKV; txt6.Text = model.Status; } btnSave.Text = "Update"; btnDelete.Enabled = true; } }
private void btnSave_Click(object sender, EventArgs e) { model.Article = txtArt.Text.Trim(); model.Name = txtName.Text.Trim(); model.Remove = txtRemove.Text.Trim(); using (КудашкинEntities1 db = new КудашкинEntities1()) { if (model.IdGoods == 0)//Insert { db.IdProdukts.Add(model); } else //Update { db.Entry(model).State = EntityState.Modified; } db.SaveChanges(); } Clear(); PopulateDataGridView(); MessageBox.Show("Submitted Successfully"); }
private void btnSave_Click(object sender, EventArgs e) { model.IdContract = int.Parse(txt1.Text.Trim()); model.IdGoods = int.Parse(txt2.Text.Trim()); model.Price = txt3.Text.Trim(); model.Count = txt4.Text.Trim(); model.Status = txt5.Text.Trim(); using (КудашкинEntities1 db = new КудашкинEntities1()) { if (model.IdContract == 0)//Insert { db.DannyS.Add(model); } else //Update { db.Entry(model).State = EntityState.Modified; } db.SaveChanges(); } Clear(); PopulateDataGridView(); MessageBox.Show("Submitted Successfully"); }