public DataTable QuerySwitch(QueryType QT, ArrayList ParameterList) { DBO.VDS_CRM_RECORD_MAINDBO VCRM = new VDS_CRM_RECORD_MAINDBO(ref USEDB); DBO.VDS_CRM_RECORD_DETLDBO VCRD = new VDS_CRM_RECORD_DETLDBO(ref USEDB); DataTable Dt; try { switch (QT) { case QueryType.QueryLastThreeCRMRecord: Dt = VCRM.DO_CRM011_QUERY_RECORD_THREE(ParameterList); break; case QueryType.CRM011_DETL_SCHEMA: Dt = VCRD.DO_CRM011_DETAIL_SCHEMA(ParameterList); break; default: Dt = new DataTable(); break; } return Dt; } catch (Exception ex) { throw GetNewException(ex); } }
/// <summary> /// 新增 VDS_CRM_RECORD_MAIN 和 VDS_CRM_RECORD_DETL 的資料 /// </summary> /// <param name="ParameterList">MASTER TABLE 的變數</param> /// <param name="RootDBT">是否有主交易,無主交易輸入null</param> /// <param name="dt_Detail">DETAIL TABLE</param> /// <returns>VDS_CRM_RECORD_MAIN.ID</returns> public int CreateCRMRecord(ArrayList ParameterList, DbTransaction RootDBT, DataTable dt_Detail) { int ID = 0; string s_Log_UpdateUid = string.Empty; DateTime d_Log_UpdateDate; bool IsRootTranscation = false; try { DBO.VDS_CRM_RECORD_MAINDBO VCRM = new VDS_CRM_RECORD_MAINDBO(ref USEDB); DBO.VDS_CRM_RECORD_DETLDBO VCRD = new VDS_CRM_RECORD_DETLDBO(ref USEDB); //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion //寫入 Master Table ID = VCRM.ADD_CRM011_MAIN(ParameterList, DBT); s_Log_UpdateUid = ParameterList[14].ToString(); d_Log_UpdateDate = DateTime.Parse(ParameterList[15].ToString()); //寫入 Detail Table foreach (DataRow dRow in dt_Detail.Rows) { VCRD.ADD_CRM011_DETL(DBT, dRow, ID, s_Log_UpdateUid, d_Log_UpdateDate); } #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion return ID; } catch (Exception ex) { #region 交易失敗 if (IsRootTranscation) { //獨立呼叫Transcation失敗 DBT.Rollback(); } #endregion throw GetNewException(ex); } finally { #region 判斷是否關閉交易連線 if (IsRootTranscation) { //獨立呼叫Transcation,關閉連線 if (Conn.State == ConnectionState.Connecting) { Conn.Close(); } } #endregion } }
/// <summary> /// 檢查[流水編號]是否存在於VDS_CRM_RECORD_MAIN /// </summary> /// <param name="ParameterList">[流水編號]</param> /// <returns>VDS_CRM_RECORD_MAIN</returns> public DataTable QueryCRMRecordByCode_CheckExist(ArrayList ParameterList) { try { DataTable dt_Return = new DataTable(); DBO.VDS_CRM_RECORD_MAINDBO VCRM = new VDS_CRM_RECORD_MAINDBO(ref USEDB); dt_Return = VCRM.QUERY_CRM011_MAIN_BY_CODE(ParameterList); return dt_Return; } catch (Exception ex) { throw GetNewException(ex); } }
/// <summary> /// 更新 VDS_CRM_RECORD_MAIN 和 VDS_CRM_RECORD_DETL 的資料 /// </summary> /// <param name="ParameterList">MASTER TABLE 的變數</param> /// <param name="RootDBT">是否有主交易,無主交易輸入null</param> /// <param name="dt_Detail">DETAIL TABLE</param> /// <returns>VDS_CRM_RECORD_MAIN.ID</returns> public int UpdateCRMRecord(ArrayList ParameterList, DbTransaction RootDBT, DataTable dt_Detail) { int i_Master_Id = 0; string s_Log_UpdateUid = string.Empty; DateTime d_Log_UpdateDate; bool IsRootTranscation = false; try { DBO.VDS_CRM_RECORD_MAINDBO VCRM = new VDS_CRM_RECORD_MAINDBO(ref USEDB); DBO.VDS_CRM_RECORD_DETLDBO VCRD = new VDS_CRM_RECORD_DETLDBO(ref USEDB); //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion VCRM.UPDATE_CRM011_MAIN(ParameterList, DBT); if (dt_Detail.Rows.Count != 0) { i_Master_Id = int.Parse(ParameterList[3].ToString()); s_Log_UpdateUid = ParameterList[1].ToString(); d_Log_UpdateDate = DateTime.Parse(ParameterList[2].ToString()); foreach (DataRow dRow in dt_Detail.Rows) { if (dRow["STATUS"].ToString() == "ADD") { VCRD.ADD_CRM011_DETL(DBT, dRow, i_Master_Id, s_Log_UpdateUid, d_Log_UpdateDate); } else if (dRow["STATUS"].ToString() == "DELETE") { VCRD.DELETE_CRM011_DETAIL(DBT, dRow, s_Log_UpdateUid, d_Log_UpdateDate); } } } #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion return i_Master_Id; } catch (Exception ex) { #region 交易失敗 if (IsRootTranscation) { //獨立呼叫Transcation失敗 DBT.Rollback(); } #endregion throw GetNewException(ex); } finally { #region 判斷是否關閉交易連線 if (IsRootTranscation) { //獨立呼叫Transcation,關閉連線 if (Conn.State == ConnectionState.Connecting) { Conn.Close(); } } #endregion } }
/// <summary> /// 查詢 VDS_CRM_RECORD_MAIN 和 VDS_CRM_RECORD_DETL 和 VDS_STM_STORE 的資料 /// 根據畫面上使用者輸入的條件 /// </summary> /// <param name="ParameterList">MASTER TABLE 的變數</param> /// <returns>VDS_CRM_RECORD_MAIN 和 VDS_CRM_RECORD_DETL 和 VDS_STM_STORE 的資料</returns> public DataSet QueryCRMRecordByFind2(ArrayList ParameterList) { #region try { DataSet ds_Return = new DataSet(); DataTable dt_Master = new DataTable(); DataTable dt_Detail = new DataTable(); DataTable dt_Store = new DataTable(); DBO.VDS_CRM_RECORD_MAINDBO VCRM = new VDS_CRM_RECORD_MAINDBO(ref USEDB); DBO.VDS_CRM_RECORD_DETLDBO VCRD = new VDS_CRM_RECORD_DETLDBO(ref USEDB); DBO.VDS_CRM_PUBLIC_DBO VCPD = new VDS_CRM_PUBLIC_DBO(ref USEDB); dt_Master = VCRM.QUERY_CRM011_MAIN_BY_CONDITONS(ParameterList); if (dt_Master.Rows.Count != 0 ) { #region 根據 Master 所抓出來來的資料,來讀取 Detail 的資料 int i_Pid = int.Parse(dt_Master.Rows[0]["ID"].ToString()); string s_UpdateUid = ParameterList[9].ToString(); DateTime d_UpdateDate = DateTime.Parse(ParameterList[10].ToString()); dt_Detail = VCRD.QUERY_CRM011_DETL_BY_PID(i_Pid, s_UpdateUid, d_UpdateDate); #endregion #region 根據 Master 所抓出來來的資料,來讀取 VDS_STM_STORE 的資料 ArrayList ParameterList_Store = new ArrayList(); ParameterList_Store.Add(dt_Master.Rows[0]["STORE"]); ParameterList_Store.Add(dt_Master.Rows[0]["CHAN_NO"]); ParameterList_Store.Add(ParameterList[9]); ParameterList_Store.Add(ParameterList[10]); dt_Store = VCPD.DO_CRM011_QUERY_STORE(ParameterList_Store); #endregion #region 設定回傳 DataSet dt_Master.TableName = "VDS_CRM_RECORD_MAIN"; dt_Detail.TableName = "VDS_CRM_RECORD_DETL"; dt_Store.TableName = "VDS_STM_STORE"; ds_Return.Tables.Add(dt_Master.Copy()); ds_Return.Tables.Add(dt_Detail.Copy()); ds_Return.Tables.Add(dt_Store.Copy()); dt_Master.Dispose(); dt_Detail.Dispose(); dt_Store.Dispose(); #endregion } return ds_Return; } catch (Exception ex) { throw GetNewException(ex); } #endregion }
public string QueryRecordMainByTool(ArrayList ParameterList) { #region try { string strResult = null; DBO.VDS_CRM_RECORD_MAINDBO DBO = new VDS_CRM_RECORD_MAINDBO(ref USEDB); DataTable dt = DBO.doQueryRecordMainByTool(ParameterList); if (dt != null && dt.Rows.Count > 0) { strResult = dt.Rows[0]["CODE"].ToString(); } else { strResult = null; } return strResult; } catch (Exception ex) { throw GetNewException(ex); } #endregion }
/// <summary> /// 取得ID For 巡覽列 /// </summary> /// <param name="ParameterList"></param> /// <returns></returns> public ArrayList QueryIDForBROWSER(ArrayList ParameterList) { #region try { ArrayList aryResult = new ArrayList(); DBO.VDS_CRM_RECORD_MAINDBO DBO = new VDS_CRM_RECORD_MAINDBO(ref USEDB); DataTable dt = DBO.doQueryIDForBROWSER(ParameterList); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { #region aryResult.Add(dr["ID"]); #endregion } } else { aryResult = null; } return aryResult; } catch (Exception ex) { throw GetNewException(ex); } #endregion }
/// <summary> /// 查詢 VDS_CRM_RECORD_MAIN 和 VDS_CRM_RECORD_DETL 和 VDS_STM_STORE 的資料 /// 根據 VDS_CRM_RECORD_MAIN.CODE /// </summary> /// <param name="ParameterList">MASTER TABLE 的變數</param> /// <returns>VDS_CRM_RECORD_MAIN 和 VDS_CRM_RECORD_DETL 和 VDS_STM_STORE 的資料</returns> public DataSet QueryCRMRecordByCode(ArrayList ParameterList) { try { DataSet ds_Return = new DataSet(); DataTable dt_Master = new DataTable(); DataTable dt_Detail = new DataTable(); DataTable dt_Store = new DataTable(); DBO.VDS_CRM_RECORD_MAINDBO VCRM = new VDS_CRM_RECORD_MAINDBO(ref USEDB); DBO.VDS_CRM_RECORD_DETLDBO VCRD = new VDS_CRM_RECORD_DETLDBO(ref USEDB); DBO.VDS_CRM_PUBLIC_DBO VCPD = new VDS_CRM_PUBLIC_DBO(ref USEDB); dt_Master = VCRM.QUERY_CRM011_MAIN_BY_CODE(ParameterList); if (dt_Master.Rows.Count != 0) { dt_Detail = VCRD.QUERY_CRM011_DETL_BY_PID(int.Parse(dt_Master.Rows[0]["ID"].ToString()), (string)ParameterList[1], (DateTime)ParameterList[2]); ArrayList ParameterList_Store = new ArrayList(); ParameterList_Store.Add(dt_Master.Rows[0]["STORE"]); ParameterList_Store.Add(dt_Master.Rows[0]["CHAN_NO"]); ParameterList_Store.Add(ParameterList[1]); ParameterList_Store.Add(ParameterList[2]); dt_Store = VCPD.DO_CRM011_QUERY_STORE(ParameterList_Store); dt_Master.TableName = "VDS_CRM_RECORD_MAIN"; dt_Detail.TableName = "VDS_CRM_RECORD_DETL"; dt_Store.TableName = "VDS_STM_STORE"; ds_Return.Tables.Add(dt_Master.Copy()); ds_Return.Tables.Add(dt_Detail.Copy()); ds_Return.Tables.Add(dt_Store.Copy()); dt_Master.Dispose(); dt_Detail.Dispose(); dt_Store.Dispose(); } return ds_Return; } catch (Exception ex) { throw GetNewException(ex); } }