예제 #1
0
        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());
            }
        }
 private void detach_POSITIONs(POSITION entity)
 {
     this.SendPropertyChanging();
     entity.RESULT = null;
 }
 private void attach_POSITIONs(POSITION entity)
 {
     this.SendPropertyChanging();
     entity.RESULT = this;
 }
 partial void DeletePOSITION(POSITION instance);
 partial void UpdatePOSITION(POSITION instance);
 partial void InsertPOSITION(POSITION instance);