Exemple #1
0
        private void btnXlsLoad_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog dial = new OpenFileDialog();

                dial.Multiselect = false;
                dial.ShowDialog();

                string strFileName = dial.FileName;

                dial.Dispose();

                if (strFileName == string.Empty)
                {
                    return;
                }

                strFileName = strFileName.Replace(@"\\", @"\");

                //strFileName = @".\chasys.xls";


                clsOleDB clsOle = new clsOleDB(enProvider.Excel, strFileName, string.Empty, string.Empty, string.Empty);

                using (DataSet ds = clsOle.dsExcute_Query("select orderdate, partcode, target_cnt from [order$]"))
                {
                    if (ds.Tables[0].Rows.Count < 1)
                    {
                        return;
                    }

                    lstPlan.Items.Clear();
                    ResetInput();

                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        lstPlan.Items.Add(new ListViewItem(new string[] { (lstPlan.Items.Count + 1).ToString(),
                                                                          clsFunction.Null2String(dr["ORDERDATE"]),
                                                                          clsFunction.Null2String(dr["PARTCODE"]),
                                                                          clsFunction.Null2String(dr["TARGET_CNT"]) }));
                    }
                }
            }
            catch (Exception ex)
            {
                clsLog.WLog_Exception("btnXlsLoad", ex);
                clsFunction.ShowMsg(this, ex.Message, string.Empty, frmMessage.enMessageType.OK);
            }
        }