Esempio n. 1
0
        public void setMarkPoint_LKdata()
        {
            LinhKienData temData = (LinhKienData)LKListImport.BindingSourceLK.Current;

            markPoint_set = temData;
            //markPoint_set.Value = Constant_LK.VALUE_DEFAULT;
        }
Esempio n. 2
0
 public LinhKienManager()
 {
     LKListImport   = new LinhKienItem();
     LKListExport   = new LinhKienItem();
     LKitems        = new LinhKienItem();
     PartListImport = new PartItem();
     markPoint_set  = new LinhKienData();
 }
Esempio n. 3
0
 public LinhKienData(LinhKienData data_)
 {
     Posistion = data_.Posistion;
     MidX      = data_.MidX;
     MidY      = data_.MidY;
     AngelNew  = data_.AngelNew;
     AngelOld  = data_.AngelOld;
     Value     = data_.Value;
     ValueOld  = data_.ValueOld;
     FootPrint = data_.FootPrint;
 }
Esempio n. 4
0
        public void ExportLinhKienToPanelLine(LinhKienItem dt, float _longX, float _longY, int _numberX, int _numberY)
        {
            if (dt.BindingSourceLK.Count < 1)
            {
                return;
            }

            LKListExport.BindingSourceLK.Clear();

            int temCount = 0;

            for (int cf_y = 0; cf_y < _numberY; cf_y++)
            {
                for (int cf_x = 0; cf_x < _numberX; cf_x++)
                {
                    temCount++;

                    foreach (LinhKienData temLKData in dt.BindingSourceLK)
                    {
                        // remote mm
                        LinhKienData temDataExport = new LinhKienData(temLKData);

                        float temMidX = Convert.ToSingle(temLKData.MidX.Remove(temLKData.MidX.IndexOf("mm")));
                        float temMidY = Convert.ToSingle(temLKData.MidY.Remove(temLKData.MidY.IndexOf("mm")));

                        temMidX = temMidX + _longX * cf_x;
                        temMidY = temMidY - _longY * cf_y;  // n30/11/2019  Y phải nhỏ dần
                        //temMidY = temMidY + _longY * cf_y;

                        temDataExport.Posistion = string.Format("{0}_{1}", temCount, temLKData.Posistion);
                        //temDataExport.Posistion = string.Format("{0}_{1}", temLKData.Posistion, temCount);
                        //temDataExport.AngelNew = temLKData.AngelNew;
                        //temDataExport.AngelOld = temLKData.AngelOld;
                        //temDataExport.Value = temLKData.Value;
                        //temDataExport.ValueOld = temLKData.ValueOld;
                        temDataExport.MidX = string.Format("{0}mm", temMidX);
                        temDataExport.MidY = string.Format("{0}mm", temMidY);


                        LKListExport.BindingSourceLK.Add(temDataExport);
                    }
                }
            }
            LKListExport.BindingSourceLK.ResetBindings(true);
        }
Esempio n. 5
0
        public void WriteLinhKienItemToTxt(LinhKienItem dt, string strFilePath)
        {
            using (var sw = new StreamWriter(strFilePath))
            {
                #region xuat txt file chuẩn Kayo
                LinhKienData temLK1 = new LinhKienData();

                sw.Write(temLK1.GetHeaderStringTo_TXT());

                //foreach (LinhKienData temLK in LKListImport.BindingSourceLK)
                foreach (LinhKienData temLK in dt.BindingSourceLK)
                {
                    sw.Write(temLK.GetStringTo_TXT());
                }
                sw.Close();
                #endregion
            }
        }
Esempio n. 6
0
        public void WriteLinhKienItemToCsv(LinhKienItem dt, string strFilePath)
        {
            using (var sw = new StreamWriter(strFilePath))
            {
                #region xuat csv file

                LinhKienData temLK1 = new LinhKienData();

                sw.Write(temLK1.GetHeaderStringTo_Csv());

                foreach (LinhKienData temLK in LKListImport.BindingSourceLK)
                {
                    sw.Write(temLK.GetStringTo_CSV());
                }

                sw.Close();
                #endregion
            }
        }
Esempio n. 7
0
        public void ExportLinhKienToPanelLine_2(LinhKienItem dt, float _longX, float _longY, int _numberX, int _numberY)
        {
            if (dt.BindingSourceLK.Count < 1)
            {
                return;
            }

            if (markPoint_set.Posistion == Constant_LK.POS_DEFAULT)
            {
                MessageBox.Show("Vui lòng set Mark point", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            LKListExport.BindingSourceLK.Clear();

            #region Add Markpoint import & Markpoint Array

            for (int cf_y = 0; cf_y < _numberY; cf_y++)
            {
                for (int cf_x = 0; cf_x < _numberX; cf_x++)
                {
                    if ((cf_x == 0 && cf_y == 0) ||
                        (cf_x == (_numberX - 1) && cf_y == 0) ||
                        (cf_x == 0 && cf_y == (_numberY - 1)) ||
                        (cf_x == (_numberX - 1) && cf_y == (_numberY - 1)))
                    {
                        LinhKienData temLKData = markPoint_set;

                        // remote mm
                        LinhKienData temDataExport = new LinhKienData(temLKData);

                        float temMidX = Convert.ToSingle(temLKData.MidX.Remove(temLKData.MidX.IndexOf("mm")));
                        float temMidY = Convert.ToSingle(temLKData.MidY.Remove(temLKData.MidY.IndexOf("mm")));

                        temMidX = temMidX + _longX * cf_x;
                        temMidY = temMidY - _longY * cf_y;  // n30/11/2019  Y phải nhỏ dần
                                                            //temMidY = temMidY + _longY * cf_y;

                        string temName = "";
                        if ((cf_x == 0) && (cf_y == 0))
                        {
                            temName = string.Format("MarkPoint{0}_{1}", "UP", "L");
                        }
                        else if ((cf_x == (_numberX - 1)) && (cf_y == 0))
                        {
                            temName = string.Format("MarkPoint{0}_{1}", "UP", "R");
                        }
                        else if ((cf_x == 0) && (cf_y == (_numberY - 1)))
                        {
                            temName = string.Format("MarkPoint{0}_{1}", "DOWN", "L");
                        }
                        else if ((cf_x == (_numberX - 1)) && (cf_y == (_numberY - 1)))
                        {
                            temName = string.Format("MarkPoint{0}_{1}", "DOWN", "R");
                        }
                        else
                        {
                            ;
                        }

                        temDataExport.Posistion = string.Format("{0}_{1}", temName, temLKData.Posistion);
                        temDataExport.MidX      = string.Format("{0}mm", temMidX);
                        temDataExport.MidY      = string.Format("{0}mm", temMidY);
                        temDataExport.Value     = Constant_LK.VALUE_DEFAULT;


                        LKListExport.BindingSourceLK.Add(temDataExport);
                    }
                }
            }

            #endregion Add Markpoint import & Markpoint Array

            int temCount = 0;

            //for (int cf_y = 0; cf_y < _numberY; cf_y++)
            //{
            //    for (int cf_x = 0; cf_x < _numberX; cf_x++)
            //    {
            //        temCount++;

            foreach (LinhKienData temLKData in dt.BindingSourceLK)
            {
                // remote mm
                LinhKienData temDataExport = new LinhKienData(temLKData);

                //float temMidX = Convert.ToSingle(temLKData.MidX.Remove(temLKData.MidX.IndexOf("mm")));
                //float temMidY = Convert.ToSingle(temLKData.MidY.Remove(temLKData.MidY.IndexOf("mm")));

                //temMidX = temMidX + _longX * cf_x;
                //temMidY = temMidY - _longY * cf_y;  // n30/11/2019  Y phải nhỏ dần
                //temMidY = temMidY + _longY * cf_y;

                //temDataExport.Posistion = string.Format("{0}_{1}", temCount, temLKData.Posistion);

                //temDataExport.MidX = string.Format("{0}mm", temMidX);
                //temDataExport.MidY = string.Format("{0}mm", temMidY);


                LKListExport.BindingSourceLK.Add(temDataExport);
            }
            //    }
            //}
            LKListExport.BindingSourceLK.ResetBindings(true);
        }
Esempio n. 8
0
        public DataTable ReadCsvFileToLinhKien(string file)
        {
            DataTable dt = new DataTable();

            using (StreamReader streamReader = new StreamReader(file))
            {
                while (!streamReader.EndOfStream)
                {
                    string   text = streamReader.ReadToEnd();
                    string[] rows = text.Split('\n');
                    if (rows.Length > 0)
                    {
                        LKListImport.BindingSourceLK.Clear();

                        //Add columns
                        string[] columns = rows[0].Split(',');
                        for (int j = 0; j < columns.Count(); j++)
                        {
                            dt.Columns.Add(columns[j]);
                        }

                        //Add rows
                        for (int i = 1; i < rows.Count() - 1; i++)
                        {
                            string[]     data        = rows[i].Split(',');
                            DataRow      dr          = dt.NewRow();
                            LinhKienData temLinhKien = new LinhKienData();

                            for (int k = 0; k < data.Count(); k++)
                            {
                                #region Lấy data Linh kiện dang Import
                                string temData = data[k];
                                if (data[k].IndexOf("\r") > -1)
                                {
                                    temData = data[k].Remove(data[k].IndexOf('\r'));
                                }

                                if (columns[k].IndexOf(Constant_LK.Posistion) > -1)
                                {
                                    temLinhKien.Posistion = temData;
                                }
                                else if (columns[k].IndexOf(Constant_LK.MidX) > -1)
                                {
                                    temLinhKien.MidX = temData;
                                }
                                else if (columns[k].IndexOf(Constant_LK.MidY) > -1)
                                {
                                    temLinhKien.MidY = temData;
                                }
                                else if (columns[k].IndexOf(Constant_LK.AngelOld) > -1)
                                {
                                    temLinhKien.AngelOld = temData;
                                }
                                else if (columns[k].IndexOf(Constant_LK.Value) > -1)
                                {
                                    temLinhKien.Value = temData;
                                    if (temLinhKien.ValueOld == "NoValueOld")
                                    {
                                        temLinhKien.ValueOld = temData;
                                    }
                                    //temLinhKien.FootPrint = temData;
                                }
                                else if (columns[k].IndexOf(Constant_LK.ValueOld) > -1)
                                {
                                    temLinhKien.ValueOld = temData;
                                }
                                #endregion
                                dr[k] = temData;
                            }

                            LKListImport.BindingSourceLK.Add(temLinhKien);     // Add linh kiện vừa Import
                            //LKListImport.BindingSourceLK.Sort = "ValueOld ASC, Posistion DESC";
                            //LKListImport.BindingSourceLK.Sort = "MidX DESC, Posistion DESC";
                            //LKListImport.BindingSourceLK.Sort = "ValueOld ASC";
                            dt.Rows.Add(dr);
                        }
                    }
                }
            }
            markPoint_set.Posistion = Constant_LK.POS_DEFAULT; // Reset markPoint_set

            //MessageBox.Show(string.Format("Sort status: {0}", LKListImport.BindingSourceLK.SupportsAdvancedSorting));
            //LKListImport.BindingSourceLK.Sort = "ValueOld ASC";
            return(dt);
        }