using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OracleClient;
using Otitan.BLL;
using System.Data.SQLite;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnstart_Click(object sender, EventArgs e)
{
RefreshOracleData();
}
/// <summary>
/// 从sqllite中获得数据
/// </summary>
/// <returns></returns>
public DataTable GetDataTabFromSqllite()
{
//连接sqllite
SQLiteConnection sqlliteconn = new SQLiteConnection();
sqlliteconn.ConnectionString = @"Data Source=E:\sqllite\乌当区运输证.sqlite";
sqlliteconn.Open();//打开sqlite
SQLiteCommand command = new SQLiteCommand();
command.Connection = sqlliteconn;
command.CommandText = "select * from TBL_YUNSHU_ZHENG";
SQLiteDataAdapter adapter = new SQLiteDataAdapter();
adapter.SelectCommand = command;
DataSet dataset = new DataSet();
adapter.Fill(dataset);//获得sqllite数据
return dataset.Tables[0];
}
/// <summary>
/// 更新oracle数据库对应的表
/// </summary>
public void RefreshOracleData()
{
BUSI_MC_TRANSPORT b_trancport = new BUSI_MC_TRANSPORT();
Otitan.Model.BUSI_MC_TRANSPORT m_trancport = new Otitan.Model.BUSI_MC_TRANSPORT();
DataTable mc_Tab = GetDataTabFromSqllite();
try
{
for (int i = 0; i < mc_Tab.Rows.Count; i++)
{
m_trancport.ID = b_trancport.GetMaxId();
m_trancport.TRANS_NUMBER = mc_Tab.Rows[i]["YSZ_BH"].ToString();//运输帐号
// m_trancport.CUT_NUMBER = mc_Tab.Rows[i]["AGE"].ToString();//采伐证号(凭证号)
// m_trancport.CUT_UNIT=//采伐(售材)单位(个人) 签发机关
// m_trancport.BUY_UNIT//购买单位
m_trancport.TRANS_PEOPLE = mc_Tab.Rows[i]["CHENG_YUN_R"].ToString();//承运人
// m_trancport.TREES_ID
// m_trancport.C_NAME
//m_trancport.P_NAME
// m_trancport.AMOUNT//检查记录
m_trancport.G_SIZE = mc_Tab.Rows[i]["YUN_SHU_FS"].ToString();//运输方式
m_trancport.TRANS_PLACE = mc_Tab.Rows[i]["YUN_SHU_ZDM"].ToString();//运往地点
m_trancport.WOOD_LY = mc_Tab.Rows[i]["CHAN_DI"].ToString();//产地
// m_trancport.TRANS_DATE//运输日期
//m_trancport.RUSH_PEOPLE//签发人员
m_trancport.LEAD_PEOPLE = mc_Tab.Rows[i]["LING_ZHENG_R"].ToString();//领证人
m_trancport.NOTE = mc_Tab.Rows[i]["BEI_ZHU"].ToString();//备注
m_trancport.Q_PLACE = mc_Tab.Rows[i]["YUN_SHU_QDM"].ToString();//起运地点
m_trancport.HZ = mc_Tab.Rows[i]["HUO_ZHU_MC"].ToString();//货主
m_trancport.QYDD_S = mc_Tab.Rows[i]["YUN_SHU_QSMC"].ToString();//起运地点——省
m_trancport.QYDD_X = mc_Tab.Rows[i]["YUN_SHU_QXMC"].ToString();//起运地点——市
m_trancport.DDDD_S = mc_Tab.Rows[i]["YUN_SHU_ZSMC"].ToString();//到达地点--省
m_trancport.DDDD_X = mc_Tab.Rows[i]["YUN_SHU_ZXMC"].ToString();//到达地点--市
m_trancport.QFRQ = DateTime.Parse(mc_Tab.Rows[i]["QIAN_FA_RQ"].ToString());//签发日期
m_trancport.QFJGTEL = mc_Tab.Rows[i]["QIAN_FA_DH"].ToString();//签发机关电话
m_trancport.DQXXID = decimal.Parse(mc_Tab.Rows[i]["YUN_SHU_QBM"].ToString().Substring(4, 2));//地区信息
b_trancport.Add(m_trancport);
label1.Text = "总共更新了" + i + "行数据";
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnRefresh_Click(object sender, EventArgs e)
{
//删除插入的数据,重新进行生成
OracleConnection conn = new OracleConnection();conn.ConnectionString = " data source=orcl_192.168.1.15; user=gyly;password=gyly;";
conn.Open();
OracleCommand command = conn.CreateCommand();
command.CommandText = "delete from BUSI_MC_TRANSPORT ";
command.ExecuteReader();
}
}
}