Exemplo n.º 1
0
 private void LoadData(string Tab)
 {
     dt = SQLITE.SQL_Table("*", "" + Tab + "", "");
     dtEdit.Columns.Clear();
     dtEdit.DataSource = dt;
     for (int i = 0; i < dtEdit.Columns.Count; i++)
     {
         dtEdit.Columns[i].Width = 80;
     }
     blChoose = true;
 }
Exemplo n.º 2
0
        private void Main_Load(object sender, EventArgs e)
        {
            // G.sourceSQL = G.defautSQL;
            // SQLITE.DeleteAll("INFOR");
            lbDate.Text           = DateTime.Now.ToString("dd/MM/yyyy");
            cbShift.SelectedIndex = 0;
            G.wScreen             = Screen.PrimaryScreen.Bounds.Width;
            G.hScreen             = Screen.PrimaryScreen.Bounds.Height;
            this.Location         = new Point(G.wScreen / 2 - this.Width / 2, G.hScreen / 2 - this.Height / 2);
            listPro     = new List <string>();
            G.sourceSQL = G.defautSQL;
            DataTable dt = SQLITE.SQL_Table("*", "INFOR", "");

            listPro  = SQLITE.SQL_List(1, dt);
            listPath = new List <string>();
            listPath = SQLITE.SQL_List(2, dt);
            List <string> listSelect = new List <string>();

            listSelect = SQLITE.SQL_List(3, dt);
            cbProgram.Items.Clear();
            int i = 0;

            foreach (string s in listPro)
            {
                cbProgram.Items.Add(s);
                if (listSelect[i] == "1")
                {
                    cbProgram.SelectedIndex = i;
                    G.pathSQL  = listPath[i];
                    G.editTile = listPro[i];
                }
                i++;
            }
            cbProgram.Items.Add("New Program");
        }
Exemplo n.º 3
0
        private void LoadData(string Tab)
        {
            dt = cSQL.SQL_Table("*", "" + Tab + "", "");
            fm1.dtEdit.Columns.Clear();
            fm1.dtEdit.DataSource = dt;
            for (int i = 0; i < fm1.dtEdit.Columns.Count; i++)
            {
                fm1.dtEdit.Columns[i].Width = 80;
            }

            /*
             * if (Tab == "TYPE")
             * {
             *  cbType.DataSource = new BindingSource(SQL_List(0, dt), null);
             *  cbType.SelectedIndex = -1;
             * }
             * else if (Tab == "CO")
             * {
             *  cbCo.DataSource = new BindingSource(SQL_List(1, dt), null);
             *  cbCo.SelectedIndex = -1;
             * }
             * else if (Tab == "MOD")
             * {
             * }
             * else if (Tab == "AREA")
             * {
             *
             * //   cbArea.DataSource = new BindingSource(SQL_List(1, dt), null);
             * //  cbArea.SelectedIndex = -1;
             * }
             * else if (Tab == "BIT")
             * {
             *
             *  cbBit.DataSource = new BindingSource(SQL_List(1, dt), null);
             *  cbBit.SelectedIndex = -1;
             * }*/
        }
Exemplo n.º 4
0
        public LoadSQLITE(int wMap)
        {
            G.LisDevice     = new List <string>();
            G.LisPLC        = new List <LisPLC>();
            G.ListGraphic   = new List <ListGraphic>();
            G.ListVariables = new List <ListVariables>();
            G.ListToolGr    = new List <ToolGr>();
            G.ListToolChart = new List <GRAPHIC.ToolChart>();
            G.ListToolTemp  = new List <ToolGr>();
            G.pPen          = new Point(0, 0);
            G.sourceSQL     = G.VariableSQL;
            DataTable dtCycleTime           = new DataTable();
            DataTable dtYield               = new DataTable();
            DataTable dtLostTime            = new DataTable();
            DataTable dtToolQua             = new DataTable();
            DataTable dtToolTime            = new DataTable();
            DataTable dtChart               = new DataTable();
            DataTable dtDevice              = new DataTable();
            DataTable dtVariable            = new DataTable();
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("isCycle", isCycle.open.ToString());
            SQLITE.Update("CycleTime", dic, "", G.VariableSQL);
            dtDevice    = SQLITE.SQL_Table("*", "DEVICE", "");
            dtVariable  = SQLITE.SQL_Table("*", "Global", "");
            dtCycleTime = SQLITE.SQL_Table("*", "CycleTime", "");
            dtYield     = SQLITE.SQL_Table("*", "Yield", "");
            dtLostTime  = SQLITE.SQL_Table("*", "LostTime", "");
            G.sourceSQL = G.ToolSQL;
            // SQLITE.DeleteAll("CHART");
            //   SQLITE.DeleteAll("Quantity");
            //   SQLITE.DeleteAll("Time");
            //SQLITE.DeleteAll("TOOL");
            //SQLITE.Delete("TOOL", "TYPE='Yield'");
            dtToolQua   = SQLITE.SQL_Table("*", "Quantity", "");
            dtToolTime  = SQLITE.SQL_Table("*", "Time", "");
            G.sourceSQL = G.ChartSQL;
            dtChart     = SQLITE.SQL_Table("*", "CHART", "");
            G.sourceSQL = G.VariableSQL;
            foreach (DataRow DataRow in dtDevice.Rows)
            {
                AxDBCommManager plcTemp = new AxDBCommManager();

                DBPlcId eModel = (DBPlcId)Enum.Parse(typeof(MOD), DataRow[3].ToString().Replace("-", ""));

                Via eVia = (Via)Enum.Parse(typeof(Via), DataRow[4].ToString());


                //   plcTemp = KEYENCEs.Create(eModel, eVia, DataRow[5].ToString());
                if (G.isConnect == isConnect.Disconnected)
                {
                    blConnect = false;
                }
                Image picModel, picVia;

                picModel = Image.FromFile(DataRow[3].ToString() + ".png");
                picVia   = Image.FromFile(DataRow[4].ToString() + ".png");
                G.LisPLC.Add(new LisPLC(DataRow[0].ToString(), DataRow[2].ToString(), DataRow[3].ToString(), eVia, DataRow[5].ToString(), plcTemp, G.isConnect, picModel, picVia, G.pPen));
                G.pPen.X += G.spicReview.X + 10;
                if (G.pPen.X + G.spicReview.X >= wMap)
                {
                    G.pPen.Y += G.spicReview.Y + 50;
                    G.pPen.X  = 0;
                }
            }
            foreach (DataRow DataRow in dtVariable.Rows)
            {
                isBit   isBit   = (isBit)Enum.Parse(typeof(isBit), DataRow[6].ToString());
                typeBit typeBit = (typeBit)Enum.Parse(typeof(typeBit), DataRow[4].ToString());
                int     i       = 0;
                int     index   = 0;
                foreach (DataRow DataRow1 in dtDevice.Rows)
                {
                    if (DataRow1[0].ToString() == DataRow[1].ToString())
                    {
                        index = i;
                    }
                    i++;
                }
                G.ListVariables.Add(new ListVariables(DataRow[0].ToString(), G.LisPLC[index], DataRow[2].ToString(), DataRow[3].ToString(), DataRow[5].ToString(), isBit, typeBit, typeVariable2.Global));
            }
            foreach (DataRow DataRow in dtCycleTime.Rows)
            {
                int i     = 0;
                int index = 0;
                foreach (DataRow DataRow1 in dtVariable.Rows)
                {
                    if (DataRow1[0].ToString() == DataRow[1].ToString())
                    {
                        index = i;
                    }
                    i++;
                }

                G.ListVariables.Add(new ListVariables(new CycleTime(DataRow[0].ToString(), G.ListVariables[index], DataRow[2].ToString(), int.Parse(DataRow[3].ToString()), int.Parse(DataRow[4].ToString()), new DateTime(), new DateTime(), isCycle.open, false), typeVariable2.CycleTime));
                //  LoadData("CycleTime");
            }
            foreach (DataRow DataRow in dtLostTime.Rows)
            {
                int i     = 0;
                int index = 0;
                foreach (DataRow DataRow1 in dtVariable.Rows)
                {
                    if (DataRow1[0].ToString() == DataRow[1].ToString())
                    {
                        index = i;
                    }
                    i++;
                }
                G.ListVariables.Add(new ListVariables(new LostTime(DataRow[0].ToString(), G.ListVariables[index], DataRow[2].ToString(), int.Parse(DataRow[3].ToString()), int.Parse(DataRow[4].ToString()), new DateTime(), new DateTime(), isLost.open, false), typeVariable2.LostTime));
            }

            foreach (DataRow DataRow in dtYield.Rows)
            {
                int    i = 0;
                int    index = 0;
                string ListOKsql = "", ListNGsql = "";
                ListOKsql = DataRow[2].ToString();
                ListNGsql = DataRow[3].ToString();
                string[]             ListOKsplit = ListOKsql.Split(',');
                string[]             ListNGsplit = ListNGsql.Split(',');
                List <ListVariables> ListYieldOK = new List <ListVariables>();
                List <ListVariables> ListYieldNG = new List <ListVariables>();
                foreach (ListVariables ListVariables in G.ListVariables)
                {
                    foreach (string ListOK in ListOKsplit)
                    {
                        if (ListVariables.Name == ListOK)
                        {
                            ListYieldOK.Add(ListVariables);
                        }
                    }
                    foreach (string ListNG in ListNGsplit)
                    {
                        if (ListVariables.Name == ListNG)
                        {
                            ListYieldNG.Add(ListVariables);
                        }
                    }
                }
                foreach (DataRow DataRow1 in dtVariable.Rows)
                {
                    if (DataRow1[0].ToString() == DataRow[1].ToString())
                    {
                        index = i;
                    }
                    i++;
                }
                //Color red = Color.FromName("Red");
                G.ListVariables.Add(new ListVariables(new Yield(DataRow[0].ToString(), DataRow[1].ToString(), ListYieldOK, ListYieldNG), typeVariable2.Yield));
            }
            foreach (DataRow DataRow in dtToolQua.Rows)
            {
                var    cvt   = new FontConverter();
                String color = DataRow[5].ToString();
                Font   fonts = new Font("Arial", 10);
                try
                {
                    fonts = cvt.ConvertFromString(DataRow[6].ToString()) as Font;
                }
                catch (Exception)
                {
                }
                String Fcolor = DataRow[7].ToString();
                color = color.Replace("Color [A=", "");
                color = color.Replace("]", "");
                color = color.Replace("Color [", "");
                color = color.Replace("R=", "");
                color = color.Replace("G=", "");
                color = color.Replace("B=", "");

                Fcolor = Fcolor.Replace("Color ", "");
                Fcolor = Fcolor.Replace("]", "");
                Fcolor = Fcolor.Replace("[", "");



                string[] splColor = color.Split(',');
                // string[] splFcolor = Fcolor.Split(',');

                SolidBrush backcolor;
                try
                {
                    backcolor = new SolidBrush(Color.FromArgb(int.Parse(splColor[0]), int.Parse(splColor[1]), int.Parse(splColor[2]), int.Parse(splColor[3])));
                }
                catch (Exception)
                {
                    backcolor = new SolidBrush(Color.FromName(color));
                }
                Color      fontColor = Color.FromName(Fcolor);
                FontDialog fontDlg   = new FontDialog();
                fontDlg.Color = fontColor;
                fontDlg.Font  = fonts;
                int i     = 0;
                int index = 0;
                foreach (ListVariables ListVariables in G.ListVariables)
                {
                    if (ListVariables.Name != null)
                    {
                        if (ListVariables.Name.ToString() == DataRow[2].ToString())
                        {
                            index = i;
                        }
                    }
                    else
                    {
                        if (ListVariables.Yield != null)
                        {
                            if (ListVariables.Yield.Name.ToString() == DataRow[2].ToString())
                            {
                                index = i;
                            }
                        }
                    }
                    i++;
                }
                //string Name,string sShow,TypeGr TypeGr,ListVariables ListVariables, Brush brFont,Color BackColor,int sizeFont,int defaut,Font font,bool isChar,bool isVal,bool isConst)
                TypeGr typeGr = (TypeGr)Enum.Parse(typeof(TypeGr), DataRow[1].ToString());
                G.ListToolGr.Add(new ToolGr(DataRow[0].ToString(), DataRow[3].ToString(), typeGr, G.ListVariables[index], new SolidBrush(fontDlg.Color), backcolor, int.Parse(DataRow[4].ToString()), int.Parse(DataRow[11].ToString()), fontDlg.Font, Boolean.Parse(DataRow[8].ToString()), Boolean.Parse(DataRow[9].ToString()), Boolean.Parse(DataRow[10].ToString())));
            }
            foreach (DataRow DataRow in dtToolTime.Rows)
            {
                var    cvt   = new FontConverter();
                String color = DataRow[5].ToString();
                Font   fonts = new Font("Arial", 10);
                try
                {
                    fonts = cvt.ConvertFromString(DataRow[6].ToString()) as Font;
                }
                catch (Exception)
                {
                }

                String Fcolor = DataRow[7].ToString();
                color = color.Replace("Color [A=", "");
                color = color.Replace("]", "");
                color = color.Replace("Color [", "");
                color = color.Replace("R=", "");
                color = color.Replace("G=", "");
                color = color.Replace("B=", "");

                Fcolor = Fcolor.Replace("Color ", "");
                Fcolor = Fcolor.Replace("]", "");
                Fcolor = Fcolor.Replace("[", "");



                string[] splColor = color.Split(',');
                // string[] splFcolor = Fcolor.Split(',');

                SolidBrush backcolor;
                try
                {
                    backcolor = new SolidBrush(Color.FromArgb(int.Parse(splColor[0]), int.Parse(splColor[1]), int.Parse(splColor[2]), int.Parse(splColor[3])));
                }
                catch (Exception)
                {
                    backcolor = new SolidBrush(Color.FromName(color));
                }
                Color      fontColor = Color.FromName(Fcolor);
                FontDialog fontDlg   = new FontDialog();
                fontDlg.Color = fontColor;
                fontDlg.Font  = fonts;
                int i     = 0;
                int index = 0;
                foreach (ListVariables ListVariables in G.ListVariables)
                {
                    if (ListVariables.CycleTime != null)
                    {
                        if (ListVariables.CycleTime.Name.ToString() == DataRow[2].ToString())
                        {
                            index = i;
                        }
                    }
                    else
                    {
                        //  if (ListVariables.LostTime.Name.ToString() == DataRow[2].ToString())
                        //  {

                        //     index = i;
                        //  }
                    }
                    i++;
                }
                //string Name,string sShow,TypeGr TypeGr,ListVariables ListVariables, Brush brFont,Color BackColor,int sizeFont,int defaut,Font font,bool isChar,bool isVal,bool isConst)
                TypeGr typeGr = (TypeGr)Enum.Parse(typeof(TypeGr), DataRow[1].ToString());
                G.ListToolGr.Add(new ToolGr(DataRow[0].ToString(), DataRow[3].ToString(), typeGr, G.ListVariables[index], new SolidBrush(fontDlg.Color), backcolor, Convert.ToDouble(DataRow[12].ToString()), fontDlg.Font, Boolean.Parse(DataRow[8].ToString()), Boolean.Parse(DataRow[9].ToString()), Boolean.Parse(DataRow[10].ToString())));
            }
            List <ToolChart> ToolChart = new List <GRAPHIC.ToolChart>();
            List <string>    ListNameChart = new List <string>();
            string           nameChart = ""; DateTime dtBegin = new DateTime(); int Reset = 0, Update = 0; Point pOffset = new Point();
            int indexRow = 0;

            foreach (DataRow DataRow in dtChart.Rows)
            {
                if (DataRow[0].ToString() != nameChart && nameChart != "")
                {
                    G.ListGraphic.Add(new ListGraphic(nameChart, ToolChart, G.ListData, dtBegin, Reset, Update, int.Parse(DataRow[5].ToString()), pOffset, int.Parse(DataRow[8].ToString()), bool.Parse(DataRow[9].ToString())));
                    ToolChart = new List <GRAPHIC.ToolChart>();
                }

                //  ToolChart.Clear();
                int i     = 0;
                int index = 0;
                foreach (ToolGr ToolGr in G.ListToolGr)
                {
                    if (DataRow[1].ToString() == ToolGr.Name)
                    {
                        string[] ChartPoint = DataRow[6].ToString().Split(',');
                        ToolChart.Add(new ToolChart(ToolGr, new Point(int.Parse(ChartPoint[0]), int.Parse(ChartPoint[1]))));
                    }
                    i++;
                }
                G.ListData = new List <List <ListData> >();
                dtBegin    = DateTime.Parse(DataRow[2].ToString());
                dtBegin.AddYears(DateTime.Now.Year - dtBegin.Year);
                dtBegin.AddMonths(DateTime.Now.Month - dtBegin.Month);
                dtBegin.AddDays(DateTime.Now.Day - dtBegin.Day);
                Reset           = int.Parse(DataRow[3].ToString());
                Update          = int.Parse(DataRow[4].ToString());
                G.ListToolChart = ToolChart;
                UpdateGraphic(Reset, Update);


                string[] pOffsetSplit = DataRow[7].ToString().Split(',');
                pOffset = new Point(int.Parse(pOffsetSplit[0]), int.Parse(pOffsetSplit[1]));

                nameChart = DataRow[0].ToString();
                indexRow++;
                if (indexRow == dtChart.Rows.Count)
                {
                    G.ListGraphic.Add(new ListGraphic(nameChart, ToolChart, G.ListData, dtBegin, Reset, Update, int.Parse(DataRow[5].ToString()), pOffset, int.Parse(DataRow[8].ToString()), bool.Parse(DataRow[9].ToString())));
                }
            }
        }