public FrmEditPos(int _posId, bool _isNewPos = false, int _dealerId = 0) { posId = _posId; isNewPos = _isNewPos; dealerId = _dealerId; InitializeComponent(); layoutControlItem17.Visibility = isNewPos ? DevExpress.XtraLayout.Utils.LayoutVisibility.Never : DevExpress.XtraLayout.Utils.LayoutVisibility.Always; if (dealerId == 0) { var frmSelectDealer = new Forms.FrmDealerChoose(); if (frmSelectDealer.ShowDialog(this) == DialogResult.OK) { dealerId = frmSelectDealer.DealerId; } } }
private void simpleButton9_Click(object sender, EventArgs e) { var frmSelectDealer = new Forms.FrmDealerChoose(); if (frmSelectDealer.ShowDialog(this) == DialogResult.OK) { try { var dbNew = new tradeEntities(DbModel.Tools.TradeConnectionString(Properties.Settings.Default.barcodeCS.ToString())); var pos2change = dbNew.Pos.Where(x => x.ID == posId).FirstOrDefault(); pos2change.dealer_ID = frmSelectDealer.DealerId; dbNew.SaveChanges(); this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); this.Close(); } } }