Exemple #1
0
        /// <summary>
        /// 提交数据,写入csv档
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Register_btn_Click(object sender, EventArgs e)
        {
            //检查barcode是否已经检查
            if (Flag == false)
            {
                error_msg.Text       = "条码格式有误,请重新输入!";
                Output_lbl.ForeColor = Color.Red;
                barcode_txt.SelectAll();
                return;
            }
            else
            {
                error_msg.Text = "";
            }
            //检查是否有选中的NG CODE项
            string ngCode = sNgCode();

            if (ngCode == null)
            {
                error_msg.Text       = "请选择不良原因!";
                Output_lbl.ForeColor = Color.Red;
                panel1.Select();
                return;
            }
            else
            {
                error_msg.Text = "";
            }

            CsvFile csv  = new CsvFile();
            string  path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            #region
            csv.Model = "KK07";
            csv.Site  = "NSTD";

            string      fPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Setting.xml";
            XmlDocument xDoc  = new XmlDocument();
            xDoc.Load(fPath);
            XmlNode nod = xDoc.SelectSingleNode("root");

            XmlNode xNode   = nod.SelectSingleNode("factory");
            string  factory = xNode.Attributes["value"].Value;

            csv.Factory = factory;
            csv.Line    = line_cbx.SelectedItem.ToString();
            csv.Process = process_cbx.SelectedItem.ToString();
            csv.Module  = barcode_txt.Text.ToUpper();
            csv.Module2 = "";
            csv.x2      = "";
            DateTime t1 = System.DateTime.Now;
            csv.Year     = int.Parse(t1.Year.ToString().Substring(2, 2));
            csv.Month    = int.Parse(t1.Month.ToString());
            csv.Day      = int.Parse(t1.Day.ToString());
            csv.Hour     = int.Parse(t1.Hour.ToString());
            csv.Minute   = int.Parse(t1.Minute.ToString());
            csv.Second   = int.Parse(t1.Second.ToString());
            csv.Faci_num = 1;
            //csv.Faci = "PLC";
            csv.Faci        = ngCode;
            csv.faci_value  = 0;
            csv.Item_result = 1;
            csv.All_result  = 1;
            csv.Item_num    = 1;
            //csv.Op_user = _user.user;
            csv.Op_type  = "OPERATOR";
            csv.Op_value = this.user;
            #endregion
            csv.OutPutCsv(path);
            Output_lbl.ForeColor = Color.Lime;
            Output_lbl.Text      = "Output " + csv.Filename + " completed.";
            Flag            = false;
            barErr_lbl.Text = "";

            /*
             * panel1.Click -= new EventHandler(panel1_Click);
             * foreach (RadioButton rad in panel1.Controls)
             * {
             *  rad.Checked = false;
             * }
             * panel1.Click += new EventHandler(panel1_Click);
             */
            barcode_txt.SelectAll();
            barcode_txt.Focus();
            serials = new List <SnClass>();
            LoadserialsDGV();
            //后台ftp上传线程启动
            //ftpUpLoad();
        }
Exemple #2
0
        private void UpLoadData()
        {
            //检查barcode是否已经检查
            if (Flag == false)
            {
                error_msg.Text      = "SN List 是空,不能做上传操作!";
                error_msg.ForeColor = Color.Red;
                barcode_txt.SelectAll();
                return;
            }
            //检查是否有选中的NG CODE项
            string ngCode = sNgCode();

            if (ngCode == null)
            {
                error_msg.Text      = "请选择不良原因!";
                error_msg.ForeColor = Color.Red;
                panel1.Select();
                return;
            }
            CsvFile        csvFile = new CsvFile();
            List <CsvFile> csvs    = new List <CsvFile>();
            string         path    = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            foreach (SnClass s in serials)
            {
                CsvFile csv = new CsvFile();
                #region
                csv.Model = System.Configuration.ConfigurationManager.AppSettings["Model"];//原来固定"KK07";
                csv.Site  = "NSTD";

                string      fPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Setting.xml";
                XmlDocument xDoc  = new XmlDocument();
                xDoc.Load(fPath);
                XmlNode nod = xDoc.SelectSingleNode("root");

                XmlNode xNode   = nod.SelectSingleNode("factory");
                string  factory = xNode.Attributes["value"].Value;

                csv.Factory = factory;
                //csv.Factory = "E-1";
                csv.Line    = line_cbx.SelectedItem.ToString();
                csv.Process = process_cbx.SelectedItem.ToString();
                csv.Module  = s.sn;
                csv.Module2 = "";
                csv.x2      = "";
                DateTime t1 = DateTime.Now;

                //csv.Day = int.Parse(t1.Day.ToString());
                //csv.Hour = int.Parse(t1.Hour.ToString());
                //csv.Minute = int.Parse(t1.Minute.ToString());
                //csv.Second = int.Parse(t1.Second.ToString());

                // modify date 20180615 by fyh
                string   cmbDate = cmbx_date.SelectedItem.ToString();
                string   cmbTime = cmbx_time.SelectedItem.ToString();
                string[] timeArr = cmbTime.Split(':');
                if (cmbDate == "现在")
                {
                    csv.Year   = int.Parse(t1.Year.ToString().Substring(2, 2));
                    csv.Month  = int.Parse(t1.Month.ToString());
                    csv.Day    = int.Parse(t1.Day.ToString());
                    csv.Hour   = int.Parse(t1.Hour.ToString());
                    csv.Minute = int.Parse(t1.Minute.ToString());
                    csv.Second = int.Parse(t1.Second.ToString());
                }
                else if (cmbDate == "昨天")
                {
                    csv.Year   = int.Parse(t1.AddDays(-1).Year.ToString().Substring(2, 2));
                    csv.Month  = int.Parse(t1.AddDays(-1).Month.ToString());
                    csv.Day    = int.Parse(t1.AddDays(-1).Day.ToString());
                    csv.Hour   = int.Parse(timeArr[0].ToString());
                    csv.Minute = int.Parse(timeArr[1].ToString());
                    csv.Second = int.Parse(timeArr[2].ToString());
                }
                else if (cmbDate == "今天")
                {
                    csv.Year   = int.Parse(t1.Year.ToString().Substring(2, 2));
                    csv.Month  = int.Parse(t1.Month.ToString());
                    csv.Day    = int.Parse(t1.Day.ToString());
                    csv.Hour   = int.Parse(timeArr[0].ToString());
                    csv.Minute = int.Parse(timeArr[1].ToString());
                    csv.Second = int.Parse(timeArr[2].ToString());
                }


                csv.Faci_num = 1;
                //csv.Faci = "PLC";
                csv.Faci        = ngCode;
                csv.faci_value  = 0;
                csv.Item_result = 1;
                csv.All_result  = 1;
                csv.Item_num    = 1;
                //csv.Op_user = _user.user;
                csv.Op_type  = "OPERATOR";
                csv.Op_value = this.user;
                csvs.Add(csv);
                #endregion
            }
            if (!csvFile.OutPutCsvLot(path, csvs))
            {
                error_msg.Text      = "提交失败,请重新刷入并提交!";
                error_msg.ForeColor = Color.Red;
                return;
            }

            error_msg.Text      = "Output " + csvFile.Filename + " completed.";
            error_msg.ForeColor = Color.GreenYellow;
            Flag = false;
            //error_msg.Text = "";

            /*
             * panel1.Click -= new EventHandler(panel1_Click);
             * foreach (RadioButton rad in panel1.Controls)
             * {
             *  rad.Checked = false;
             * }
             * panel1.Click += new EventHandler(panel1_Click);
             */
            barcode_txt.Text = "";
            barcode_txt.SelectAll();
            barcode_txt.Focus();
            //后台ftp上传线程启动
            //ftpUpLoad();
        }
Exemple #3
0
        private void UpLoadData()
        {
            //检查barcode是否已经检查
            if (Flag == false)
            {
                Output_lbl.Text      = "条码格式有误,请重新输入请重新输入FYH!";
                Output_lbl.ForeColor = Color.Red;
                barcode_txt.SelectAll();
                return;
            }
            //检查是否有选中的NG CODE项
            string ngCode = sNgCode();

            if (ngCode == null)
            {
                Output_lbl.Text      = "请选择不良原因!";
                Output_lbl.ForeColor = Color.Red;
                panel1.Select();
                return;
            }

            CsvFile csv  = new CsvFile();
            string  path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            #region
            csv.Model   = "KK07";
            csv.Site    = "NSTD";
            csv.Factory = "E-1";
            csv.Line    = line_cbx.SelectedItem.ToString();
            csv.Process = process_cbx.SelectedItem.ToString();
            csv.Module  = barcode_txt.Text.ToUpper();
            csv.Module2 = "";
            csv.x2      = "";
            DateTime t1 = System.DateTime.Now;
            csv.Year     = int.Parse(t1.Year.ToString().Substring(2, 2));
            csv.Month    = int.Parse(t1.Month.ToString());
            csv.Day      = int.Parse(t1.Day.ToString());
            csv.Hour     = int.Parse(t1.Hour.ToString());
            csv.Minute   = int.Parse(t1.Minute.ToString());
            csv.Second   = int.Parse(t1.Second.ToString());
            csv.Faci_num = 1;
            //csv.Faci = "PLC";
            csv.Faci        = ngCode;
            csv.faci_value  = 0;
            csv.Item_result = 1;
            csv.All_result  = 1;
            csv.Item_num    = 1;
            //csv.Op_user = _user.user;
            csv.Op_type  = "OPERATOR";
            csv.Op_value = this.user;
            #endregion
            csv.OutPutCsv(path);
            Output_lbl.ForeColor = Color.Lime;
            Output_lbl.Text      = "Output " + csv.Filename + " completed.";
            Flag            = false;
            barErr_lbl.Text = "";
            panel1.Click   -= new EventHandler(panel1_Click);
            foreach (RadioButton rad in panel1.Controls)
            {
                rad.Checked = false;
            }
            panel1.Click    += new EventHandler(panel1_Click);
            barcode_txt.Text = "";
            barcode_txt.SelectAll();
            barcode_txt.Focus();
            //后台ftp上传线程启动
            //ftpUpLoad();
        }