Exemplo n.º 1
0
        private void btnGui_Click(object sender, EventArgs e)
        {
            if (dgvSTK.Rows.Count > 0) // User đã click "Kiểm tra" và có dữ liệu phù hợp
            {
                STK stk = busSTK.timSTK(dgvSTK.CurrentRow.Cells["MaSTK"].Value.ToString());
                stk.NGAYBD = DateTime.ParseExact(txtNgayBD.Text, "dd/M/yyyy", CultureInfo.InvariantCulture);
                stk.NGAYDH = DateTime.ParseExact(txtNgayDH.Text, "dd/M/yyyy", CultureInfo.InvariantCulture);

                switch (stk.MALOAITK.Trim())
                {
                case "LTK01":
                    stk.SODU += double.Parse(txtTienGui.Text) + stk.SODU * stk.LOAITK.LAISUAT * 3;
                    break;

                case "LTK02":
                    stk.SODU += double.Parse(txtTienGui.Text) + stk.SODU * stk.LOAITK.LAISUAT * 6;
                    break;

                case "LTK03":
                    stk.SODU += double.Parse(txtTienGui.Text) + stk.SODU * stk.LOAITK.LAISUAT * 12;
                    break;
                }

                busSTK.suaSTK(stk.MASTK);
                MessageBox.Show("Gửi tiền thành công");
                dgvSTK.Rows.Clear();
                btnKiemTra_Click(sender, e);
            }
            else
            {
                lblLoi.Visible = true;
            }
        }
Exemplo n.º 2
0
        private void btnKiemTra_Click(object sender, EventArgs e)
        {
            dgvSTK.Rows.Clear();

            if (!string.IsNullOrEmpty(txtTuKhoa.Text))
            {
                if (cbxLoaiTraCuu.Text.Equals("CMND"))  // 1 CMND có nhiều STK
                {
                    foreach (STK stk in busSTK.layDsSTK())
                    {
                        if (stk.KHACHHANG.CMND.Equals(txtTuKhoa.Text.Trim()))
                        {
                            dgvSTK.Rows.Add(stk.MASTK, stk.KHACHHANG.HOTEN, stk.LOAITK.TENLOAI, stk.LOAITK.LAISUAT, stk.NGAYBD, stk.NGAYDH, stk.SODU);
                        }
                    }
                }
                else  // 1 Mã STK chỉ thuộc về 1 STK
                {
                    STK stk = busSTK.timSTK(txtTuKhoa.Text.Trim());
                    dgvSTK.Rows.Add(stk.MASTK, stk.KHACHHANG.HOTEN, stk.LOAITK.TENLOAI, stk.LOAITK.LAISUAT, stk.NGAYBD, stk.NGAYDH, stk.SODU);
                }

                if (dgvSTK.Rows.Count == 0)
                {
                    lblLoi.Text    = "Tài khoản không tồn tại !";
                    lblLoi.Visible = true;
                }
            }
            else
            {
                lblLoi.Text    = "Bạn chưa nhập từ khóa !";
                lblLoi.Visible = true;
            }
        }
Exemplo n.º 3
0
        private void cbxMaSTK_TextChanged(object sender, EventArgs e)
        {
            STK stk = busSTK.timSTK(cbxMaSTK.Text.Trim());

            txtLoaiTK.Text  = stk.LOAITK.TENLOAI;
            txtLaiSuat.Text = stk.LOAITK.LAISUAT.ToString();
            txtHoTen.Text   = stk.KHACHHANG.HOTEN;

            switch (stk.MALOAITK.Trim())
            {
            case "LTK01":
                txtTongLai.Text = (stk.SODU * stk.LOAITK.LAISUAT * 3).ToString();
                break;

            case "LTK02":
                txtTongLai.Text = (stk.SODU * stk.LOAITK.LAISUAT * 6).ToString();
                break;

            case "LTK03":
                txtTongLai.Text = (stk.SODU * stk.LOAITK.LAISUAT * 12).ToString();
                break;

            default:        // Không kỳ hạn
                txtTongLai.Text = "";
                break;
            }
        }
Exemplo n.º 4
0
        public void Pb_Admin_UpdateSTK_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            STK UpdateSTK = new STK();

            UpdateSTK.STK_LoadNewSTK();
            Cursor.Current = Cursors.Default;
        }
Exemplo n.º 5
0
 private void CalculateFoMCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     this.progressBar.Value = 0;
     this.progressBar.Style = ProgressBarStyle.Blocks;
     string[] results = STK.CalculateStatistics(root, resultList);
     this.statusLabel.Text = "Coverage calculated";
     root.Rewind();
 }
Exemplo n.º 6
0
 public void themSTK(STK stk)
 {
     try
     {
         dao.themSTK(stk);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 7
0
 public void themSTK(STK stk)
 {
     try
     {
         db.STKs.Add(stk);
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 8
0
        private void runAnalysisDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            for (int i = 0; i < nRuns; i++)
            {
                PropagationResults results = STK.PropagateAstrogatorSatellite(root, app, initState, currentTle, satData, uncertainty, i + 1, Convert.ToInt32(nRuns), propagatorName);
                resultList.Add(results);

                // report the progress
                worker.ReportProgress((i + 1) * 100 / (Convert.ToInt32(nRuns)));
            }
        }
Exemplo n.º 9
0
 // Cập nhật STK
 public void suaSTK(string MaSTK)
 {
     try
     {
         STK stk = db.STKs.SingleOrDefault(x => x.MASTK.Equals(MaSTK));
         db.Entry(stk).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 10
0
        private void GenerateMtoDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            try
            {
                STK.CreateMto(root, resultList);
            }
            catch (Exception)
            {
                MessageBox.Show("MTO already exists", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 11
0
        private void createScenarioTleDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            app = new AgUiApplication();
            app.LoadPersonality("STK");
            root      = (AgStkObjectRoot)app.Personality2;
            initState = new InitialState();
            satData   = new Data(Convert.ToDouble(tbMass.Text), Convert.ToDouble(tbDragArea.Text), Convert.ToDouble(tbCd.Text), Convert.ToDouble(tbSolarArea.Text), Convert.ToDouble(tbCr.Text));
            STK.CreateScenarioFromTle(ref root, Convert.ToDouble(this.nudDuration.Value), ref initState, currentTle);
            STK.ConfigurePropagator(root);
            root.Rewind();
        }
Exemplo n.º 12
0
        private void CalculateFoMDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            try
            {
                STK.CreateCoverage(root, currentTle);
            }
            catch (Exception)
            {
                MessageBox.Show("Coverage already calculated", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 13
0
        private void btnCreateConstellation_Click(object sender, EventArgs e)
        {
            nSatellites = Convert.ToInt32(this.nudSatellites.Value);

            // check for eccentricity
            if (apogeeRadius < perigeeRadius)
            {
                MessageBox.Show("Apogee should be greater than or equal to Perigee", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            for (int i = 0; i < nSatellites; i++)
            {
                string currentSatName = constName + "_" + (i + 1);
                this.lblStatus.Text = "Creating " + currentSatName;
                this.statusStrip1.Update();

                if (i == 0) // first satellite only
                {
                    currentRaan              = initialRaan;
                    currentRaanForStk        = currentRaan;
                    currentMeanAnomaly       = initialMeanAnomaly;
                    currentMeanAnomalyForStk = currentMeanAnomaly;
                }
                else
                {
                    currentRaan       = currentRaan - 360 * (fn / fd);
                    currentRaanForStk = CalculateRaanForStk(currentRaan);
                    // currentMeanAnomaly = 360 * i * ((fn * nPetals + fd * fh) / (fd * nDays));
                    currentMeanAnomaly       = currentMeanAnomaly + (360 * (fn / fd)) / (nDays / nPetals); // eq 1.54
                    currentMeanAnomalyForStk = CalculateMeanAnomalyForStk(currentMeanAnomaly);
                }



                STK.CreateSatellite(currentSatName, orbitPeriod, eccentricity, inclination, currentRaanForStk, currentMeanAnomalyForStk, argOfPerigee);
                STK.SetColorSingle(currentSatName, this.pnlCurrentColor.BackColor);

                bool showInertial = this.cbInertialFrame.Checked;
                bool showFixed    = this.cbFixedFrame.Checked;
                STK.SetOrbitGraphics(currentSatName, showInertial, showFixed);
            }

            this.lblStatus.Text = "";
            this.statusStrip1.Update();

            if (this.cbConstellationObj.Checked)
            {
                STK.CreateConstellation(constName, Convert.ToInt32(nSatellites));
            }
        }
Exemplo n.º 14
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            try
            {
                STK.CheckStkActiveXInstance();
            }
            catch (Exception)
            {
                MessageBox.Show("STK scenario not available. Please create a new one and try again", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.Close();
            }

            CalculateDerivedParameters();
        }
Exemplo n.º 15
0
 private void runAnalysisCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     this.progressBar.Value = 0;
     string[] results = STK.CalculateStatistics(root, resultList);
     this.tbEventLogger.AppendText("Statisitcal summary" + Environment.NewLine);
     this.tbEventLogger.AppendText("Mean Impact Epoch: " + results[0] + Environment.NewLine);
     this.tbEventLogger.AppendText("1-Sigma St. Dev. (min): " + results[1] + Environment.NewLine);
     this.tbEventLogger.AppendText(Environment.NewLine);
     this.tbEventLogger.ScrollToCaret();
     root.Rewind();
     this.statusLabel.Text        = "Analysis ended";
     this.btnGenerateMto.Enabled  = true;
     this.btnCalculateFoM.Enabled = true;
 }
Exemplo n.º 16
0
        private void btnTiep_Click(object sender, EventArgs e)
        {
            STK stk = busSTK.timSTK(txtCMND.Text.Trim());

            if (stk != null)
            {   // Mình chưa bắt lỗi ô CMND bị bỏ trống nhé
                this.Hide();
                // new GuiTietKiemCoKyHan(stk.MASTK).ShowDialog();  // Truyền MaTK vào form mới
                this.Close();
            }
            else
            {
                //lblError.Visible = true;
            }
        }
Exemplo n.º 17
0
        public void Pb_Admin_YearClear_Click(object sender, EventArgs e)
        {
            decimal Year;

            Year = ((NumericUpDown)MainProgram.Self.TabControl.Controls.Find("pb_Admin_STKYearToClear", true).First()).Value;

            DialogResult Results = MessageBox.Show("Zostanie Usunięty Rok: " + Year.ToString() + "  Jesteś tego pewny?", "Uwaga!!", MessageBoxButtons.OKCancel);

            if (Results == DialogResult.OK)
            {
                Cursor.Current = Cursors.WaitCursor;
                STK _STK = new STK();
                _STK.STK_ClearYear(Year);
                Cursor.Current = Cursors.Default;
            }
        }
Exemplo n.º 18
0
        private void createScenarioSatcatDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            app = new AgUiApplication();
            app.LoadPersonality("STK");
            root      = (AgStkObjectRoot)app.Personality2;
            initState = new InitialState();
            satData   = new Data(Convert.ToDouble(tbMass.Text), Convert.ToDouble(tbDragArea.Text), Convert.ToDouble(tbCd.Text), Convert.ToDouble(tbSolarArea.Text), Convert.ToDouble(tbCr.Text));
            string satelliteID = this.dgvSatList.SelectedRows[0].Cells[1].Value.ToString();

            currentTle = STK.CreateScenarioFromSatcat(ref root, Convert.ToDouble(this.nudDuration.Value), ref initState, satelliteID);

            STK.ConfigurePropagator(root);
            root.Rewind();
        }
Exemplo n.º 19
0
        public void Pb_Admin_ManualUpdate_Click(object sender, EventArgs e)
        {
            decimal Year;

            Year = ((NumericUpDown)MainProgram.Self.TabControl.Controls.Find("pb_Admin_STKYearToClear", true).First()).Value;

            DialogResult Results = MessageBox.Show("Czy chcesz dodać STK amnualnie na rok: " + Year.ToString() + "  Jesteś tego pewny?", "Uwaga!!", MessageBoxButtons.OKCancel);

            if (Results == DialogResult.OK)
            {
                Cursor.Current = Cursors.WaitCursor;
                STK _STK = new STK();
                _STK.STK_ManualUpdateFromFile(Year);
                Cursor.Current = Cursors.Default;
            }
        }
Exemplo n.º 20
0
        public void CalculateMaxProfitTest()
        {
            Option opt1 = new Option("VXX", OptionRight.PUT, 33, "20171117");
            Option opt2 = new Option("VXX", OptionRight.CALL, 37, "20171117");
            STK    spot = new STK("VXX");

            Position ShortPut = new Position()
            {
                Asset    = opt1,
                AvgCost  = 1.359,
                Quantity = -1500
            };

            Position BuyCall = new Position()
            {
                Asset    = opt2,
                AvgCost  = 2.061,
                Quantity = 1500
            };

            Position ShortSpot = new Position()
            {
                Asset    = spot,
                AvgCost  = 35,
                Quantity = -1500
            };

            BearCollar bear_collar = new BearCollar(ShortSpot, BuyCall, ShortPut);

            if (bear_collar.IsVaildated)
            {
                var max_profit = bear_collar.CalculateMaxProfit();
                var max_lose   = bear_collar.CalculateMaxLose();


                var ratio = bear_collar.CalculateRiskRatio();

                Assert.IsTrue(max_profit > 0);
            }
        }
Exemplo n.º 21
0
        private void btnGuiTien_Click(object sender, EventArgs e)
        {
            DateTime StartTime = new DateTime(2000, 1, 1);

            KHACHHANG kh  = new KHACHHANG();
            TimeSpan  key = DateTime.Now - StartTime;

            kh.MAKH     = "KH" + key.TotalMilliseconds.ToString().Substring(4, 8);
            kh.HOTEN    = txtHoTen.Text;
            kh.DIACHI   = txtDiaChi.Text;
            kh.SDT      = txtSDT.Text;
            kh.NGAYSINH = DateTime.ParseExact(txtNgaySinh.Text, "dd/M/yyyy", CultureInfo.InvariantCulture);
            kh.CMND     = txtCMND.Text;

            if (rdbNam.Checked)
            {
                kh.GIOITINH = "Nam";
            }
            if (rdbNu.Checked)
            {
                kh.GIOITINH = "Nữ";
            }
            busKH.themKH(kh);

            STK stk = new STK();

            stk.MASTK  = "STK" + key.TotalMilliseconds.ToString().Substring(4, 7);
            stk.MAKH   = kh.MAKH;
            stk.NGAYMO = DateTime.ParseExact(txtNgayMo.Text, "dd/M/yyyy", CultureInfo.InvariantCulture);
            stk.NGAYBD = DateTime.ParseExact(txtNgayBD.Text, "dd/M/yyyy", CultureInfo.InvariantCulture);
            stk.SODU   = int.Parse(txtSoDu.Text);


            switch (cbxLoaiTK.Text)
            {
            case "Tiết kiệm có kỳ hạn 3 tháng":
                stk.MALOAITK = "LTK01";
                stk.NGAYDH   = DateTime.ParseExact(txtNgayDH.Text, "dd/M/yyyy", CultureInfo.InvariantCulture);
                break;

            case "Tiết kiệm có kỳ hạn 6 tháng":
                stk.MALOAITK = "LTK02";
                stk.NGAYDH   = DateTime.ParseExact(txtNgayDH.Text, "dd/M/yyyy", CultureInfo.InvariantCulture);
                break;

            case "Tiết kiệm có kỳ hạn 12 tháng":
                stk.MALOAITK = "LTK03";
                stk.NGAYDH   = DateTime.ParseExact(txtNgayDH.Text, "dd/M/yyyy", CultureInfo.InvariantCulture);
                break;

            case "Tiết kiệm không kỳ hạn":
                stk.MALOAITK = "LTK04";
                break;

            default:
                stk.MALOAITK = "LTK04";     // Mặc định
                break;
            }

            busSTK.themSTK(stk);
            MessageBox.Show("Gửi tiền thành công");
            dgvSTK.DataSource = busSTK.layDsSTK();
        }