예제 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string         constring = "Data Source=" + oracleSid + ";Persist Security Info=True;User ID=" + oracleName + ";Password="******";Unicode=True";
            DBHelperORACLE doo       = new DBHelperORACLE(constring);
            //再尝试转换对应的文件
            Boolean createXmlOk = createXml();

            if (createXmlOk)
            {
                //最后将转换后的数据按地址(GPS)为依据逐个作为这个K号的多个记录导入
                string     path = Application.StartupPath + "\\data.xml";
                byte[]     data;
                FileStream fs = File.OpenRead(path);
                data = new byte[fs.Length];
                fs.Read(data, 0, Convert.ToInt32(fs.Length));
                fs.Close();
                Program.LastError = "";
                DataTable            dt      = CSVFileHelper.OpenCSV(csvPath);
                List <KCT_CASE_INFO> kctList = CSVFileHelper.ToKctList(dt);
                dic = CSVFileHelper.Group(kctList);
                Boolean isOk    = CSVFileHelper.insert(dic, inv_no, constring);
                Boolean XmlisOk = CSVFileHelper.InsertXml(inv_no, data, doo);
                if (isOk && XmlisOk)
                {
                    MessageBox.Show("导入完成!");
                    this.Close();
                }
                else
                {
                    if (!isOk && !XmlisOk)
                    {
                        MessageBox.Show("索引和数据均导入失败!\r\n" + Program.LastError);
                    }
                    else if (!isOk)
                    {
                        MessageBox.Show("索引导入失败!\r\n" + Program.LastError);
                    }
                    else
                    {
                        MessageBox.Show("数据均导入失败!\r\n" + Program.LastError);
                    }
                }
            }
            else
            {
                MessageBox.Show("XML文件生成失败");
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string         constring = "Data Source=" + oracleSid + ";Persist Security Info=True;User ID=" + oracleName + ";Password="******";Unicode=True";
            DBHelperORACLE doo       = new DBHelperORACLE(constring);

            doo.openConn();

            Boolean createXmlOk = createXml();

            if (createXmlOk)
            {
                DataTable            dt      = CSVFileHelper.OpenCSV(csvPath);
                List <KCT_CASE_INFO> kctList = CSVFileHelper.ToKctList(dt);
                dic = CSVFileHelper.Group(kctList);
                Boolean updateOk = CSVFileHelper.update(dic, inv_no, constring);
                string  path     = Application.StartupPath + "\\data.xml";

                byte[]     data;
                FileStream fs = File.OpenRead(path);
                data = new byte[fs.Length];
                fs.Read(data, 0, Convert.ToInt32(fs.Length));
                fs.Close();
                Boolean XmlisOk = CSVFileHelper.InsertXml(inv_no, data, doo);
                if (updateOk && XmlisOk)
                {
                    MessageBox.Show("更新成功!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("更新失败!");
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("XML文件生成失败");
                this.Close();
            }
        }