コード例 #1
0
        private void ip_linenamelist_ItemClick(object sender, EventArgs e)
        {
            try
            {
                List <string> lsValue = new List <string>();
                if (this.ip_linenamelist.SelectedItems.Count > 0)
                {
                    for (int i = 0; i < this.ip_linenamelist.Items.Count; i++)
                    {
                        if ((this.ip_linenamelist.Items[i] as DevComponents.DotNetBar.CheckBoxItem).Checked)
                        {
                            lsValue.Add(this.dicnames[(this.ip_linenamelist.Items[i] as DevComponents.DotNetBar.CheckBoxItem).Text]);
                        }
                    }
                }

                this.dgv_had.DataSource = ClsReadExcel.getTableHad(ClsReadExcel.FileExists(this.mExcleFile), lsValue.ToArray());

                this.dgv_dta.DataSource = ClsReadExcel.getTableDta(ClsReadExcel.FileExists(this.mExcleFile), lsValue.ToArray());
                if (this.dgv_had.Rows.Count > 0)
                {
                    this.dgv_had.Columns["料站数"].Visible = false;
                }
            }
            catch (Exception ex)
            {
                this.mainfrm.ShowPrgMsg(ex.Message, MainParent.MsgType.Warning);
            }
        }
コード例 #2
0
        private void mbt_OpenExcel_Click(object sender, EventArgs e)
        {
            try
            {
                dicnames = new Dictionary <string, string>();
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Title  = "选择料站表";
                ofd.Filter = "(*.xls Excel 2003)|*.xls";
                //ofd.InitialDirectory = "c:\\";
                DialogResult dlr = ofd.ShowDialog();
                if (dlr == DialogResult.Yes || dlr == DialogResult.OK)
                {
                    this.mExcleFile = ofd.FileName;
                    //在打开Excel文档时就去判断文档内容是否符合规则要求
                    List <string> lsnames    = ClsReadExcel.GetTableNames(ClsReadExcel.FileExists(this.mExcleFile));
                    DataTable     mdatatable = new DataTable();
                    string        side       = string.Empty;
                    foreach (string item in lsnames)
                    {
                        side = "T";// item.Split('-')[1].Substring(0, 1);
                        if (item.Split(' ').Length < 2)
                        {
                            throw new Exception("料站表的命名规则不符,请重新修正..");
                        }
                        if (string.IsNullOrEmpty(side))
                        {
                            throw new Exception("文档命名不符合规则(\"产品名称-PCB版面+F\")");
                        }
                        //if ("T" != side && "B" != side)
                        //throw new Exception("文档命名不符合规则(\"产品名称-PCB版面+F\")");

                        //添加Feeder类型
                        string sql = string.Format("select 产品料号,产品描述,机器编号,BOM版本,料站总数,count(*) as 料站数 from [{0}] group by 产品料号,产品描述,机器编号,BOM版本,料站总数 having 机器编号 is not null",
                                                   item);
                        //string sql = string.Format("select 产品料号,产品描述,机器编号,BOM版本,料站总数,count(*) as 料站数 from [{0}] group by 产品料号,产品描述,机器编号,BOM版本,料站总数 having 机器编号 is not null",
                        //    item);
                        mdatatable = ClsReadExcel.getTableForSql(ClsReadExcel.FileExists(this.mExcleFile), sql);

                        this.dicnames.Add(item.Replace('\'', ' ').Replace('$', ' ').Trim(), item);

                        if (mdatatable.Rows.Count > 2)
                        {
                            if (this.ShowMsg("一条生产线的参数设置过多\n默认只支持左边、右边,请重新设置.."))
                            {
                                throw new Exception("一条生产线的参数设置过多,默认只支持左边、右边,请检查料表设置..");
                            }
                        }
                    }

                    //this.dgv_had.DataSource = mdatatable;
                    // this.dgv_had.Columns["料站数"].Visible = false;
                    this.ip_linenamelist.Items.Clear();
                    foreach (string item in this.dicnames.Keys)
                    {
                        this.ip_linenamelist.Items.Add(new DevComponents.DotNetBar.CheckBoxItem(item, item));
                        this.ip_linenamelist.Refresh();
                    }
                    //将料站表上传FTP
                    try
                    {
                        FrmBLL.Ftp_MyFtp ftp = new FrmBLL.Ftp_MyFtp();
                        ftp.PutImage(ofd.FileName);
                    }
                    catch (Exception ex)
                    {
                        this.mainfrm.ShowPrgMsg(ex.Message, MainParent.MsgType.Warning);
                    }
                }
            }
            catch (Exception ex)
            {
                this.mainfrm.ShowPrgMsg(ex.Message, MainParent.MsgType.Error);
            }
        }