Exemplo n.º 1
0
 void LoadMain()
 {
     lWait.Visibility = System.Windows.Visibility.Visible;
     if (v == null) v = new MainWnd();
     v.Shutdown = false;
     lWait.Visibility = System.Windows.Visibility.Hidden;
 }
Exemplo n.º 2
0
        private void OnCancelTrailClick(object sender, RoutedEventArgs e)
        {
            System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(_trailingStopId));

            MainWnd.CancelOrder(_trailingStopId);
            _trailingStopId = null;
        }
Exemplo n.º 3
0
        private void LoadProcedure()
        {
            try
            {
                var cmd = new SqlCommand("[getarticlepartitionedqty]", MainWnd._sql_con)
                {
                    CommandType    = CommandType.StoredProcedure,
                    CommandTimeout = 500
                };

                cmd.Parameters.Add("@dateFrom", SqlDbType.DateTime).Value = Get_Date_From();
                cmd.Parameters.Add("@dateTo", SqlDbType.DateTime).Value   = Get_Date_To();
                cmd.Parameters.Add("@file", SqlDbType.VarChar).Value      = _fileName;
                cmd.Parameters.Add("@table", SqlDbType.VarChar).Value     = MainWnd.GetTableSource();

                var da = new SqlDataAdapter(cmd);
                var ds = new DataSet();
                da.Fill(_dataSet);
                da.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex, "Error.", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
        public void InitPositionWatcher(BitmexUser account, Dictionary <string, ICryptoIntrument> instruments)
        {
            _priceMultiplier = PriceMultiplier;
            _instrument      = Instrument;
            _instrumentObj   = (InstrumentBaseType)instruments[_instrument];
            _posWatcher      = new PositionWatcher(_instrument, MainWnd.Controller, MainWindow.Error);

            var ex = MainWnd.Controller.Exchange;

            ex.PositionChanged += _posWatcher.OnPositionChanged;
            ex.OrderChanged    += _posWatcher.OnOrderChanged;

            this.PositionSizeChanged += (s, e) =>
            {
                MainWindow.HandleException(() => _posWatcher.OnPositionSizeChanged(e.PositionSize));
            };
            _posWatcher.WatcherChanged += (s, e) =>
            {
                ChangeControl(() => LogWatcherEvent(e.Message));
            };
            _posWatcher.StateChanged += (s, e) => ChangeControl(() =>
            {
                lblState.Content             = e.Message;
                var state                    = e.Message == "BuyLimit" || e.Message == "SellLimit";
                btnCancelWatching.Visibility = state ? Visibility.Visible : Visibility.Hidden;
            });
            MainWnd.PriceChangedSubscription(true, _instrument);
            _posWatcher.Init(account);
        }
Exemplo n.º 5
0
        private void LoadData()
        {
            _dataTable = new DataTable();

            int.TryParse(MainWnd._mouseOverMachineNumber, out var machine);
            if (machine <= 0 || machine > 210)
            {
                MessageBox.Show("Invalid machine number.", "Sinotico", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            using (var con = new SqlConnection(MainWnd.conString))
            {
                var cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "[getcleanersonmachine]";
                cmd.Connection  = con;

                cmd.Parameters.Add("@startdate", SqlDbType.DateTime).Value   = MainWnd.Get_from_date();
                cmd.Parameters.Add("@enddate", SqlDbType.DateTime).Value     = MainWnd.Get_to_date();
                cmd.Parameters.Add("@machine", SqlDbType.Int).Value          = machine;
                cmd.Parameters.Add("@shiftArray", SqlDbType.NVarChar).Value  = MainWnd.Get_shift_array().ToString();
                cmd.Parameters.Add("@puliziaType", SqlDbType.NVarChar).Value = _puliziaType;

                con.Open();
                var dr = cmd.ExecuteReader();
                _dataTable.Load(dr);
                con.Close();
                dr.Close();
            }

            dgvReport.DataSource = _dataTable;

            dgvReport.Columns[0].Visible = false;
        }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            switch (cb_interval.SelectedIndex)
            {
            case 0:
            {
                MainWnd.SetTableSource("extendview");

                Properties.Settings.Default.TableSource = MainWnd.GetTableSource();
                Properties.Settings.Default.Save();
                MessageBox.Show("Saved!", "Data Interval");
            }
            break;

            case 1:
            {
                MainWnd.SetTableSource("currentyearview");

                Properties.Settings.Default.TableSource = MainWnd.GetTableSource();
                Properties.Settings.Default.Save();
                MessageBox.Show("Saved!", "Data Interval");
            }
            break;

            case 2:
            {
                MainWnd.SetTableSource("historyview");

                Properties.Settings.Default.TableSource = MainWnd.GetTableSource();
                Properties.Settings.Default.Save();
                MessageBox.Show("Saved!", "Data Interval");
            }
            break;
            }
        }
Exemplo n.º 7
0
        protected override void OnLoad(EventArgs e)
        {
            FrmHolidays.dc = new DataContext(MainWnd.conString);
            StyleDataGridView(dgvSettings);
            LoadData();

            cb_interval.SelectedIndex = GetInterval(MainWnd.GetTableSource());

            if (Properties.Settings.Default.UpdateSettings)
            {
                //update user settings from previous version
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpdateSettings = false;
                Properties.Settings.Default.Save();
            }
            AddClearFilterButton(txtDownloadSource, "btnAddPath");

            cbUpdateRuntime.Checked = Properties.Settings.Default.checkUpdates;
            txtDownloadSource.Text  = Properties.Settings.Default.downloadSource;
            Intensity_slider.Value  = currIntesity.Value;
            intensity_label.Text    = "Selected intesity: " + Intensity_slider.Value.ToString();

            //var pathMain = AppDomain.CurrentDomain.BaseDirectory;
            //var strAssembOld = "";
            //foreach (var file in Directory.GetFiles(pathMain))
            //{
            //    if (Path.GetExtension(file) != ".exe") continue;
            //    strAssembOld = Assembly.LoadFile(file).GetName().Version.ToString();
            //}
            //linkLabel1.Text = "Sinotico version: " + strAssembOld;
            //linkLabel1.Refresh();

            base.OnLoad(e);
        }
Exemplo n.º 8
0
        private static void ShowWindows()
        {
            if (ScreenManager.Singleton().Has2Screens)
            {
                LockDisplayWindow.Show();
            }

            MainWnd.Show();
        }
Exemplo n.º 9
0
        private void OnCloseMarketPositionClick(object sender, RoutedEventArgs e)
        {
            var pos  = _posController.GetPosition(_instrument);
            var qty  = Convert.ToInt64(pos.Size);
            var side = pos.Side == "Buy" ? "Sell" : "Buy";

            tbCloseSlip.Background = Brushes.White;

            MainWnd.HandleActionWithMetrics(btnCloseMarket, () => MainWnd.Controller.CreateCloseMarketOrder(_instrument, side, qty), "NEW ORD");
        }
Exemplo n.º 10
0
 public void SetProgressBarValueByTicks(MainWnd mainWnd, int value, string text, CancellationToken cancellationToken)
 {
     try
     {
         for (int i = 0; i < value; i++)
         {
             mainWnd.SetProgressBarValue(i, text, this);
             Thread.Sleep(200);
             cancellationToken.ThrowIfCancellationRequested();
         }
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 11
0
        private void OnCloseLimitPositionClick(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(tbCloseSlip.Text))
            {
                Warning("Slippage value is undefinfed."); return;
            }

            var pos       = _posController.GetPosition(_instrument);
            var side      = pos.Side == "Buy" ? "Sell" : "Buy";
            var qty       = Convert.ToInt64(pos.Size);
            var closeSlip = Convert.ToDouble(tbCloseSlip.Text) * _instrumentObj.TickSize;

            tbCloseSlip.Background = Brushes.White;

            MainWnd.HandleActionWithMetrics(btnCloseLimit, () => _posWatcher.BeginClosePosition(_instrument, side, qty, closeSlip), "NEW ORD");
        }
Exemplo n.º 12
0
        private void LoadProcedure(string shift, DataTable dt)
        {
            SqlDataReader dr;

            if (string.IsNullOrEmpty(cboLines.Text) && string.IsNullOrEmpty(cboLines.Text))
            {
                machinesNr = 210;
            }
            if (!string.IsNullOrEmpty(cboLines.Text))
            {
                machinesNr = 14;
            }
            if (!string.IsNullOrEmpty(cboBlocks.Text))
            {
                machinesNr = 70;
            }

            var cmd = new SqlCommand("getmergedproductioneffects", MainWnd._sql_con)
            {
                CommandType    = CommandType.StoredProcedure,
                CommandTimeout = 300
            };

            cmd.Parameters.Add("@from_date", SqlDbType.DateTime).Value = GetDateFrom;
            cmd.Parameters.Add("@to_date", SqlDbType.DateTime).Value   = GetDateTo;
            cmd.Parameters.Add("@shift", SqlDbType.VarChar).Value      = shift;
            cmd.Parameters.Add("@machine", SqlDbType.VarChar).Value    = _machines_array.ToString();
            cmd.Parameters.Add("@machinesNr", SqlDbType.Int).Value     = machinesNr;
            cmd.Parameters.Add("@table", SqlDbType.VarChar).Value      = MainWnd.GetTableSource();

            MainWnd._sql_con.Open();
            dr = cmd.ExecuteReader();
            dt.Load(dr);
            MainWnd._sql_con.Close();
            dr.Close();
            cmd = null;

            _daysRange = GetDateTo.Subtract(GetDateFrom).TotalDays;
            if (_daysRange == 0)
            {
                _daysRange = 1;
            }
            else
            {
                _daysRange += 1.0;
            }
        }
Exemplo n.º 13
0
    private void Init()
    {
        #region  所有UI界面的获取, 本项目暂时没有做资源加载的框架
        mUIRootTr       = transform.Find("UIRoot");
        mLoadingWnd     = transform.Find("UIRoot/LoadingWnd").GetComponent <LoadingWnd>();
        mLoginWnd       = transform.Find("UIRoot/LoginWnd").GetComponent <LoginWnd>();
        mDynamicTipsWnd = transform.Find("UIRoot/DynamicTips").GetComponent <DynamicTipsWnd>();
        mCreateWnd      = transform.Find("UIRoot/CreateWnd").GetComponent <CreateWnd>();
        mMainWnd        = transform.Find("UIRoot/MainWnd").GetComponent <MainWnd>();
        mActorInfoWnd   = transform.Find("UIRoot/ActorInfoWnd").GetComponent <ActorInfoWnd>();
        mGuideWnd       = transform.Find("UIRoot/GuideWnd").GetComponent <GuideWnd>();
        mStrongWnd      = transform.Find("UIRoot/StrongWnd").GetComponent <StrongWnd>();
        mChatWnd        = transform.Find("UIRoot/ChatWnd").GetComponent <ChatWnd>();
        mCommonBuyWnd   = transform.Find("UIRoot/CommonBuyWnd").GetComponent <CommonBuyWnd>();
        mFuBenWnd       = transform.Find("UIRoot/FuBenWnd").GetComponent <FuBenWnd>();
        mPlayerCtrlWnd  = transform.Find("UIRoot/PlayerCtrlWnd").GetComponent <PlayerCtrlWnd>();

        #endregion

        #region   务层初始化
        mCfgSvc = GetComponent <CfgSvc>();
        mCfgSvc.Init();
        mResSvc = GetComponent <ResSvc>();
        mResSvc.Init();
        mAudioSvc = GetComponent <AudioSvc>();
        mAudioSvc.Init();
        mNetSvc = GetComponent <NetSvc>();
        mNetSvc.Init();
        mTimerSvc = GetComponent <TimerSvc>();
        mTimerSvc.Init();
        #endregion

        #region  业务层初始化
        mLoginSys = GetComponent <LoginSys>();
        mLoginSys.Init();
        mMainCitySys = GetComponent <MainCitySys>();
        mMainCitySys.Init();
        mFuBenSys = GetComponent <FuBenSys>();
        mFuBenSys.Init();
        mBattleSys = GetComponent <BattleSys>();
        mBattleSys.Init();
        #endregion

        InitUIRoot();
        mLoginSys.EnterLogin();
    }
Exemplo n.º 14
0
        private void CreateStopLimitOrder(Button btn, string side)
        {
            double stopPx = 0;

            if (String.IsNullOrEmpty(tbPositionSize.Text))
            {
                Warning("Empty position size."); return;
            }
            if (String.IsNullOrEmpty(tbStopLimitPrice.Text))
            {
                Warning("Empty stop limit price."); return;
            }
            if (String.IsNullOrEmpty(tbStopPriceDelta.Text))
            {
                Warning("Empty trigger value"); return;
            }

            var    triggerDelta = ToPrice(tbStopPriceDelta.Text);
            var    price        = ToPrice(tbStopLimitPrice.Text);
            var    size         = Convert.ToInt32(tbPositionSize.Text);
            var    ctrl         = MainWnd.Controller;
            string text         = null;

            if (side == "Buy")
            {
                if (ctrl.GetBidPrice(_instrument) > price)
                {
                    Warning("Stop price is less than market for the buy."); return;
                }
                stopPx = price - triggerDelta;
            }
            else
            {
                if (price > ctrl.GetAskPrice(_instrument))
                {
                    Warning("Stop price is more than market for the sell."); return;
                }
                stopPx = price + triggerDelta;
            }
            if (!_posController.PositionOpened(_instrument))
            {
                text = "OPN";
            }
            MainWnd.HandleActionWithMetrics(btn, () => ctrl.CreateStopLimitOrder(_instrument, side, size, price, stopPx, false, text), "NEW STOP");
        }
Exemplo n.º 15
0
        private void CreateWatchingOrder(Button btn, string side)
        {
            if (PositionSize == 0)
            {
                Warning("Empty position size"); return;
            }

            var stopLoss = GetAlignedStopLoss(Convert.ToDouble(lblBidPrice.Content)); // stopLossPcnt.Value * Convert.ToDouble(lblBidPrice.Content) / 100;

            if (!stopLoss.HasValue)
            {
                return;
            }

            var priceSlip = ConvertValueFromString(tbPriceSlip.Text) * _instrumentObj.TickSize;
            var stopSlip  = StopSlip;

            MainWnd.HandleActionWithMetrics(btn, () => _posWatcher.BeginOpenPosition(_instrument, side, PositionSize, stopLoss.Value, priceSlip, stopSlip), "NEW ORD");
        }
Exemplo n.º 16
0
 private void LoadProcedure(DataTable dt, int idm)
 {
     using (var con = new SqlConnection(MainWnd.conString))
     {
         var cmd = new SqlCommand();
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Connection  = con;
         cmd.CommandText = "[getscartirammendireportdata]";
         cmd.Parameters.Add("@machine", SqlDbType.Int).Value       = idm;
         cmd.Parameters.Add("@fromDate", SqlDbType.DateTime).Value = MainWnd.Get_from_date();
         cmd.Parameters.Add("@toDate", SqlDbType.DateTime).Value   = MainWnd.Get_to_date();
         cmd.Parameters.Add("@shift", SqlDbType.NVarChar).Value    = MainWnd.Get_shift_array().ToString();
         con.Open();
         var dr = cmd.ExecuteReader();
         dt.Load(dr);
         con.Close();
         dr.Close();
     }
 }
Exemplo n.º 17
0
        //Example 1
        public static void SimpleZip(string dirToZip, string zipName, MainWnd mainWnd, CustomProgressBar pb_ZIP)
        {
            CancellationTokenSource ts_ZIP = new CancellationTokenSource();
            CancellationToken       ct_ZIP = ts_ZIP.Token;

            try
            {
                Task pbZip_Task = new Task(() => { pb_ZIP.SetProgressBarValueByTicks(mainWnd, 100, "Zipping...", ct_ZIP); }, ct_ZIP);
                pbZip_Task.Start();

                ZipFile.CreateFromDirectory(dirToZip, zipName);

                ts_ZIP.Cancel();
                mainWnd.SetProgressBarValue(100, "Zipping finished", pb_ZIP);
            }
            catch (IOException exc)
            {
                ts_ZIP.Cancel();

                MessageBox.Show(exc.Message);

                DialogResult dialogResult = MessageBox.Show("Do you whant to delete existing file(zip) ?", "File exists !!", MessageBoxButtons.YesNo);

                if (dialogResult == DialogResult.Yes)
                {
                    mainWnd.SetProgressBarValue(0, "", pb_ZIP);
                    File.Delete(zipName);
                    SimpleZip(dirToZip, zipName, mainWnd, pb_ZIP);
                }
                else
                {
                    MessageBox.Show("Old version of file(zip) will be uploaded !!");
                    mainWnd.SetProgressBarValue(100, "Zipping finished", pb_ZIP);
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
                throw;
            }
        }
Exemplo n.º 18
0
        private void CreateMarketOrder(Button btn, string side)
        {
            if (!_posController.PositionOpened(_instrument))
            {
                Error("This action shouldn't create a position."); return;
            }
            if (String.IsNullOrEmpty(tbPositionSize.Text))
            {
                Error("Empty position size."); return;
            }

            var    size = Convert.ToInt32(tbPositionSize.Text);
            string text = null;

            if (!_posController.PositionOpened(_instrument))
            {
                text = "OPN";
            }

            MainWnd.HandleActionWithMetrics(btn, () => MainWnd.Controller.CreateMarketOrder(_instrument, side, size, text), "NEW MARKET");
        }
Exemplo n.º 19
0
        private void LoadChanges(string txt)
        {
            _tblChanges = new DataTable();

            var cmd = new SqlCommand(txt, MainWnd._sql_con)
            {
                CommandType    = CommandType.StoredProcedure,
                CommandTimeout = 1000
            };

            cmd.Parameters.Add("@year", SqlDbType.Int).Value      = Convert.ToInt32(_year);
            cmd.Parameters.Add("@table", SqlDbType.VarChar).Value = MainWnd.GetTableSource();

            MainWnd._sql_con.Open();
            var dr = cmd.ExecuteReader();

            _tblChanges.Load(dr);
            MainWnd._sql_con.Close();
            dr.Close();
            cmd = null;
        }
Exemplo n.º 20
0
        private void LoadProcedure(DataSet ds)
        {
            var cmd = new SqlCommand()
            {
                CommandText    = "get_capi_report_data",
                Connection     = MainWnd._sql_con,
                CommandType    = CommandType.StoredProcedure,
                CommandTimeout = 99999999
            };

            cmd.Parameters.Add("@from_date", SqlDbType.DateTime).Value = Get_Date_From();
            cmd.Parameters.Add("@to_date", SqlDbType.DateTime).Value   = Get_Date_To();
            cmd.Parameters.Add("@table", SqlDbType.VarChar).Value      = MainWnd.GetTableSource();
            MainWnd._sql_con.Open();
            var da = new SqlDataAdapter(cmd);

            da.Fill(ds);
            MainWnd._sql_con.Close();
            da.Dispose();
            cmd = null;
        }
Exemplo n.º 21
0
        private void CreateLimitOrder(Button btn, string side)
        {
            if (String.IsNullOrEmpty(tbPositionSize.Text))
            {
                Warning("Empty position size."); return;
            }
            if (String.IsNullOrEmpty(tbLimitPrice.Text))
            {
                Warning("Empty limit price."); return;
            }

            var    limitPrice = ToPrice(tbLimitPrice.Text);
            var    size       = Convert.ToInt32(tbPositionSize.Text);
            string text       = null;

            if (!_posController.PositionOpened(_instrument))
            {
                text = "OPN";
            }

            MainWnd.HandleActionWithMetrics(btn, () => MainWnd.Controller.CreateLimitOrder(_instrument, side, size, limitPrice, false, text), "NEW LIMIT");
        }
Exemplo n.º 22
0
        private void Application_Exit(object sender, ExitEventArgs e)
        {
            try
            {
                if (MonitorManager.IsTwoMonitor)
                {
                    LockDisplayWindow.Close();
                }
                MainWnd.Close();
                Taskbar.Show();

                if (CurrentProceess?.IsProcessOpened ?? false)
                {
                    CurrentProceess.StopProcess();
                }
                Repository.Dispose();
                Logger.Info("End seanse in VrManager!!!!!");
            }
            catch (Exception ex)
            {
                SendException(ex);
            }
        }
Exemplo n.º 23
0
        private void OnCreateTrailClick(object sender, RoutedEventArgs e)
        {
            string side = "Buy";

            if (String.IsNullOrEmpty(tbTrailValue.Text))
            {
                Warning("Empty trailing stop value"); return;
            }

            var trailValue = Convert.ToDouble(tbTrailValue.Text);
            var exchTrail  = cbExchTrail.IsChecked.Value;
            var qty        = CalcPositionSize(100);

            MainWnd.HandleActionWithMetrics((Button)sender, () =>
            {
                if (exchTrail)
                {
                    if (PositionSide == "Buy")
                    {
                        trailValue *= -1;
                        side        = "Sell";
                    }
                    var ordData     = MainWnd.Controller.Client.CreateTrailingStopOrder(_instrument, side, qty, trailValue);
                    _trailingStopId = ordData.OrderId;
                }
                else
                {
                    _posWatcher.PositionPriceChanged(trailValue);
                }
            },
                                            "TRAIL");

            if (exchTrail)
            {
                btnCancelTrail.IsEnabled = true;
            }
        }
Exemplo n.º 24
0
        public static void ZipThenFtp(MainWnd mainWnd, TextBox tb_selectedPublishItemFullPath, CustomProgressBar pb_ZIP, CustomProgressBar pb_FTP, string SiteName)
        {
            string directoryForZipFtp = tb_selectedPublishItemFullPath.Text;

            string currentUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

            currentUser = currentUser.Contains(@"\") == true?currentUser.Replace('\\', '_') : currentUser;

            string zipFileName_Path = directoryForZipFtp + "_" + SitesLogic.Frontend + "_" + currentUser + ".zip";

            Compression.SimpleZip(directoryForZipFtp, zipFileName_Path, mainWnd, pb_ZIP);

            string fileName = zipFileName_Path.Substring(zipFileName_Path.LastIndexOf('\\') + 1);

            fileName = SiteName + "_" + fileName;

            using (WebClient client = new WebClient())
            {
                CancellationTokenSource ts_FTP = new CancellationTokenSource();
                CancellationToken       ct_FTP = ts_FTP.Token;
                Task pbFtp_Task = new Task(() => { pb_FTP.SetProgressBarValueByTicks(mainWnd, 100, "Uploading...", ct_FTP); }, ct_FTP);
                pbFtp_Task.Start();

                client.Credentials = new NetworkCredential(UserName, Password);
                client.UploadFile(FTP_URL + fileName, WebRequestMethods.Ftp.UploadFile, zipFileName_Path);

                ts_FTP.Cancel();
                mainWnd.SetProgressBarValue(100, "Upload Finished", pb_FTP);
            }

            MessageBox.Show("upload finished !!");

            File.Delete(zipFileName_Path);
            mainWnd.SetProgressBarValue(0, "", pb_ZIP);
            mainWnd.SetProgressBarValue(0, "", pb_FTP);
        }
Exemplo n.º 25
0
        private void Application_Exit(object sender, ExitEventArgs e)
        {
            try
            {
                Convert.ToUInt32("sdsa");
                if (MonitorManager.IsTwoMonitor)
                {
                    LockDisplayWindow.Close();
                }
                MainWnd.Close();
                Taskbar.Show();

                if (CurrentProceess?.IsProcessOpened ?? false)
                {
                    CurrentProceess.StopProcess();
                }
                Repository.Dispose();
                Logger.Info("End seanse in VrManager!!!!!");
            }
            catch (Exception ex)
            {
                App.Logger.Error($"exeption {ex.Message} ||| in class {nameof(App)} and method {GetStackTraseMethod().GetMethod().Name}");
            }
        }
Exemplo n.º 26
0
        private void CalculateTotalsHorizontal()
        {
            var main = new MainWnd();

            for (var r = 0; r <= dgvReport.Rows.Count - 1; r++)
            {
                main._hours   = 0;
                main._minutes = 0;
                var eff  = 0.0;
                var eff2 = 0.0;
                var qty  = 0;
                var c1   = 0;
                var c2   = 0;
                var c3   = 0;

                for (var c = 0; c <= dgvReport.Columns.Count - 1; c++)
                {
                    if (c == 1 || c == 4 || c == 7)
                    {
                        if (r > 0)
                        {
                            double.TryParse(dgvReport.Rows[r].Cells[c].Value.ToString(), out double e);
                            if (!string.IsNullOrEmpty(dgvReport.Rows[r].Cells[c].Value.ToString()))
                            {
                                c1++;
                            }
                            eff += e;
                        }
                        else
                        {
                            double.TryParse(dgvReport.Rows[r].Cells[c].Value.ToString().Split('%')[0], out double e);
                            if (!string.IsNullOrEmpty(dgvReport.Rows[r].Cells[c].Value.ToString()))
                            {
                                c1++;
                            }
                            eff += e;
                        }
                    }
                    if (c == 2 || c == 5 || c == 8)
                    {
                        if (r > 0)
                        {
                            double.TryParse(dgvReport.Rows[r].Cells[c].Value.ToString(), out double e);
                            if (!string.IsNullOrEmpty(dgvReport.Rows[r].Cells[c].Value.ToString()))
                            {
                                c2++;
                            }
                            eff2 += e;
                        }
                        else
                        {
                            double.TryParse(dgvReport.Rows[r].Cells[c].Value.ToString().Split('%')[0], out double e);
                            if (!string.IsNullOrEmpty(dgvReport.Rows[r].Cells[c].Value.ToString()))
                            {
                                c2++;
                            }
                            eff2 += e;
                        }
                    }
                    if (c == 3 || c == 6 || c == 9)
                    {
                        int.TryParse(dgvReport.Rows[r].Cells[c].Value.ToString(), out int q);
                        if (!string.IsNullOrEmpty(dgvReport.Rows[r].Cells[c].Value.ToString()))
                        {
                            c3++;
                        }
                        qty += q;
                    }
                }

                var effic  = Math.Round(eff / (c1 == 0 ? 1 : c1), 1);
                var effic2 = Math.Round(eff2 / (c2 == 0 ? 1 : c2), 1);
                dgvReport.Rows[r].Cells[10].Value = effic == 0.0 ? string.Empty : effic.ToString() + "%";
                dgvReport.Rows[r].Cells[11].Value = effic2 == 0.0 ? string.Empty : effic2.ToString() + "%";
                double.TryParse(qty.ToString(), out var qt);
                if (c3 == 0)
                {
                    c3 = 1;
                }
                var mediaQty = Math.Round(qt / c3, 1);
                dgvReport.Rows[r].Cells[12].Value = mediaQty.ToString();
            }
        }
Exemplo n.º 27
0
        private void CalculateTotalsVertical()
        {
            //horizontal and vertical calculator
            var eff1 = 0.0;
            var eff2 = 0.0;
            var eff3 = 0.0;
            var eff4 = 0.0;
            var eff5 = 0.0;
            var eff6 = 0.0;
            var qty1 = 0;
            var qty2 = 0;
            var qty3 = 0;

            var c1 = 0;
            var c2 = 0;
            var c3 = 0;
            var c4 = 0;
            var c5 = 0;
            var c6 = 0;

            var main = new MainWnd();

            for (var r = 1; r <= dgvReport.Rows.Count - 1; r++)
            {
                double.TryParse(dgvReport.Rows[r].Cells[1].Value.ToString(), out double e1);
                if (!string.IsNullOrEmpty(dgvReport.Rows[r].Cells[1].Value.ToString()))
                {
                    c1++;
                }
                eff1 += e1;
                double.TryParse(dgvReport.Rows[r].Cells[2].Value.ToString(), out double e2);
                if (!string.IsNullOrEmpty(dgvReport.Rows[r].Cells[2].Value.ToString()))
                {
                    c2++;
                }
                eff2 += e2;

                int.TryParse(dgvReport.Rows[r].Cells[3].Value.ToString(), out int q1);
                qty1 += q1;

                double.TryParse(dgvReport.Rows[r].Cells[4].Value.ToString(), out double e3);
                if (!string.IsNullOrEmpty(dgvReport.Rows[r].Cells[4].Value.ToString()))
                {
                    c3++;
                }
                eff3 += e3;
                double.TryParse(dgvReport.Rows[r].Cells[5].Value.ToString(), out double e4);
                if (!string.IsNullOrEmpty(dgvReport.Rows[r].Cells[5].Value.ToString()))
                {
                    c4++;
                }
                eff4 += e4;

                int.TryParse(dgvReport.Rows[r].Cells[6].Value.ToString(), out int q2);
                qty2 += q2;

                double.TryParse(dgvReport.Rows[r].Cells[7].Value.ToString(), out double e5);
                if (!string.IsNullOrEmpty(dgvReport.Rows[r].Cells[7].Value.ToString()))
                {
                    c5++;
                }
                eff5 += e5;
                double.TryParse(dgvReport.Rows[r].Cells[8].Value.ToString(), out double e6);
                if (!string.IsNullOrEmpty(dgvReport.Rows[r].Cells[8].Value.ToString()))
                {
                    c6++;
                }
                eff6 += e6;

                int.TryParse(dgvReport.Rows[r].Cells[9].Value.ToString(), out int q3);
                qty3 += q3;
            }

            eff1 = Math.Round(eff1 / (c1 == 0 ? 1 : c1), 1);
            eff2 = Math.Round(eff2 / (c2 == 0 ? 1 : c2), 1);
            eff3 = Math.Round(eff3 / (c3 == 0 ? 1 : c3), 1);
            eff4 = Math.Round(eff4 / (c4 == 0 ? 1 : c4), 1);
            eff5 = Math.Round(eff5 / (c5 == 0 ? 1 : c5), 1);
            eff6 = Math.Round(eff6 / (c6 == 0 ? 1 : c6), 1);

            dgvReport.Rows[0].Cells[1].Value = eff1 == 0.0 ? string.Empty : eff1.ToString() + "%";
            dgvReport.Rows[0].Cells[2].Value = eff2 == 0.0 ? string.Empty : eff2.ToString() + "%";
            dgvReport.Rows[0].Cells[4].Value = eff3 == 0.0 ? string.Empty : eff3.ToString() + "%";
            dgvReport.Rows[0].Cells[5].Value = eff4 == 0.0 ? string.Empty : eff4.ToString() + "%";
            dgvReport.Rows[0].Cells[7].Value = eff5 == 0.0 ? string.Empty : eff5.ToString() + "%";
            dgvReport.Rows[0].Cells[8].Value = eff6 == 0.0 ? string.Empty : eff6.ToString() + "%";

            dgvReport.Rows[0].Cells[3].Value = Math.Round(Convert.ToDouble(qty1 / _daysRange), 0).ToString();
            dgvReport.Rows[0].Cells[6].Value = Math.Round(Convert.ToDouble(qty2 / _daysRange), 0).ToString();
            dgvReport.Rows[0].Cells[9].Value = Math.Round(Convert.ToDouble(qty3 / _daysRange), 0).ToString();
        }
Exemplo n.º 28
0
        //------------------------------------------------------------------------

        public ControllerFolderCreator(MainWnd mainWnd)
        {
            m_mainWnd = mainWnd;

            m_modelFolderCreator = new ModelFolderCreator();
        }
Exemplo n.º 29
0
        static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException       += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            System.Windows.Forms.Application.ThreadException += new ThreadExceptionEventHandler(MainWnd_UIThreadException);

            Event clsEvent = new Event();

            clsEvent.AddEvent("starting.... loading splash screen...");
            SplashWnd appsplash = new SplashWnd();

            clsEvent.AddEventLn("Done!");

            appsplash.prgBar.Maximum = 100;
            appsplash.lblStatus.Text = "Checking OS Version... ";
            appsplash.prgBar.Value   = 10;
            appsplash.Show();
            appsplash.Refresh();

            // get the windows version
            clsEvent.AddEvent("Checking windows current version");
            OSVersion osVersion = OSInformation.getOSVersion();

            switch (osVersion)
            {
            case OSVersion.Windows95:
            case OSVersion.WindowsMe:
                clsEvent.AddEventLn(": " + osVersion.ToString("G"));
                clsEvent.AddEventLn("This OS platform is not supported. Application will now close.");
                MessageBox.Show("FATAL ERROR Level 1.!!! The Operating System : '" + osVersion.ToString("G") + "' is not supported. Application will now close.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                Application.Exit(); return;

            case OSVersion.Windows98:
            case OSVersion.Windows98SecondEdition:
            case OSVersion.WindowsNT351:
            case OSVersion.WindowsNT4:
            case OSVersion.Windows2000:
            case OSVersion.WindowsXP:
            case OSVersion.WindowsVista:
            case OSVersion.Windows7:
                clsEvent.AddEventLn(": " + osVersion.ToString("G"));
                break;

            case OSVersion.Unknown:
                System.OperatingSystem osInfo = System.Environment.OSVersion;
                clsEvent.AddEventLn(": Unidentified: Platform=" + osInfo.Platform.ToString() + " Major Version=" + osInfo.VersionString);
                clsEvent.AddEventLn("This OS platform is not supported. Application will now close.");
                MessageBox.Show("FATAL ERROR Level 1.!!! The Operating System is unidentified by Retailplus Application. System will now close. Platform=" + osInfo.Platform.ToString() + " Version=" + osInfo.VersionString, "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                Application.Exit(); return;
            }


            // get the running version
            appsplash.lblStatus.Text = "Checking application Version... ";
            appsplash.prgBar.Value   = 20;
            appsplash.Show();
            appsplash.Refresh();
            clsEvent.AddEvent("Checking application current version");
            Version curVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

            clsEvent.AddEventLn(":" + curVersion.ToString());

            Version verNewVersion = GetLatestVersion();

            clsEvent.AddEventLn("latest version is " + verNewVersion.ToString(), true);
            // compare the versions
            if (curVersion.CompareTo(verNewVersion) < 0)
            {
                clsEvent.AddEventLn("system will now exit then download the latest version.", true);
                System.Diagnostics.Process.Start("RetailPlus.VersionChecker.exe", "RetailPlus.exe");
                Application.Exit();
                return;
            }
            clsEvent.AddEventLn("This application version is updated.", true);

            appsplash.lblStatus.Text = "Checking connections to database... ";
            appsplash.prgBar.Value   = 30;
            appsplash.Refresh();
            if (!IsDBAlive())
            {
                MessageBox.Show("FATAL ERROR Level 1.!!! Cannot connect to database. Please consult your system administrator immediately...", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
                return;
            }
            appsplash.lblStatus.Text += "DONE!";
            appsplash.Refresh();

            appsplash.lblStatus.Text = "Checking Last Initialization of ZREAD... ";
            appsplash.prgBar.Value   = 50;
            appsplash.Show();
            appsplash.Refresh();
            if (!IsDateLastInitializationOK())
            {
                MessageBox.Show("FATAL ERROR Level 2.!!! System date is behind ZREAD last initialization date. Please adjust SYSTEM DATE!!!", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
                return;
            }
            appsplash.lblStatus.Text += "DONE!";
            appsplash.Refresh();

            appsplash.prgBar.Value   = 70;
            appsplash.lblStatus.Text = "Checking terminal if exist in the database... ";
            appsplash.Refresh();
            string ErrorMessage;

            if (!IsTerminalExist(out ErrorMessage))
            {
                MessageBox.Show(ErrorMessage, "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
                return;
            }
            appsplash.lblStatus.Text += "DONE!";
            appsplash.Refresh();
            appsplash.prgBar.Value   = 100;
            appsplash.lblStatus.Text = "Checking terminal if demo is expired... ";
            appsplash.Refresh();
            if (IsDemoExpired())
            {
                string stHDSeriano = Key.GetHDSerialNo();
                MessageBox.Show(
                    "This copy has been expired. Please contact your nearest software distributor" + Environment.NewLine +
                    "Or call RBS Sales @: " + Environment.NewLine +
                    "          Philippines: +63.947.3215979" + Environment.NewLine +
                    "          Philippines: +63.918.9390926" + Environment.NewLine +
                    "          Philippines: +632.998.7722" + Environment.NewLine +
                    "          Singapore: +658.6519601" + Environment.NewLine +
                    "Or email [email protected]" + Environment.NewLine +
                    "Your HD Serial No. is: " + stHDSeriano, "RetailPlus™ Demo Version", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                Application.Exit();
                return;
            }

            appsplash.lblStatus.Text += "DONE!";
            appsplash.Refresh();
            appsplash.Dispose();
            appsplash.Close();

            Security.AuditTrailDetails clsAuditDetails = new Security.AuditTrailDetails();
            clsAuditDetails.BranchID     = Constants.TerminalBranchID;
            clsAuditDetails.TerminalNo   = CompanyDetails.TerminalNo;
            clsAuditDetails.ActivityDate = DateTime.Now;
            clsAuditDetails.User         = "******";
            clsAuditDetails.IPAddress    = System.Net.Dns.GetHostName();
            clsAuditDetails.Activity     = "Open Terminal";
            clsAuditDetails.Remarks      = "FE:" + "Open terminal no.:'" + CompanyDetails.TerminalNo + "' @ Branch:" + Constants.TerminalBranchID.ToString();

            Security.AuditTrail clsAuditTrail = new Security.AuditTrail();
            clsAuditTrail.Insert(clsAuditDetails);

            Data.Terminal        clsTerminal        = new Data.Terminal(clsAuditTrail.Connection, clsAuditTrail.Transaction);
            Data.TerminalDetails clsTerminalDetails = clsTerminal.Details(Constants.TerminalBranchID, CompanyDetails.TerminalNo);

            //overwrite the companydetails from the database
            Data.SysConfig        clsSysConfig        = new Data.SysConfig(clsAuditTrail.Connection, clsAuditTrail.Transaction);
            Data.SysConfigDetails clsSysConfigDetails = clsSysConfig.get_SysConfigDetails();
            clsAuditTrail.CommitAndDispose();

            CompanyDetails.CompanyCode = string.IsNullOrEmpty(clsSysConfigDetails.CompanyCode) ? CompanyDetails.CompanyCode : clsSysConfigDetails.CompanyCode;
            CompanyDetails.CompanyName = string.IsNullOrEmpty(clsSysConfigDetails.CompanyName) ? CompanyDetails.CompanyName : clsSysConfigDetails.CompanyName;
            CompanyDetails.Currency    = string.IsNullOrEmpty(clsSysConfigDetails.Currency) ? CompanyDetails.Currency : clsSysConfigDetails.Currency;
            CompanyDetails.TIN         = string.IsNullOrEmpty(clsSysConfigDetails.TIN) ? CompanyDetails.TIN : clsSysConfigDetails.TIN;

            CompanyDetails.Address1     = string.IsNullOrEmpty(clsSysConfigDetails.Address1) ? CompanyDetails.Address1 : clsSysConfigDetails.Address1;
            CompanyDetails.Address2     = string.IsNullOrEmpty(clsSysConfigDetails.Address2) ? CompanyDetails.Address2 : clsSysConfigDetails.Address2;
            CompanyDetails.City         = string.IsNullOrEmpty(clsSysConfigDetails.City) ? CompanyDetails.City : clsSysConfigDetails.City;
            CompanyDetails.State        = string.IsNullOrEmpty(clsSysConfigDetails.State) ? CompanyDetails.State : clsSysConfigDetails.State;
            CompanyDetails.Zip          = string.IsNullOrEmpty(clsSysConfigDetails.Zip) ? CompanyDetails.Zip : clsSysConfigDetails.Zip;
            CompanyDetails.Country      = string.IsNullOrEmpty(clsSysConfigDetails.Country) ? CompanyDetails.Country : clsSysConfigDetails.Country;
            CompanyDetails.OfficePhone  = string.IsNullOrEmpty(clsSysConfigDetails.OfficePhone) ? CompanyDetails.OfficePhone : clsSysConfigDetails.OfficePhone;
            CompanyDetails.DirectPhone  = string.IsNullOrEmpty(clsSysConfigDetails.DirectPhone) ? CompanyDetails.DirectPhone : clsSysConfigDetails.DirectPhone;
            CompanyDetails.FaxPhone     = string.IsNullOrEmpty(clsSysConfigDetails.FaxPhone) ? CompanyDetails.FaxPhone : clsSysConfigDetails.FaxPhone;
            CompanyDetails.MobilePhone  = string.IsNullOrEmpty(clsSysConfigDetails.MobilePhone) ? CompanyDetails.MobilePhone : clsSysConfigDetails.MobilePhone;
            CompanyDetails.EmailAddress = string.IsNullOrEmpty(clsSysConfigDetails.EmailAddress) ? CompanyDetails.EmailAddress : clsSysConfigDetails.EmailAddress;
            CompanyDetails.WebSite      = string.IsNullOrEmpty(clsSysConfigDetails.WebSite) ? CompanyDetails.WebSite : clsSysConfigDetails.WebSite;

            try
            {
                clsEvent.AddEventLn("Running Main Window.", true);

                MainWnd appmain = new MainWnd();
                appmain.Text = " RetailPlus ™";

                /********************************
                 * Added December 21, 2008
                 * Enable 2 windows in one computer
                 * *****************************/
                try
                {
                    if (clsTerminalDetails.MultiInstanceEnabled)
                    {
                        Application.Run(appmain);
                    }
                    else
                    {
                        SingleInstance.Run(appmain);
                    }
                }
                catch (Exception exMain)
                {
                    clsEvent.AddEventLn("System has excountered an error while loading main screen!" + Environment.NewLine + exMain.ToString(), true);
                    clsEvent.AddEventLn("System has been exited!", true);
                    throw (exMain);
                }

                clsEvent.AddEventLn("System has been exited!", true);

                clsAuditDetails              = new Security.AuditTrailDetails();
                clsAuditDetails.BranchID     = Constants.TerminalBranchID;
                clsAuditDetails.TerminalNo   = CompanyDetails.TerminalNo;
                clsAuditDetails.ActivityDate = DateTime.Now;
                clsAuditDetails.User         = "******";
                clsAuditDetails.IPAddress    = System.Net.Dns.GetHostName();
                clsAuditDetails.Activity     = "Close Terminal";
                clsAuditDetails.Remarks      = "FE:" + "Close terminal no.:'" + CompanyDetails.TerminalNo + "' @ Branch:" + Constants.TerminalBranchID.ToString() + ".";

                clsAuditTrail = new Security.AuditTrail();
                clsAuditTrail.Insert(clsAuditDetails);
                clsAuditTrail.CommitAndDispose();
            }
            catch (Exception ex)
            {
                clsEvent.AddErrorEventLn(ex);

                MessageBox.Show("FATAL ERROR Level 1.!!! An internal error has occurred in the system. Please consult your system administrator immediately...", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
        }
Exemplo n.º 30
0
 private void OnClose(object sender, RoutedEventArgs e)
 {
     MainWnd.Close();
 }
Exemplo n.º 31
0
 private void OnTitleBarDrag(object sender, MouseButtonEventArgs e)
 {
     MainWnd.DragMove();
 }