public DataTable CheckDETL(ArrayList Para) { VDS_IVM043_DBO dbo = new VDS_IVM043_DBO(ref USEDB); try { return dbo.CheckDETL(Para); } catch (Exception ex) { throw ex; } }
public bool SaveData(DataTable dtData, ArrayList ParameterList) { bool bResult = false; try { string strSTOCKTAKE_NO = ParameterList[0].ToString(); string strUID = ParameterList[1].ToString(); string strPID = ParameterList[2].ToString(); Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); DBO.VDS_IVM043_DBO db = new VDS_IVM043_DBO(ref USEDB); ArrayList Para = new ArrayList(); for (int i = 0; i < dtData.Rows.Count; i++) { //V_STOCKTAKE_NO //V_LOCATE_NO //V_LOCATE_SECTION //V_ITEM //V_PERIOD Para.Clear(); Para.Add(strSTOCKTAKE_NO); Para.Add(dtData.Rows[i]["LOCATE_NO"].ToString()); Para.Add(dtData.Rows[i]["LOCATE_SECTION"].ToString()); Para.Add(dtData.Rows[i]["ITEM"].ToString()); Para.Add(dtData.Rows[i]["PERIOD"].ToString()); DataTable dtCheck = db.CheckDETL(Para); if (dtCheck.Rows.Count > 0) { //N_ID number, //N_STOCKTAKE_QTY number, //V_NEW_UPDATEUID varchar2, //D_NEW_UPDATEDATE date, //V_OLD_UPDATEUID varchar2, //D_OLD_UPDATEDATE date, //V_OLD_CREATEUID varchar2, //D_OLD_CREATEDATE date Para.Clear(); Para.Add(int.Parse(dtCheck.Rows[0]["ID"].ToString())); Para.Add(int.Parse(dtData.Rows[i]["STOCKTAKE_QTY"].ToString())); Para.Add(strUID); Para.Add(DateTime.Now); Para.Add(DBNull.Value); Para.Add(DBNull.Value); Para.Add(DBNull.Value); Para.Add(DBNull.Value); db.UpdStockTake(Para, DBT); } else { Para.Clear(); Para.Add(int.Parse(strPID)); Para.Add(dtData.Rows[i]["LOCATE_NO"].ToString() + dtData.Rows[i]["LOCATE_SECTION"].ToString()); Para.Add(dtData.Rows[i]["ITEM"].ToString()); Para.Add(dtData.Rows[i]["PERIOD"].ToString()); Para.Add(int.Parse(dtData.Rows[i]["STOCKTAKE_QTY"].ToString())); Para.Add(decimal.Parse(dtData.Rows[i]["COST"].ToString())); Para.Add(strUID); Para.Add(DateTime.Now); InsertStockTake(Para, DBT); } } DBT.Commit(); bResult = true; } catch (Exception ex) { if (DBT != null) { //獨立呼叫Transcation失敗 DBT.Rollback(); } throw ex; } finally { //獨立呼叫Transcation,關閉連線 if (Conn.State == ConnectionState.Connecting) { Conn.Close(); } } return bResult; }