private void button1_Click(object sender, EventArgs e) { ModelDataInterfaceDataContext db = new ModelDataInterfaceDataContext(Connection.GetStringConnection()); var opennings = (from pos in db.POSITIONs where pos.ID == _id select pos).First(); OpenFileDialog fop = new OpenFileDialog(); fop.InitialDirectory = @"D:\project\NhatKyGiaoDich\"; fop.Filter = "[png]|*.png"; if (fop.ShowDialog() == DialogResult.OK) { FileStream FS = new FileStream(@fop.FileName, FileMode.Open, FileAccess.Read); byte[] img = new byte[FS.Length]; FS.Read(img, 0, Convert.ToInt32(FS.Length)); opennings.ImageBinaryClose = img; } opennings.IdStatus = 2; opennings.NoteClosed = rtbNoteClose.Text; opennings.IdResult = cbbTypeclose.SelectedIndex + 1; db.SubmitChanges(); ///note // System.Windows.Forms.Form f = System.Windows.Forms.Application.OpenForms["Form1"]; ((Form1)f).ResetDataGridview(); ((Form1)f).LoadOpenningPosition(); ((Form1)f).LoadClosedPositions(); // ((Form1)f).idresult = cbbTypeclose.SelectedIndex + 1; this.Close(); }
private void button1_Click(object sender, EventArgs e) { ModelDataInterfaceDataContext db = new ModelDataInterfaceDataContext(Connection.GetStringConnection()); PAIR ob = new PAIR(); ob.PairName = textBox1.Text; db.PAIRs.InsertOnSubmit(ob); db.SubmitChanges(); this.Close(); }
private void button2_Click(object sender, EventArgs e) { try { ModelDataInterfaceDataContext db = new ModelDataInterfaceDataContext(Connection.GetStringConnection()); POSITION openFrm = new POSITION(); openFrm.IdPair = cmbPair.SelectedIndex + 1; openFrm.IdStatus = cmbstatus.SelectedIndex + 1; openFrm.Entryprice = float.Parse(txtEntry.Text); openFrm.Stoploss = float.Parse(txtSL.Text); openFrm.TakeProfit = float.Parse(txtTP.Text); openFrm.DateOpen = dtpDateOpen.Value; openFrm.NoteOpen = rtbNoteOpen.Text; openFrm.NoteClosed = ""; openFrm.IdResult = 3; OpenFileDialog fop = new OpenFileDialog(); fop.InitialDirectory = @"D:\project\NhatKyGiaoDich\"; fop.Filter = "[png]|*.png"; if (fop.ShowDialog() == DialogResult.OK) { FileStream FS = new FileStream(@fop.FileName, FileMode.Open, FileAccess.Read); byte[] img = new byte[FS.Length]; FS.Read(img, 0, Convert.ToInt32(FS.Length)); openFrm.ImageBinary = img; openFrm.ImageBinaryClose = img; } db.POSITIONs.InsertOnSubmit(openFrm); db.SubmitChanges(); MessageBox.Show("Saved!!!"); System.Windows.Forms.Form f = System.Windows.Forms.Application.OpenForms["Form1"]; ((Form1)f).ResetDataGridview(); ((Form1)f).LoadOpenningPosition(); ((Form1)f).LoadClosedPositions(); this.Close(); } catch (Exception ef) { MessageBox.Show(ef.ToString()); } }