private void OpenAct() { if (dataGridView1.RowCount > 0) { if (dataGridView1.CurrentRow == null) { dataGridView1.CurrentCell = dataGridView1.Rows[0].Cells["ArzName"]; } ResultEdit = (Connection.Model.Arz)dataGridView1.CurrentRow.DataBoundItem; txtArzEdit.Text = ResultEdit.ArzName; txtPriceEdit.Text = ResultEdit.Price.ToString("0.##"); pnlFooter.Visible = true; txtArzEdit.Focus(); } }
public static bool Create(Connection.Model.Arz ArzInstance) { using (var context = new Connection.Model.PersianModel()) { try { context.Arz.Add(ArzInstance); context.SaveChanges(); return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); return(false); } } }
public static bool Update(Connection.Model.Arz ObjectName) { using (var context = new Connection.Model.PersianModel()) { try { var Ins = context.Arz.Where(a => a.ArzID == ObjectName.ArzID).FirstOrDefault(); Ins.ArzName = ObjectName.ArzName; Ins.Price = ObjectName.Price; context.SaveChanges(); return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); return(false); } } }