Пример #1
0
        public bool UpdateBJ(VBJ BJ)
        {
            String BJTable = BJ.GetType().Name;
            var    res     = mapper.Update(String.Format("Update{0}", BJTable), BJ);

            return(res > 0);
        }
Пример #2
0
        public bool InsertBJ(VBJ BJ)
        {
            String BJTable = BJ.GetType().Name;

            mapper.Insert(String.Format("Insert{0}", BJTable), BJ);
            return(BJ.ID > 0);
        }
Пример #3
0
        protected override void OnClose()
        {
            //comm.StopScan();
            //pcbComm.StopScan();
            engine.exit();
            if (engine.work_thread != null)
            {
                engine.work_thread.Join();
            }
            CanComm.OnError -= Comm_OnError;
            CanComm.Close();
            if (System.Windows.Application.Current.ShutdownMode == System.Windows.ShutdownMode.OnMainWindowClose)
            {
                TraceService.InsertT_Trace(TraceLevelEnum.LowImportant, "关闭主程序");
            }
            else
            {
                TraceService.InsertT_Trace(TraceLevelEnum.LowImportant, "注销");
            }

            foreach (var key in Constants.BJDict.Keys)
            {
                switch (key)
                {
                case "T_BJ_DeepPlate":
                {
                    VBJ.SaveConfig(Constants.BJDict[key]);
                    break;
                }
                }
            }

            base.OnClose();
            System.Environment.Exit(0);
        }
Пример #4
0
 public void Save()
 {
     if (Constants.BJDict.ContainsKey(Key))
     {
         var list = Constants.BJDict[Key];
         for (int i = 0; i < list.Count; i++)
         {
             var item = list[i];
             if (item is VBJ vbj)
             {
                 var p = typeof(DGContent).GetProperty("Y" + (i));
                 if (p == null)
                 {
                     break;
                 }
                 var count = vbj.Values.GetLength(0);
                 for (int x = 0; x < Math.Min(count, DataList.Count); x++)
                 {
                     vbj.SetValue(x, 0, p.GetValue(DataList[x]));
                 }
             }
         }
         VBJ.SaveConfig(Constants.BJDict[Key]);
         this.View.ShowHint(new MessageWin());
         Engine.getInstance().InitRes();
     }
 }
Пример #5
0
        public bool DeleteBJ(VBJ BJ)
        {
            Hashtable ht = new Hashtable();

            ht.Add("TableName", GetPgTable(BJ));//BJ.GetType().Name);
            ht.Add("ID", BJ.ID);
            return(mapper.Delete("DeleteBJ", ht) > 0);
        }
Пример #6
0
        private String GetPgTable(VBJ BJ)
        {
            var   name = BJ.GetType().Name;
            Regex reg  = new Regex("([a-z\\d]+)([A-Z]{1})");

            name = name.Replace("T_", "");
            name = reg.Replace(name, "$1_$2");

            return(name);
        }
Пример #7
0
 public bool DeleteBJ(VBJ BJ)
 {
     return(bjDAO.DeleteBJ(BJ));
 }
Пример #8
0
        private Grid InitGrid(VBJ bj)
        {
            var vbj = bj as VBJ;

            if (vbj == null)
            {
                return(null);
            }
            Grid grid = new Grid();

            int X = vbj.Values.GetLength(0);
            int Y = vbj.Values.GetLength(1);

            for (int i = -1; i < X; i++)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new System.Windows.GridLength(i == -1?60:50)
                });
            }
            for (int i = -1; i < Y; i++)
            {
                grid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new System.Windows.GridLength(35)
                });
            }
            for (int i = -1; i < X; i++)
            {
                for (int j = -1; j < Y; j++)
                {
                    Border border = new Border();
                    if (i == -1 || j == -1)
                    {
                        border.Background = new SolidColorBrush(Color.FromRgb(0xF0, 0xF0, 0xF0));
                        border.Name       = String.Format("border_{0}_{1}", i, j).Replace("-", "Z");

                        if (CanSave)
                        {
                            border.MouseLeftButtonDown += Border_MouseLeftButtonDown;
                        }
                    }
                    border.SetValue(Grid.RowProperty, j + 1);
                    border.SetValue(Grid.ColumnProperty, i + 1);
                    border.BorderBrush     = Brushes.Black;
                    border.BorderThickness = new System.Windows.Thickness(1);
                    grid.Children.Add(border);
                    if (i == -1)
                    {
                        TextBlock tb = new TextBlock();
                        if (j == -1)
                        {
                            tb.Text = bj.Name;
                        }
                        else
                        {
                            tb.Text = Letters.ElementAt(j).ToString();
                        }
                        tb.TextAlignment = System.Windows.TextAlignment.Center;
                        tb.Margin        = new System.Windows.Thickness(0, 5, 0, 0);
                        border.Child     = tb;
                    }
                    else
                    {
                        if (j == -1)
                        {
                            TextBlock tb = new TextBlock();
                            tb.Margin        = new System.Windows.Thickness(0, 5, 0, 0);
                            tb.Text          = (i + 1).ToString();
                            tb.TextAlignment = System.Windows.TextAlignment.Center;
                            border.Child     = (tb);
                        }
                        else
                        {
                            string tip_msg = i + "," + j;
                            if (vbj.Values[i, j] is ResInfoData resinfo)
                            {
                                tip_msg += "\n" + resinfo.GetCodeAt(0) + "\n" + resinfo.GetCodeAt(1);
                            }
                            Ellipse ell = new Ellipse();
                            ell.Height          = 30;
                            ell.Width           = 30;
                            ell.ToolTip         = tip_msg;
                            ell.StrokeThickness = 1;
                            ell.Stroke          = Brushes.Black;
                            ell.Name            = String.Format("ell_{0}_{1}", i, j);
                            ell.SetResourceReference(Ellipse.FillProperty, vbj.Values[i, j] == null? "BJFillUnUsed": "BJFillUsed");
                            ell.Tag = vbj.Values[i, j];
                            if (CanSave)
                            {
                                ell.MouseLeave        += Ell_MouseLeave;
                                ell.MouseLeftButtonUp += Ell_MouseLeftButtonUp;
                            }
                            border.Child = ell;
                        }
                    }
                }
            }
            return(grid);
        }
Пример #9
0
 private void InvokeSetValue(VBJ vb, byte x, byte y, Object val)
 {
     Constants.MainWindow.Dispatcher.Invoke(new Action(() => {
         vb.SetValue(x, y, val);
     }));
 }