Example #1
0
        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();
        }
Example #2
0
        public void LoadClosedPositions()
        {
            ModelDataInterfaceDataContext db = new ModelDataInterfaceDataContext(Connection.GetStringConnection());
            var opennings = from pos in db.POSITIONs
                            join sta in db.STATUSSes on pos.IdStatus equals sta.ID

                            join cucucuc in db.PAIRs on pos.IdPair equals cucucuc.ID


                            where sta.StatusName == "Closed"
                            select new
            {
                pos.ID,
                cucucuc.PairName,
                pos.DateOpen
            };

            dtgClosedPosition.DataSource = opennings;
            dtgClosedPosition.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dtgClosedPosition.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dtgClosedPosition.AllowUserToResizeRows   = false;
            DataGridViewButtonColumn btnsee = new DataGridViewButtonColumn();

            btnsee.HeaderText = "Information";
            btnsee.Text       = "See";
            btnsee.Name       = "btn";
            dtgClosedPosition.Columns.Add(btnsee);
            btnsee.UseColumnTextForButtonValue = true;
        }
Example #3
0
        private void LoadDataCombobox()
        {
            //combbox PAIR
            ModelDataInterfaceDataContext db = new ModelDataInterfaceDataContext(Connection.GetStringConnection());
            var pairsss = from table in db.RESULTs
                          select table.NameResult;

            cbbTypeclose.DataSource = pairsss;
        }
Example #4
0
        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();
        }
Example #5
0
        // public string connection = @"Data Source=SA2WKS0265\SQLEXPRESS;Initial Catalog=TheWay;Integrated Security=True";
        public void LoadDataCombobox()
        {
            //combbox PAIR
            ModelDataInterfaceDataContext db = new ModelDataInterfaceDataContext(Connection.GetStringConnection());
            var pairsss = from table in db.PAIRs
                          select table.PairName;

            cmbPair.DataSource = pairsss;

            //combobox Status
            var statuss = from table in db.STATUSSes
                          select table.StatusName;

            cmbstatus.DataSource = statuss;
        }
Example #6
0
        public void LoadImage()
        {
            try
            {
                //load openposition
                ModelDataInterfaceDataContext db = new ModelDataInterfaceDataContext(Connection.GetStringConnection());
                var imageBinary = from table in db.POSITIONs
                                  where table.ID == _id
                                  select table.ImageBinary;


                //byte[] y = imageBinary.First().ToArray();
                MemoryStream ms = new MemoryStream(imageBinary.First().ToArray());
                pbopen.Image    = Image.FromStream(ms);
                pbopen.SizeMode = PictureBoxSizeMode.StretchImage;
                pbopen.Refresh();

                // if (_showclosed)
                {
                    var noteOpen = from table in db.POSITIONs
                                   where table.ID == _id
                                   select table.NoteOpen;
                    rtbopen.Text = noteOpen.First().ToString();
                }
                //////////////////
                var imageBinaryclosed = from table in db.POSITIONs
                                        where table.ID == _id
                                        select table.ImageBinaryClose;


                //byte[] y = imageBinary.First().ToArray();
                MemoryStream mss = new MemoryStream(imageBinaryclosed.First().ToArray());
                pbclosed.Image    = Image.FromStream(mss);
                pbclosed.SizeMode = PictureBoxSizeMode.StretchImage;
                pbclosed.Refresh();

                {
                    var noteOpen = from table in db.POSITIONs
                                   where table.ID == _id
                                   select table.NoteClosed;
                    rtbclosed.Text = noteOpen.First().ToString();
                }
            }
            catch (Exception eff)
            {
                MessageBox.Show(eff.ToString());
            }
        }
Example #7
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());
            }
        }