public bool UpdateDisCRMRecord( DataTable dtDisMain, DataTable dtDisItemNew, DataTable dtDisItemOld, DataTable dtDisStoreNew, DataTable dtDisStoreOld, string strDIS_NO, DbTransaction RootDBT) { #region bool bResult = false; bool IsRootTranscation = false; ArrayList ParameterList = new ArrayList(); DataCompare dc = new DataCompare(); DataTable dtDisMainDiff = null; DataTable dtDisItemDiff = null; DataTable dtDisItemAdd = null; DataTable dtDisItemDelete = null; DataTable dtDisStoreDiff = null; DataTable dtDisStoreAdd = null; DataTable dtDisStoreDelete = null; try { //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation //4.1) 控制 Begin Transaction if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion #region biz logical #region 4.2) 更新配本主檔並記 if (dtDisMain != null && dtDisMain.Rows.Count > 0) { MaintainDisMain BCODisMain = new MaintainDisMain(ConnectionDB); bResult = BCODisMain.UpdateDisMainFor111(dtDisMain, DBT); } else { bResult = true; } if (!bResult) throw new Exception(string.Format("MaintainDisCRMRecord.UpdateDisMainFor111:Step{0} 發生錯誤", "4.2")); #endregion #region 4.3) 更新配本商品與配本通路 #region 比較新舊值 dc.Clear(); dc.CompareA = dtDisItemNew; dc.CompareB = dtDisItemOld; dc.CompareField.AddCompareFieldRow("DIS_NO", "", true); dc.CompareField.AddCompareFieldRow("ITEM", "", true); dc.CompareField.AddCompareFieldRow("PERIOD", "", true); dc.CompareField.AddCompareFieldRow("INCLUDE_NON_EFF", "", false); dc.CompareData(); dtDisItemDiff = dc.ADiff; dtDisItemAdd = dc.AOnly; dtDisItemDelete = dc.BOnly; #endregion //處理新增 if (dtDisItemAdd != null && dtDisItemAdd.Rows.Count > 0) { #region MaintainDisItem BCODisItem = new MaintainDisItem(ConnectionDB); MaintainDisChan BCODisChan = new MaintainDisChan(ConnectionDB); bResult = BCODisItem.CreateDisItem(dtDisItemAdd, strDIS_NO, DBT); if (!bResult) throw new Exception(string.Format("MaintainDisItem.CreateDisItem:Step{0} 發生錯誤", "4.3")); foreach (DataRow dr in dtDisItemAdd.Rows) { ParameterList.Clear(); ParameterList.Add(strDIS_NO); ParameterList.Add(dr["ITEM"]); ParameterList.Add(dr["PERIOD"]); ParameterList.Add(dtDisMain.Rows[0]["RCHAN_NO"]); ParameterList.Add(DBNull.Value); ParameterList.Add(dr["CREATEDATE"]); ParameterList.Add(dr["CREATEUID"]); ParameterList.Add(DBNull.Value); ParameterList.Add(dtDisMain.Rows[0]["ST_ACCEPT_DATE"]); bResult = BCODisChan.CreateDisChan(ParameterList, DBT); if (!bResult) throw new Exception(string.Format("MaintainDisChan.CreateDisChan:Step{0} 發生錯誤", "4.3")); } } else { bResult = true; #endregion } //處理更新 if (dtDisItemDiff != null && dtDisItemDiff.Rows.Count > 0) { #region MaintainDisItem BCODisItem = new MaintainDisItem(ConnectionDB); MaintainDisChan BCODisChan = new MaintainDisChan(ConnectionDB); bResult = BCODisItem.UpdateDisItemFor111(dtDisItemDiff, DBT); if (!bResult) throw new Exception(string.Format("MaintainDisItem.UpdateDisItemFor111:Step{0} 發生錯誤", "4.3")); foreach (DataRow dr in dtDisItemDiff.Rows) { ParameterList.Clear(); //new ParameterList.Add(dr["CODE", DataRowVersion.Current]); ParameterList.Add(dr["UPDATEDATE", DataRowVersion.Current]); ParameterList.Add(dr["UPDATEUID", DataRowVersion.Current]); ParameterList.Add(dr["DIS_NO", DataRowVersion.Current]); ParameterList.Add(dr["ITEM", DataRowVersion.Current]); ParameterList.Add(dr["PERIOD", DataRowVersion.Current]); ParameterList.Add(dr["CHAN_NO", DataRowVersion.Current]); ParameterList.Add(dr["PLAN_RETURN_DATE", DataRowVersion.Current]); ParameterList.Add(dr["DIS_TYPE", DataRowVersion.Current]); ParameterList.Add(dr["PATTERN_NO", DataRowVersion.Current]); ParameterList.Add(dr["DIS_BRATE", DataRowVersion.Current]); ParameterList.Add(dr["DIS_STO_CQTY", DataRowVersion.Current]); ParameterList.Add(dr["DIS_PRE_CQTY", DataRowVersion.Current]); ParameterList.Add(dr["DIS_TOT_QTY", DataRowVersion.Current]); ParameterList.Add(dr["DIS_TOT_OQTY", DataRowVersion.Current]); ParameterList.Add(dr["DIS_TOT_PQTY", DataRowVersion.Current]); ParameterList.Add(dr["IS_LOCK", DataRowVersion.Current]); //old ParameterList.Add(dr["ID", DataRowVersion.Original]); ParameterList.Add(dr["CODE", DataRowVersion.Original]); ParameterList.Add(dr["CREATEDATE", DataRowVersion.Original]); ParameterList.Add(dr["CREATEUID", DataRowVersion.Original]); ParameterList.Add(dr["UPDATEDATE", DataRowVersion.Original]); ParameterList.Add(dr["UPDATEUID", DataRowVersion.Original]); ParameterList.Add(dr["DIS_NO", DataRowVersion.Original]); ParameterList.Add(dr["ITEM", DataRowVersion.Original]); ParameterList.Add(dr["PERIOD", DataRowVersion.Original]); ParameterList.Add(dr["CHAN_NO", DataRowVersion.Original]); ParameterList.Add(dr["PLAN_RETURN_DATE", DataRowVersion.Original]); ParameterList.Add(dr["DIS_TYPE", DataRowVersion.Original]); ParameterList.Add(dr["PATTERN_NO", DataRowVersion.Original]); ParameterList.Add(dr["DIS_BRATE", DataRowVersion.Original]); ParameterList.Add(dr["DIS_STO_CQTY", DataRowVersion.Original]); ParameterList.Add(dr["DIS_PRE_CQTY", DataRowVersion.Original]); ParameterList.Add(dr["DIS_TOT_QTY", DataRowVersion.Original]); ParameterList.Add(dr["DIS_TOT_OQTY", DataRowVersion.Original]); ParameterList.Add(dr["DIS_TOT_PQTY", DataRowVersion.Original]); ParameterList.Add(dr["IS_LOCK", DataRowVersion.Original]); bResult = BCODisChan.UpdateDisChan(ParameterList, DBT); if (!bResult) throw new Exception(string.Format("MaintainDisChan.UpdateDisChan:Step{0} 發生錯誤", "4.3")); } } else { bResult = true; #endregion } //處理刪除 if (dtDisItemDelete != null && dtDisItemDelete.Rows.Count > 0) { #region MaintainDisItem BCODisItem = new MaintainDisItem(ConnectionDB); foreach (DataRow dr in dtDisItemDelete.Rows) { #region old //ParameterList.Clear(); //ParameterList.Add(dr["ID", DataRowVersion.Original]); //ParameterList.Add(dr["CODE", DataRowVersion.Original]); //ParameterList.Add(dr["CREATEDATE", DataRowVersion.Original]); //ParameterList.Add(dr["CREATEUID", DataRowVersion.Original]); //ParameterList.Add(dr["UPDATEDATE", DataRowVersion.Original]); //ParameterList.Add(dr["UPDATEUID", DataRowVersion.Original]); //ParameterList.Add(dr["DIS_NO", DataRowVersion.Original]); //ParameterList.Add(dr["ITEM", DataRowVersion.Original]); //ParameterList.Add(dr["PERIOD", DataRowVersion.Original]); //ParameterList.Add(dtDisMain.Rows[0]["RCHAN_NO"]); //ParameterList.Add(dr["MEMO", DataRowVersion.Original]); //bResult = BCODisItem.DeleteDisCRMItem(ParameterList, DBT); //if (!bResult) // throw new Exception(string.Format("MaintainDisItem.DeleteDisCRMItem:Step{0} 發生錯誤", "4.3")); #endregion //20090930 modified ParameterList.Clear(); ParameterList.Add(dr["UPDATEDATE", DataRowVersion.Original]); ParameterList.Add(dr["UPDATEUID", DataRowVersion.Original]); ParameterList.Add(dr["DIS_NO", DataRowVersion.Original]); ParameterList.Add(dr["ITEM", DataRowVersion.Original]); ParameterList.Add(dr["PERIOD", DataRowVersion.Original]); bResult = BCODisItem.DeleteDisItemFor111(ParameterList, DBT); if (!bResult) throw new Exception(string.Format("MaintainDisItem.DeleteDisItemFor111:Step{0} 發生錯誤", "4.3")); } } else { bResult = true; #endregion } #endregion #region 4.4) 更新配本門市檔 #region 比較新舊值 dc.Clear(); dc.CompareA = dtDisStoreNew; dc.CompareB = dtDisStoreOld; dc.CompareField.AddCompareFieldRow("CODE", "", true); dc.CompareField.AddCompareFieldRow("ROUTE", "", false); dc.CompareField.AddCompareFieldRow("STEP", "", false); dc.CompareField.AddCompareFieldRow("DIS_QTY", "", false); dc.CompareData(); dtDisStoreDiff = dc.ADiff; dtDisStoreAdd = dc.AOnly; dtDisStoreDelete = dc.BOnly; #endregion //處理新增 if (dtDisStoreAdd != null && dtDisStoreAdd.Rows.Count > 0) { #region MaintainDisStore BCODisStore = new MaintainDisStore(ConnectionDB); foreach (DataRow dr in dtDisStoreAdd.Rows) { ParameterList.Clear(); ParameterList.Add(dr["CODE", DataRowVersion.Current]); ParameterList.Add(dr["UPDATEDATE", DataRowVersion.Current]); ParameterList.Add(dr["UPDATEUID", DataRowVersion.Current]); ParameterList.Add(dr["DIS_NO", DataRowVersion.Current]); ParameterList.Add(dr["ITEM", DataRowVersion.Current]); ParameterList.Add(dr["PERIOD", DataRowVersion.Current]); ParameterList.Add(dr["CHAN_NO", DataRowVersion.Current]); ParameterList.Add(dr["STORE", DataRowVersion.Current]); ParameterList.Add(dr["DIS_QTY", DataRowVersion.Current]); ParameterList.Add(dr["PO_SOURCE_NO", DataRowVersion.Current]); ParameterList.Add(dtDisMain.Rows[0]["ST_ACCEPT_DATE"]); bResult = BCODisStore.CreateDisCRMStore(ParameterList, DBT); if (!bResult) throw new Exception(string.Format("MaintainDisStore.CreateDisCRMStore:Step{0} 發生錯誤", "4.4")); } } else { bResult = true; #endregion } //處理更新 if (dtDisStoreDiff != null && dtDisStoreDiff.Rows.Count > 0) { #region MaintainDisStore BCODisStore = new MaintainDisStore(ConnectionDB); foreach (DataRow dr in dtDisStoreDiff.Rows) { ParameterList.Clear(); ParameterList.Add(dr["CODE", DataRowVersion.Current]); ParameterList.Add(dr["UPDATEDATE", DataRowVersion.Current]); ParameterList.Add(dr["UPDATEUID", DataRowVersion.Current]); ParameterList.Add(dr["DIS_NO", DataRowVersion.Current]); ParameterList.Add(dr["ITEM", DataRowVersion.Current]); ParameterList.Add(dr["PERIOD", DataRowVersion.Current]); ParameterList.Add(dr["CHAN_NO", DataRowVersion.Current]); ParameterList.Add(dr["STORE", DataRowVersion.Current]); ParameterList.Add(dr["DIS_QTY", DataRowVersion.Current]); ParameterList.Add(dr["PO_SOURCE_NO", DataRowVersion.Current]); ParameterList.Add(dtDisMain.Rows[0]["ST_ACCEPT_DATE"]); bResult = BCODisStore.CreateDisCRMStore(ParameterList, DBT); if (!bResult) throw new Exception(string.Format("MaintainDisStore.CreateDisCRMStore:Step{0} 發生錯誤", "4.4")); } } else { bResult = true; #endregion } //處理刪除 if (dtDisStoreDelete != null && dtDisStoreDelete.Rows.Count > 0) { #region MaintainDisStore BCODisStore = new MaintainDisStore(ConnectionDB); foreach (DataRow dr in dtDisStoreDelete.Rows) { ParameterList.Clear(); ParameterList.Add(dr["ID", DataRowVersion.Original]); ParameterList.Add(dr["CODE", DataRowVersion.Original]); ParameterList.Add(dr["CREATEDATE", DataRowVersion.Original]); ParameterList.Add(dr["CREATEUID", DataRowVersion.Original]); ParameterList.Add(dr["UPDATEDATE", DataRowVersion.Original]); ParameterList.Add(dr["UPDATEUID", DataRowVersion.Original]); ParameterList.Add(dr["DIS_NO", DataRowVersion.Original]); ParameterList.Add(dr["ITEM", DataRowVersion.Original]); ParameterList.Add(dr["PERIOD", DataRowVersion.Original]); ParameterList.Add(dr["CHAN_NO", DataRowVersion.Original]); ParameterList.Add(dr["STORE", DataRowVersion.Original]); ParameterList.Add(dr["DIS_QTY", DataRowVersion.Original]); ParameterList.Add(dr["PO_SOURCE_NO", DataRowVersion.Original]); bResult = BCODisStore.DeleteDisStore(ParameterList, DBT); if (!bResult) throw new Exception(string.Format("MaintainDisStore.DeleteDisStore:Step{0} 發生錯誤", "4.4")); } } else { bResult = true; #endregion } #endregion #region 4.5) 呼叫 PKG_VDS_ALO_COMM.lf_area_qty if (dtDisItemOld != null && dtDisItemOld.Rows.Count > 0) { ParameterList.Clear(); ParameterList.Add(strDIS_NO); ParameterList.Add(dtDisItemOld.Rows[0]["ITEM"]); ParameterList.Add(dtDisItemOld.Rows[0]["PERIOD"]); ParameterList.Add(dtDisMain.Rows[0]["RCHAN_NO"]); ParameterList.Add("X"); VDS_ALO_COMMON_DBO DBO_COMM = new VDS_ALO_COMMON_DBO(ref USEDB); bResult = DBO_COMM.doLp_area_disqty(ParameterList, DBT); } if (!bResult) throw new Exception(string.Format("{0} 發生失敗", "呼叫 PKG_VDS_ALO_COMM.lf_area_qty")); #endregion #region 4.6) 異動其他相關資料表 if (dtDisItemOld != null && dtDisItemOld.Rows.Count > 0) { ParameterList.Clear(); ParameterList.Add(strDIS_NO); ParameterList.Add(dtDisItemOld.Rows[0]["ITEM"]); ParameterList.Add(dtDisItemOld.Rows[0]["PERIOD"]); ParameterList.Add(dtDisItemOld.Rows[0]["ROOT_NO"]); ProcessALOCommon BCOProcessCommon = new ProcessALOCommon(ConnectionDB); bResult = BCOProcessCommon.UpdateOtherTables(ParameterList, DBT); } if (!bResult) throw new Exception(string.Format("ProcessALOCommon.UpdateOtherTables:Step{0} 發生錯誤", "4.6")); #endregion #endregion #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion } catch (Exception ex) { #region 交易失敗 if (IsRootTranscation) { //獨立呼叫Transcation失敗 DBT.Rollback(); } #endregion bResult = false; throw GetNewException(ex); } finally { #region 判斷是否關閉交易連線 if (IsRootTranscation) { //獨立呼叫Transcation,關閉連線 if (Conn.State == ConnectionState.Connecting) { Conn.Close(); } } #endregion } return bResult; #endregion }
public static System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(System.Xml.Schema.XmlSchemaSet xs) { System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); DataCompare ds = new DataCompare(); xs.Add(ds.GetSchemaSerializable()); System.Xml.Schema.XmlSchemaAny any1 = new System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); System.Xml.Schema.XmlSchemaAny any2 = new System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); System.Xml.Schema.XmlSchemaAttribute attribute1 = new System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); System.Xml.Schema.XmlSchemaAttribute attribute2 = new System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "CompareFieldDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; return type; }
public bool UpdateDisRecordFor131( DataTable dtDisTmpRecNew, DataTable dtDisTmpRecOld, DataTable dtDisMainNew, DataTable dtDisMainOld, DataTable dtDisItemNew, DataTable dtDisItemOld, DataTable dtDisChanNew, DataTable dtDisChanOld, DataTable dtDisItemReferNew, DataTable dtDisItemReferOld, DataTable dtDisType109TmpNew, DataTable dtDisType109TmpOld, DataTable dtDisTypeTmpNew, DataTable dtDisTypeTmpOld, DataTable dtDisChanReferNEW, string vDisNo, string vItem, string vPeriod, string vUserID, string vStAcceptDate, DbTransaction RootDBT) { #region bool bResult = false; bool IsRootTranscation = false; ArrayList ParameterList = new ArrayList(); DataCompare dc = new DataCompare(); DataTable dtDisMainDiff = null; DataTable dtDisItemDiff = null; DataTable dtDisChanDiff = null; DataTable dtDisChanAdd = null; DataTable dtDisChanDelete = null; DataTable dtDisItemReferDiff = null; DataTable dtDisItemReferAdd = null; DataTable dtDisItemReferDelete = null; DataTable dtDisTmpRecDiff = null; DataTable dtDisTypeTmpDiff = null; DataTable dtDisTypeTmpDelete = null; DataTable dtDisType109TmpDiff = null; try { //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation //4.1) 控制 Begin Transaction if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion #region biz logical #region 4.2) 更新配本主檔並記 #region 比較新舊值 dc.Clear(); dc.CompareA = dtDisMainNew; dc.CompareB = dtDisMainOld; dc.CompareField.AddCompareFieldRow("DIS_NO", "", true); dc.CompareField.AddCompareFieldRow("ST_ACCEPT_DATE", "", false); dc.CompareData(); dtDisMainDiff = dc.ADiff; #endregion if (dtDisMainDiff != null && dtDisMainDiff.Rows.Count > 0) { MaintainDisMain BCODisMain = new MaintainDisMain(ConnectionDB); bResult = BCODisMain.UpdateDisMainFor111(dtDisMainDiff, DBT); } else { bResult = true; } if (!bResult) throw new Exception(string.Format("MaintainDisRecord.UpdateDisMainFor111:Step{0} 發生錯誤", "4.2")); #endregion #region 4.3) 更新配本商品檔 #region 比較新舊值 dc.Clear(); dc.CompareA = dtDisItemNew; dc.CompareB = dtDisItemOld; dc.CompareField.AddCompareFieldRow("DIS_NO", "", true); dc.CompareField.AddCompareFieldRow("ITEM", "", true); dc.CompareField.AddCompareFieldRow("PERIOD", "", true); dc.CompareField.AddCompareFieldRow("INCLUDE_NON_EFF", "", false); dc.CompareField.AddCompareFieldRow("DIS_TYPE", "", false); dc.CompareField.AddCompareFieldRow("DIS_PRE_QTY", "", false); dc.CompareField.AddCompareFieldRow("DIS_QTY", "", false); dc.CompareField.AddCompareFieldRow("CHAN_TYPE", "", false); dc.CompareData(); dtDisItemDiff = dc.ADiff; #endregion if (dtDisItemDiff != null && dtDisItemDiff.Rows.Count > 0) { MaintainDisItem BCODisItem = new MaintainDisItem(ConnectionDB); bResult = BCODisItem.UpdateDisItemFor111(dtDisItemDiff, DBT); } else { bResult = true; } if (!bResult) throw new Exception(string.Format("MaintainDisRecord.UpdateDisItemFor111:Step{0} 發生錯誤", "4.3")); #endregion #region 4.4) 更新配本通路檔 #region 比較新舊值 dc.Clear(); dc.CompareA = dtDisChanNew; dc.CompareB = dtDisChanOld; dc.CompareField.AddCompareFieldRow("DIS_NO", "", true); dc.CompareField.AddCompareFieldRow("ITEM", "", true); dc.CompareField.AddCompareFieldRow("PERIOD", "", true); dc.CompareField.AddCompareFieldRow("CHAN_NO", "", true); dc.CompareField.AddCompareFieldRow("DIS_TYPE", "", false); dc.CompareField.AddCompareFieldRow("DIS_PRE_CQTY", "", false); dc.CompareField.AddCompareFieldRow("ID", "", false); dc.CompareData(); dtDisChanDiff = dc.ADiff; dtDisChanAdd = dc.AOnly; dtDisChanDelete = dc.BOnly; #endregion if ((dtDisChanDiff != null && dtDisChanDiff.Rows.Count > 0) || (dtDisChanAdd != null && dtDisChanAdd.Rows.Count > 0) || (dtDisChanDelete != null && dtDisChanDelete.Rows.Count > 0)) { MaintainDisChan BCODisChan = new MaintainDisChan(ConnectionDB); bResult = BCODisChan.UpdateDisChanFor131(dtDisChanDiff, dtDisChanAdd, dtDisChanDelete, vStAcceptDate, DBT); } else { bResult = true; } if (!bResult) throw new Exception(string.Format("MaintainDisRecord.CreateDisRecordFor131:Step{0} 發生錯誤", "4.4")); #endregion #region 4.5) 更新配本參照設定 #region 比較新舊值 dc.Clear(); dc.CompareA = dtDisItemReferNew; dc.CompareB = dtDisItemReferOld; dc.CompareField.AddCompareFieldRow("DIS_NO", "", true); dc.CompareField.AddCompareFieldRow("ITEM", "", true); dc.CompareField.AddCompareFieldRow("PERIOD", "", true); dc.CompareField.AddCompareFieldRow("RITEM", "", true); dc.CompareField.AddCompareFieldRow("RPERIOD", "", true); dc.CompareField.AddCompareFieldRow("REFER_RATE", "", false); dc.CompareField.AddCompareFieldRow("ID", "", false); dc.CompareData(); dtDisItemReferDiff = dc.ADiff; dtDisItemReferAdd = dc.AOnly; dtDisItemReferDelete = dc.BOnly; #endregion if ((dtDisItemReferDiff != null && dtDisItemReferDiff.Rows.Count > 0) || (dtDisItemReferAdd != null && dtDisItemReferAdd.Rows.Count > 0) || (dtDisItemReferDelete != null && dtDisItemReferDelete.Rows.Count > 0)) { MaintainDisItemRefer BCODisItemRefer = new MaintainDisItemRefer(ConnectionDB); bResult = BCODisItemRefer.UpdateItemAndChanRefer(dtDisItemReferDiff, dtDisItemReferAdd, dtDisItemReferDelete, dtDisChanOld, dtDisChanNew, dtDisItemReferNew, vItem, vPeriod, DBT); } else { bResult = true; } if (!bResult) throw new Exception(string.Format("MaintainDisItemRefer.CreateDisRecordFor131:Step{0} 發生錯誤", "4.5")); #endregion #region 4.5.2) 更新通路參照 if (dtDisChanReferNEW != null) { MaintainDisChanRefer BCOChanRef = new MaintainDisChanRefer(ConnectionDB); bResult = BCOChanRef.UpdateDisChanReferFor(dtDisChanReferNEW, vDisNo, vItem, vPeriod, vUserID, DBT ); if (!bResult) throw new Exception(string.Format("MaintainDisChanRefer.UpdateDisChanReferFor:Step{0} 發生錯誤", "4.5.2")); } #endregion #region 4.6) 維護配本輔助項目設定 #region 比較新舊值 dc.Clear(); dc.CompareA = dtDisTmpRecNew; dc.CompareB = dtDisTmpRecOld; dc.CompareField.AddCompareFieldRow("ID", "", true); dc.CompareField.AddCompareFieldRow("CODE", "", true); dc.CompareField.AddCompareFieldRow("SP_CHANGE", "", false); dc.CompareField.AddCompareFieldRow("ORDER_CHANGE", "", false); dc.CompareField.AddCompareFieldRow("DIS_TYPE", "", false); dc.CompareData(); dtDisTmpRecDiff = dc.ADiff; #endregion if (dtDisTmpRecDiff != null && dtDisTmpRecDiff.Rows.Count > 0) { #region MaintainDisAssist BCODisAssist = new MaintainDisAssist(ConnectionDB); DataTable dtDisAssist = BCODisAssist.GetDisAssistMainSchema(); ParameterList.Clear(); ParameterList.Add(dtDisTmpRecDiff.Rows[0]["DIS_NO"]); ParameterList.Add(dtDisTmpRecDiff.Rows[0]["ITEM"]); ParameterList.Add(dtDisTmpRecDiff.Rows[0]["PERIOD"]); ParameterList.Add(DBNull.Value);//CHAN_NO ParameterList.Add(dtDisTmpRecDiff.Rows[0]["UPDATEDATE"]); ParameterList.Add(dtDisTmpRecDiff.Rows[0]["UPDATEUID"]); BCODisAssist.DeleteOldDisAssist(ParameterList, DBT); #endregion //a) 判斷是否需更新特殊調整 if (dtDisTmpRecDiff.Rows[0]["SP_CHANGE"] != null && dtDisTmpRecDiff.Rows[0]["SP_CHANGE"].ToString().Trim() != "0") { #region 更新特殊調整(ASSIST_CODE='09') DataRow dr = dtDisAssist.NewRow(); dr["DIS_NO"] = vDisNo; dr["ITEM"] = vItem; dr["PERIOD"] = vPeriod; dr["CHAN_NO"] = "0";//更新時固定為0 dr["ASSIST_CODE"] = "09"; dr["OPERATOR1"] = DBNull.Value; dr["OP_VALUE1"] = DBNull.Value; dr["OPERATOR2"] = DBNull.Value; dr["OP_VALUE2"] = DBNull.Value; dr["CHANGE_TYPE"] = DBNull.Value; dr["CHANGE_RATE"] = DBNull.Value; dr["ORDER_CHANGE"] = DBNull.Value; dr["UPDATEDATE"] = DateTime.Now; dr["UPDATEUID"] = vUserID; dtDisAssist.Rows.Add(dr); bResult = BCODisAssist.CreateDisAssist(dtDisAssist, null, DBT); #endregion } //b) 判斷是否需更新訂單匯入 if (dtDisTmpRecDiff.Rows[0]["ORDER_CHANGE"] != null && dtDisTmpRecDiff.Rows[0]["ORDER_CHANGE"].ToString().Trim() != "0") { #region 更新訂單匯入(ASSIST_CODE='10'), DataRow dr = dtDisAssist.NewRow(); dr["DIS_NO"] = vDisNo; dr["ITEM"] = vItem; dr["PERIOD"] = vPeriod; dr["CHAN_NO"] = "0";//更新時固定為0 dr["ASSIST_CODE"] = "10"; dr["OPERATOR1"] = DBNull.Value; dr["OP_VALUE1"] = DBNull.Value; dr["OPERATOR2"] = DBNull.Value; dr["OP_VALUE2"] = DBNull.Value; dr["CHANGE_TYPE"] = DBNull.Value; dr["CHANGE_RATE"] = DBNull.Value; dr["ORDER_CHANGE"] = dtDisTmpRecDiff.Rows[0]["ORDER_CHANGE"].ToString().Trim(); dr["UPDATEDATE"] = DateTime.Now; dr["UPDATEUID"] = vUserID; dtDisAssist.Rows.Add(dr); bResult = BCODisAssist.CreateDisAssist(dtDisAssist, null, DBT); #endregion } } else { bResult = true; } if (!bResult) throw new Exception(string.Format("MaintainDisAssist.CreateDisAssist:Step{0} 發生錯誤", "4.6")); #endregion #region 4.7) 若dtDisItem.Rows.DIS_TYPE ='109' =>需判斷是否記錄109等級配本設定 #region 比較新舊值 dc.Clear(); dc.CompareA = dtDisType109TmpNew; dc.CompareB = dtDisType109TmpOld; dc.CompareField.AddCompareFieldRow("DIS_NO", "", true); dc.CompareField.AddCompareFieldRow("ITEM", "", true); dc.CompareField.AddCompareFieldRow("PERIOD", "", true); dc.CompareField.AddCompareFieldRow("RANK_CODE", "", true); dc.CompareField.AddCompareFieldRow("RANK_LEVEL", "", true); //dc.CompareField.AddCompareFieldRow("VENDOR", "", true); dc.CompareField.AddCompareFieldRow("PATTERN_NO", "", true); dc.CompareField.AddCompareFieldRow("RANK_DIS_QTY", "", false); dc.CompareData(); dtDisType109TmpDiff = dc.ADiff; #endregion if (dtDisTmpRecNew != null && dtDisTmpRecNew.Rows.Count > 0) { if (dtDisTmpRecNew.Rows[0]["DIS_TYPE"].ToString().Trim() == "109") { //if (dtDisType109TmpDiff != null && dtDisType109TmpDiff.Rows.Count > 0) //{ // MaintainDisType109Tmp BCODisType109 = new MaintainDisType109Tmp(ConnectionDB); // bResult = BCODisType109.SaveDisType109Tmp(dtDisType109TmpDiff, vDisNo, vItem, vPeriod, DBT); //} if (dtDisType109TmpNew != null && dtDisType109TmpNew.Rows.Count > 0)//20090811 added { MaintainDisType109Tmp BCODisType109 = new MaintainDisType109Tmp(ConnectionDB); bResult = BCODisType109.SaveDisType109Tmp(dtDisType109TmpNew, vDisNo, vItem, vPeriod, DBT); } } } else { bResult = true; } if (!bResult) throw new Exception(string.Format("MaintainDisType109Tmp.SaveDisType109Tmp:Step{0} 發生錯誤", "4.7")); #endregion #region 4.8) 若dtDisItem.Rows.DIS_TYPE in ('105','110') =>需判斷是否記錄105類似配本/110定額配本設定記錄 #region 比較新舊值 dc.Clear(); dc.CompareA = dtDisTypeTmpNew; dc.CompareB = dtDisTypeTmpOld; dc.CompareField.AddCompareFieldRow("DIS_NO", "", true); dc.CompareField.AddCompareFieldRow("ITEM", "", true); dc.CompareField.AddCompareFieldRow("PERIOD", "", true); dc.CompareField.AddCompareFieldRow("DIS_TYPE", "", true); dc.CompareField.AddCompareFieldRow("DIS_QTY", "", false); dc.CompareData(); dtDisTypeTmpDiff = dc.ADiff; dtDisTypeTmpDelete = dc.BOnly; #endregion if (dtDisTmpRecNew != null && dtDisTmpRecNew.Rows.Count > 0) { if (dtDisTmpRecNew.Rows[0]["DIS_TYPE"].ToString().Trim() == "105" || dtDisTmpRecNew.Rows[0]["DIS_TYPE"].ToString().Trim() == "110") { //if (dtDisTypeTmpDiff != null && dtDisTypeTmpDiff.Rows.Count > 0) //{ // MaintainDisTypeTmp BCODisType = new MaintainDisTypeTmp(ConnectionDB); // bResult = BCODisType.SaveDisTypeTmp(dtDisTypeTmpDiff, vDisNo, vItem, vPeriod, DBT); //} if (dtDisTypeTmpNew != null && dtDisTypeTmpNew.Rows.Count > 0)//20090812 added { MaintainDisTypeTmp BCODisType = new MaintainDisTypeTmp(ConnectionDB); bResult = BCODisType.SaveDisTypeTmp(dtDisTypeTmpNew, vDisNo, vItem, vPeriod, DBT); } } else { if (dtDisTypeTmpDelete != null && dtDisTypeTmpDelete.Rows.Count > 0)//20090820 added { MaintainDisTypeTmp BCODisType = new MaintainDisTypeTmp(ConnectionDB); bResult = BCODisType.DeleteDisTypeTmp(vDisNo, vItem, vPeriod, DBT); } } } else { bResult = true; } if (!bResult) throw new Exception(string.Format("MaintainDisTypeTmp.SaveDisTypeTmp:Step{0} 發生錯誤", "4.8")); #endregion #region 4.9) 異動其他相關資料表 ParameterList.Clear(); ParameterList.Add(vDisNo); ParameterList.Add(vItem); ParameterList.Add(vPeriod); ParameterList.Add(vUserID); ProcessALOCommon BCOProcessCommon = new ProcessALOCommon(ConnectionDB); bResult = BCOProcessCommon.UpdateOtherTables(ParameterList, DBT); if (!bResult) throw new Exception(string.Format("ProcessALOCommon.UpdateOtherTables:Step{0} 發生錯誤", "4.9")); #endregion #endregion #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion } catch (Exception ex) { #region 交易失敗 if (IsRootTranscation) { //獨立呼叫Transcation失敗 DBT.Rollback(); } #endregion bResult = false; throw GetNewException(ex); } finally { #region 判斷是否關閉交易連線 if (IsRootTranscation) { //獨立呼叫Transcation,關閉連線 if (Conn.State == ConnectionState.Connecting) { Conn.Close(); } } #endregion } return bResult; #endregion }
public static System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(System.Xml.Schema.XmlSchemaSet xs) { DataCompare ds = new DataCompare(); System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType(); System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence(); xs.Add(ds.GetSchemaSerializable()); System.Xml.Schema.XmlSchemaAny any = new System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; return type; }