【问题提问、论坛交流】
try
{
}
catch (OleDbException e)
{
SimpleLogger.Log(e);
MessageBox.Show("An exception of type " + e.GetType() +");
}
}
}
*****************************************
将数据进行处理分别插入主表和从表
public bool AddExceLGmailRebate(DataTable tb,string homeCompanyID)
{
bool ret=false;
SqlConnection con=null;
DataTable table=new DataTable();
table=tb;
string sConn = PublicManager.GetDBConnectionString(homeCompanyID);
con=new SqlConnection();
con.ConnectionString=sConn;
SqlTransaction tran=null;
SqlCommand com=null;
SqlCommand comm=null;
try
{
con.Open();
tran = con.BeginTransaction();
if (table != null && table.Rows.Count > 0)
{
for(int i=1;i<table.Rows.Count;i++)
{
string m_PromoCode=Convert.ToString(table.Rows[i][0]);
if(m_PromoCode=="")
{
m_PromoCode=Convert.ToString(table.Rows[i-1][0]);
}
if(m_PromoCode.Length>50 )
{
m_PromoCode=m_PromoCode.Substring(0,50);
}
string m_ItemDescription=Convert.ToString(table.DefaultView[i][1]);
if(m_ItemDescription.IndexOf("(")>0)
{
int num=m_ItemDescription.IndexOf("(");
m_ItemDescription=m_ItemDescription.Substring(0,num);
if(m_ItemDescription.Length>50)
{
m_ItemDescription=m_ItemDescription.Substring(0,50);
}
}
if(m_ItemDescription.Length>50)
{
m_ItemDescription=m_ItemDescription.Substring(0,50);
}
string begin=Convert.ToString(table.DefaultView[i][2]);
string m_BeginPromoPeriodDate;
string m_EndPromoPeriodEndDate;
if(begin=="")
{
continue;
}
else
{
string beginTime=begin.Substring(0,8);
beginTime=beginTime.Replace("/","-");
m_BeginPromoPeriodDate=beginTime;
string endTime=begin.Substring(begin.Length-8);
endTime=endTime.Replace("/","-");
m_EndPromoPeriodEndDate=endTime;
}
string m_RebateAmountStr=Convert.ToString(table.DefaultView[i][3]);
if(m_RebateAmountStr.Length >9)
{
m_RebateAmountStr=m_RebateAmountStr.Substring(0,9);
}
decimal m_RebateAmount;
if(m_RebateAmountStr=="")
{
编辑:xker.com