public void DeleteMRPResult(int pintCCNID, int pintCycleOptionID) { //Delete MTR_CPO MTR_CPODS dsMTR_CPO = new MTR_CPODS(); dsMTR_CPO.Delete(pintCCNID, pintCycleOptionID); }
/// <summary> /// DeleteCycleOptionMasterAndDetail /// </summary> /// <param name="pintCycleOptionMasterID"></param> /// <param name="pdstData"></param> /// <author>Trada</author> /// <date>Thursday, August 11 2005</date> public int DeleteCycleOptionMasterAndDetail(int pintCycleOptionMasterID, DataSet pdstData) { try { const int ONE = 1; const int DCP = 1; const int MRP = 2; const int DCPOPTION = 3; int intRowCount; //Check MTR_CPO MTR_CPODS dsMTR_CPO = new MTR_CPODS(); intRowCount = dsMTR_CPO.CheckDCPResult(pintCycleOptionMasterID, ONE); if (intRowCount != 0) { return(DCP); } MTR_MPSCycleOptionMasterDS dsMTR_MPSCycleOptionMaster = new MTR_MPSCycleOptionMasterDS(); //Check DCPOption Result intRowCount = dsMTR_MPSCycleOptionMaster.CheckDCPOption(pintCycleOptionMasterID); if (intRowCount != 0) { return(DCPOPTION); } //Check MRP intRowCount = dsMTR_MPSCycleOptionMaster.CheckMRP(pintCycleOptionMasterID); if (intRowCount != 0) { return(MRP); } else { //Delete MTR_CPO dsMTR_CPO.DeleteByMPSCycleOptionMasterID(pintCycleOptionMasterID); foreach (DataRow drow in pdstData.Tables[0].Rows) { if (drow.RowState != DataRowState.Deleted) { drow.Delete(); } } //Delete Detail MTR_MPSCycleOptionDetailDS dsMTR_MPSCycleOptionDetail = new MTR_MPSCycleOptionDetailDS(); dsMTR_MPSCycleOptionDetail.UpdateDataSet(pdstData); //Delete Master dsMTR_MPSCycleOptionMaster.Delete(pintCycleOptionMasterID); } return(0); } catch (PCSDBException ex) { throw ex; } catch (Exception ex) { throw ex; } }
/// <summary> /// Add new for case : Convert CPO to new PO /// </summary> /// <param name="pobjMasterVO"></param> /// <param name="pdstDetail"></param> /// <param name="pdstDelivery"></param> ///<author>TuanDM</author> public void UpdatePOAndDelScheduleImmediate(object pobjMasterVO, System.Data.DataSet pdstDetail, DataSet pdstDelivery, ArrayList parlCPOIDs) { //Add Master and Get returning ID PO_PurchaseOrderMasterDS dsPOMaster = new PO_PurchaseOrderMasterDS(); dsPOMaster.Update(pobjMasterVO); var voMaster = (PO_PurchaseOrderMasterVO)pobjMasterVO; //Update detail DataSet dstPODetail = pdstDetail.Copy(); PO_PurchaseOrderDetailDS dsPODetail = new PO_PurchaseOrderDetailDS(); foreach (DataRow drowDetail in pdstDetail.Tables[0].Rows) { if (drowDetail.RowState == DataRowState.Added) { drowDetail[PO_PurchaseOrderDetailTable.PURCHASEORDERMASTERID_FLD] = ((PO_PurchaseOrderMasterVO)pobjMasterVO).PurchaseOrderMasterID; } } dsPODetail.UpdateDataSet(pdstDetail); //Get PODetail DataSet which includes PURCHASEORDERDETAILID_FLD pdstDetail = dsPODetail.ListToGetID(((PO_PurchaseOrderMasterVO)pobjMasterVO).PurchaseOrderMasterID); //Create DeliverySchedule -- and add DeliverySchedule int intPOLineID = 0; PO_DeliveryScheduleDS dsDelivery = new PO_DeliveryScheduleDS(); for (int i = 0; i < dstPODetail.Tables[0].Rows.Count; i++) { DataRow[] drowSameDelivery = pdstDelivery.Tables[0].Select(ITM_ProductTable.PRODUCTID_FLD + "='" + dstPODetail.Tables[0].Rows[i][ITM_ProductTable.PRODUCTID_FLD].ToString() + "'"); intPOLineID = (int)pdstDetail.Tables[0].Select(PO_PurchaseOrderDetailTable.LINE_FLD + "='" + dstPODetail.Tables[0].Rows[i][PO_PurchaseOrderDetailTable.LINE_FLD].ToString() + "'")[0][PO_PurchaseOrderDetailTable.PURCHASEORDERDETAILID_FLD]; DataSet dstNewDelPO = dsDelivery.GetDeliverySchedule(intPOLineID); int intbaseCount = dstNewDelPO.Tables[0].Rows.Count; for (int j = 0; j < drowSameDelivery.Length; j++) { int k = GetIndexForDeliveryLine(dstNewDelPO, (DateTime)drowSameDelivery[j][PO_DeliveryScheduleTable.SCHEDULEDATE_FLD]); if (k > -1) { dstNewDelPO.Tables[0].Rows[k][PO_DeliveryScheduleTable.DELIVERYQUANTITY_FLD] = (decimal)dstNewDelPO.Tables[0].Rows[k][PO_DeliveryScheduleTable.DELIVERYQUANTITY_FLD] + (decimal)drowSameDelivery[j][PO_DeliveryScheduleTable.DELIVERYQUANTITY_FLD]; } else { drowSameDelivery[j][PO_DeliveryScheduleTable.PURCHASEORDERDETAILID_FLD] = intPOLineID; drowSameDelivery[j][PO_DeliveryScheduleTable.DELIVERYLINE_FLD] = j + 1 + intbaseCount; dstNewDelPO.Tables[0].ImportRow(drowSameDelivery[j]); } } dsDelivery.UpdateDataSet(dstNewDelPO); } //Update CPODetail MTR_CPODS dsCPO = new MTR_CPODS(); dsCPO.SetPOMasterID(parlCPOIDs, ((PO_PurchaseOrderMasterVO)pobjMasterVO).PurchaseOrderMasterID); }
/// <summary> /// DeleteCycleOptionMasterAndDetail /// </summary> /// <param name="pintCycleOptionMasterID"></param> /// <param name="pdstData"></param> /// <author>Trada</author> /// <date>Thursday, August 11 2005</date> public void DeleteCycleOptionMasterAndDetail(int pintCCNID, int pintCycleOptionMasterID, DataSet pdstData) { foreach (DataRow drow in pdstData.Tables[0].Rows) { if (drow.RowState != DataRowState.Deleted) { drow.Delete(); } } //Delete Detail MTR_MRPCycleOptionDetailDS dsMTR_MRPCycleOptionDetail = new MTR_MRPCycleOptionDetailDS(); dsMTR_MRPCycleOptionDetail.UpdateDataSet(pdstData); //Delete MTR_CPO MTR_CPODS dsMTR_CPO = new MTR_CPODS(); dsMTR_CPO.Delete(pintCCNID, pintCycleOptionMasterID); //Delete Master MTR_MRPCycleOptionMasterDS dsMTR_MRPCycleOptionMaster = new MTR_MRPCycleOptionMasterDS(); dsMTR_MRPCycleOptionMaster.Delete(pintCycleOptionMasterID); }
/// <summary> /// Delete MRP result by list of CPO /// </summary> public void DeleteMRP(string pstrCPOIDs) { MTR_CPODS dsCPO = new MTR_CPODS(); dsCPO.Delete(pstrCPOIDs); }
/// <summary> /// Return the DataSet (list of record) by inputing the FieldList and Condition /// </summary> public void UpdateDataSet(DataSet dstData) { MTR_CPODS dsCPO = new MTR_CPODS(); dsCPO.UpdateDataSet(dstData); }
/// <summary> /// Add new for case : Convert CPO to new PO /// </summary> /// <param name="pobjMasterVO"></param> /// <param name="pdstDetail"></param> /// <param name="pdstDelivery"></param> ///<author>TuanDM</author> public int AddPOAndDelScheduleImmediate(object pobjMasterVO, System.Data.DataSet pdstDetail, DataSet pdstDelivery, ArrayList parlCPOIDs) { //Add Master and Get returning ID PO_PurchaseOrderMasterDS dsPOMaster = new PO_PurchaseOrderMasterDS(); int intMasterID = dsPOMaster.AddAndReturnID(pobjMasterVO); //Add detail foreach (DataRow drowDetail in pdstDetail.Tables[0].Rows) { drowDetail[PO_PurchaseOrderDetailTable.PURCHASEORDERMASTERID_FLD] = intMasterID; } PO_PurchaseOrderDetailDS dsPODetail = new PO_PurchaseOrderDetailDS(); dsPODetail.UpdateDataSet(pdstDetail); //Get PODetail DataSet which includes PURCHASEORDERDETAILID_FLD pdstDetail = dsPODetail.ListToGetID(intMasterID); //Create DeliverySchedule -- and add DeliverySchedule int intPOLineID = 0; int i = 0; PO_DeliveryScheduleDS dsDelivery = new PO_DeliveryScheduleDS(); while (i++ < pdstDetail.Tables[0].Rows.Count) { DataSet dstNewDelPO = pdstDelivery.Clone(); DataRow[] drowSameDelivery = pdstDelivery.Tables[0].Select(ITM_ProductTable.PRODUCTID_FLD + "='" + pdstDetail.Tables[0].Rows[i - 1][ITM_ProductTable.PRODUCTID_FLD].ToString() + "'"); intPOLineID = (int)pdstDetail.Tables[0].Rows[i - 1][PO_DeliveryScheduleTable.PURCHASEORDERDETAILID_FLD]; foreach (DataRow t in drowSameDelivery) { int k = GetIndexForDeliveryLine(dstNewDelPO, (DateTime)t[PO_DeliveryScheduleTable.SCHEDULEDATE_FLD]); if (k > -1) { dstNewDelPO.Tables[0].Rows[k][PO_DeliveryScheduleTable.DELIVERYQUANTITY_FLD] = (decimal)dstNewDelPO.Tables[0].Rows[k][PO_DeliveryScheduleTable.DELIVERYQUANTITY_FLD] + (decimal)t[PO_DeliveryScheduleTable.DELIVERYQUANTITY_FLD]; t[PO_DeliveryScheduleTable.PURCHASEORDERDETAILID_FLD] = intPOLineID; } else { t[PO_DeliveryScheduleTable.PURCHASEORDERDETAILID_FLD] = intPOLineID; t[PO_DeliveryScheduleTable.DELIVERYLINE_FLD] = dstNewDelPO.Tables[0].Rows.Count + 1; dstNewDelPO.Tables[0].ImportRow(t); } } dsDelivery.UpdateDataSet(dstNewDelPO); } //Update CPODetail MTR_CPODS dsCPO = new MTR_CPODS(); if (parlCPOIDs.Count > 0) { if (Convert.ToInt32(parlCPOIDs[0]) > 0) { dsCPO.SetPOMasterID(parlCPOIDs, intMasterID); } else { dsCPO.SetPOMasterIDForDCPDetail(parlCPOIDs, intMasterID); } } return(intMasterID); }
/// <summary> /// UpdateDataSetForDCP /// </summary> /// <param name="dstData"></param> /// <param name="pstrMasterIDToUpdate"></param> /// <param name="parrMasterIDToUpdate"></param> /// <author>Trada</author> /// <date>Monday, April 24 2006</date> public void UpdateDataSetForDCP(DataSet dstData, string pstrMasterIDToUpdate, ArrayList parrMasterIDToUpdate, int pintDCOptionMasterID) { //Get ShiftPattern for refer information PRO_ShiftPatternDS dsShiftPattern = new PRO_ShiftPatternDS(); DataSet dstShift = dsShiftPattern.List(); PRO_DCPResultDetailDS dsDCPResultDetail = new PRO_DCPResultDetailDS(); PRO_DCPResultMasterDS dsDCPResultMaster = new PRO_DCPResultMasterDS(); MTR_CPODS dsCPO = new MTR_CPODS(); //build a new dataset for new rows #region Clone dataset contain new rows DataSet dstNewDataSet = new DataSet(); DataSet dstModifiedDataSet = new DataSet(); dstNewDataSet = dstData.Clone(); dstModifiedDataSet = dstData.Clone(); foreach (DataRow drow in dstData.Tables[0].Rows) { if (drow.RowState == DataRowState.Added) { DataRow drowNew = dstNewDataSet.Tables[0].NewRow(); for (int i = 0; i < dstData.Tables[0].Columns.Count; i++) { drowNew[i] = drow[i]; } dstNewDataSet.Tables[0].Rows.Add(drowNew); } if (drow.RowState == DataRowState.Modified) { DataRow drowNew = dstModifiedDataSet.Tables[0].NewRow(); for (int i = 0; i < dstData.Tables[0].Columns.Count; i++) { drowNew[i] = drow[i]; } dstModifiedDataSet.Tables[0].Rows.Add(drowNew); } } #endregion //update data #region sort new dataset by productid and start time string strOrderby = ITM_ProductTable.PRODUCTID_FLD + "," + PRO_DCPResultDetailTable.STARTTIME_FLD; DataRow[] adrowNewDataSet = dstNewDataSet.Tables[0].Select(string.Empty, strOrderby); if (adrowNewDataSet.Length > 0) { #region Calculate and update Master Table int i = 0; while (i < adrowNewDataSet.Length) { int j = i; decimal decQuantity = decimal.Parse(adrowNewDataSet[0][PRO_DCPResultDetailTable.QUANTITY_FLD].ToString()); DateTime dtmStartDateTime = new DateTime(); dtmStartDateTime = (DateTime)adrowNewDataSet[i][MTR_CPOTable.STARTDATE_FLD]; while ((j < adrowNewDataSet.Length - 1) && (int.Parse(adrowNewDataSet[j][ITM_ProductTable.PRODUCTID_FLD].ToString()) == int.Parse(adrowNewDataSet[j + 1][ITM_ProductTable.PRODUCTID_FLD].ToString()))) { decQuantity += decimal.Parse(adrowNewDataSet[j + 1][PRO_DCPResultDetailTable.QUANTITY_FLD].ToString()); j = j + 1; } //assign value to VO PRO_DCPResultMasterVO voDCPResultMaster = new PRO_DCPResultMasterVO(); //voDCPResultMaster.DCOptionMasterID = intDCOptionMasterID; voDCPResultMaster.DCOptionMasterID = pintDCOptionMasterID; voDCPResultMaster.Quantity = decQuantity; voDCPResultMaster.StartDateTime = dtmStartDateTime; voDCPResultMaster.ProductID = int.Parse(adrowNewDataSet[i][ITM_ProductTable.PRODUCTID_FLD].ToString()); voDCPResultMaster.DueDateTime = (DateTime)adrowNewDataSet[j][MTR_CPOTable.DUEDATE_FLD]; voDCPResultMaster.RoutingID = int.Parse(adrowNewDataSet[i][ITM_RoutingTable.ROUTINGID_FLD].ToString()); voDCPResultMaster.WorkCenterID = int.Parse(adrowNewDataSet[i][MST_WorkCenterTable.WORKCENTERID_FLD].ToString()); //insert to database //insert to master table int intDCPResultMasterID = dsDCPResultMaster.AddAndReturnID(voDCPResultMaster); foreach (DataRow drowDetail in dstNewDataSet.Tables[0].Rows) { //set value of Converted column drowDetail[PRO_DCPResultDetailTable.WOCONVERTED_FLD] = false; //Set value of Start Time and End Time drowDetail[PRO_DCPResultDetailTable.STARTTIME_FLD] = drowDetail[MTR_CPOTable.STARTDATE_FLD]; drowDetail[PRO_DCPResultDetailTable.ENDTIME_FLD] = drowDetail[MTR_CPOTable.DUEDATE_FLD]; //set value of Working date to detail table DataRow[] adrowShift = dstShift.Tables[0].Select(PRO_ShiftPatternTable.SHIFTID_FLD + " = " + drowDetail[PRO_DCPResultDetailTable.SHIFTID_FLD].ToString()); if (adrowShift.Length > 0) { DateTime dtmWorkingDate = new DateTime(); dtmWorkingDate = GetDateOnly((DateTime)drowDetail[MTR_CPOTable.STARTDATE_FLD], (DateTime)adrowShift[0][PRO_ShiftPatternTable.WORKTIMEFROM_FLD], (DateTime)adrowShift[0][PRO_ShiftPatternTable.WORKTIMETO_FLD]); drowDetail[PRO_DCPResultDetailTable.WORKINGDATE_FLD] = GetDateOnly(dtmWorkingDate); } //set value of totalsecond to detail table //drowDetail[PRO_DCPResultDetailTable.TOTALSECOND_FLD] = GetTotalSecond(int.Parse(drowDetail[PRO_DCPResultDetailTable.SHIFTID_FLD].ToString()), dstShift, (DateTime)drowDetail[PRO_DCPResultDetailTable.STARTTIME_FLD], (DateTime)drowDetail[PRO_DCPResultDetailTable.ENDTIME_FLD]); //set value of percentage to detail table drowDetail[PRO_DCPResultDetailTable.PERCENTAGE_FLD] = 100 * Decimal.Parse(drowDetail[PRO_DCPResultDetailTable.QUANTITY_FLD].ToString()) / decQuantity; //set value of MasterID to Detail Table if (int.Parse(drowDetail[ITM_ProductTable.PRODUCTID_FLD].ToString()) == int.Parse(adrowNewDataSet[i][ITM_ProductTable.PRODUCTID_FLD].ToString())) { drowDetail[PRO_DCPResultMasterTable.DCPRESULTMASTERID_FLD] = intDCPResultMasterID; } } i = j + 1; } #endregion //update detail to database dsDCPResultDetail.UpdateDataSetManual(dstNewDataSet); } #endregion //Remove new rows //delete row has status is add new #region delete row has status is add new DataRow[] adrowToDelete = dstData.Tables[0].Select(string.Empty, string.Empty, DataViewRowState.Added); for (int i = 0; i < adrowToDelete.Length; i++) { adrowToDelete[i].Delete(); } #endregion foreach (DataRow drow in dstModifiedDataSet.Tables[0].Rows) { Int64 intDCPResultMasterToEdit = 0; if (drow[PRO_DCPResultMasterTable.DCPRESULTMASTERID_FLD].ToString() != string.Empty) { intDCPResultMasterToEdit = Convert.ToInt64(drow[PRO_DCPResultDetailTable.DCPRESULTMASTERID_FLD]); } #region sort Modified dataset by productid and start time string strOrderbyCond = PRO_DCPResultDetailTable.DCPRESULTMASTERID_FLD + "," + PRO_DCPResultDetailTable.STARTTIME_FLD; DataRow[] adrowModifiedDataSet = dstData.Tables[0].Select(PRO_DCPResultDetailTable.DCPRESULTMASTERID_FLD + " = " + intDCPResultMasterToEdit.ToString(), strOrderbyCond); if (adrowModifiedDataSet.Length > 0) { #region Calculate and update Master Table int i = 0; while (i < adrowModifiedDataSet.Length) { int j = i; decimal decQuantity = decimal.Parse(adrowModifiedDataSet[0][PRO_DCPResultDetailTable.QUANTITY_FLD].ToString()); DateTime dtmStartDateTime = new DateTime(); dtmStartDateTime = (DateTime)adrowModifiedDataSet[i][MTR_CPOTable.STARTDATE_FLD]; while ((j < adrowModifiedDataSet.Length - 1) && (int.Parse(adrowModifiedDataSet[j][PRO_DCPResultDetailTable.DCPRESULTMASTERID_FLD].ToString()) == int.Parse(adrowModifiedDataSet[j + 1][PRO_DCPResultDetailTable.DCPRESULTMASTERID_FLD].ToString()))) { decQuantity += decimal.Parse(adrowModifiedDataSet[j + 1][PRO_DCPResultDetailTable.QUANTITY_FLD].ToString()); j = j + 1; } //assign value to VO PRO_DCPResultMasterVO voDCPResultMaster = new PRO_DCPResultMasterVO(); //voDCPResultMaster.DCOptionMasterID = intDCOptionMasterID; //voDCPResultMaster.DCOptionMasterID = pintDCOptionMasterID; voDCPResultMaster.DCPResultMasterID = int.Parse(adrowModifiedDataSet[i][PRO_DCPResultDetailTable.DCPRESULTMASTERID_FLD].ToString()); voDCPResultMaster.Quantity = decQuantity; voDCPResultMaster.StartDateTime = dtmStartDateTime; //voDCPResultMaster.ProductID = int.Parse(adrowNewDataSet[i][ITM_ProductTable.PRODUCTID_FLD].ToString()); voDCPResultMaster.DueDateTime = (DateTime)adrowModifiedDataSet[j][MTR_CPOTable.DUEDATE_FLD]; //insert to database //insert to master table dsDCPResultMaster.Update(voDCPResultMaster); foreach (DataRow drowDetail in adrowModifiedDataSet) { //set value of Converted column //drowDetail[PRO_DCPResultDetailTable.WOCONVERTED_FLD] = false; //Set value of Start Time and End Time drowDetail[PRO_DCPResultDetailTable.STARTTIME_FLD] = drowDetail[MTR_CPOTable.STARTDATE_FLD]; drowDetail[PRO_DCPResultDetailTable.ENDTIME_FLD] = drowDetail[MTR_CPOTable.DUEDATE_FLD]; //set value of Working date to detail table DataRow[] adrowShift = dstShift.Tables[0].Select(PRO_ShiftPatternTable.SHIFTID_FLD + " = " + drowDetail[PRO_DCPResultDetailTable.SHIFTID_FLD].ToString()); if (adrowShift.Length > 0) { DateTime dtmWorkingDate = new DateTime(); dtmWorkingDate = GetDateOnly((DateTime)drowDetail[MTR_CPOTable.STARTDATE_FLD], (DateTime)adrowShift[0][PRO_ShiftPatternTable.WORKTIMEFROM_FLD], (DateTime)adrowShift[0][PRO_ShiftPatternTable.WORKTIMETO_FLD]); drowDetail[PRO_DCPResultDetailTable.WORKINGDATE_FLD] = GetDateOnly(dtmWorkingDate); } //set value of totalsecond to detail table //drowDetail[PRO_DCPResultDetailTable.TOTALSECOND_FLD] = GetTotalSecond(int.Parse(drowDetail[PRO_DCPResultDetailTable.SHIFTID_FLD].ToString()), dstShift, (DateTime)drowDetail[PRO_DCPResultDetailTable.STARTTIME_FLD], (DateTime)drowDetail[PRO_DCPResultDetailTable.ENDTIME_FLD]); //set value of percentage to detail table drowDetail[PRO_DCPResultDetailTable.PERCENTAGE_FLD] = 100 * Decimal.Parse(drowDetail[PRO_DCPResultDetailTable.QUANTITY_FLD].ToString()) / decQuantity; } i = j + 1; } #endregion //update detail to database dsDCPResultDetail.UpdateDataSetManual(dstData); } #endregion } #region Update DataSet (old code) dsCPO.UpdateDataSetForDCP(dstData); #endregion #region Delete master Table for delete multi-rows event //Update Master Table //First, we get detail and master table from database for re-calculating master information if (parrMasterIDToUpdate.Count > 0) { string strMasterIDToDelete = "0"; DataSet dstDCPResultDetailAfterSaving = new DataSet(); DataSet dstDCPResultMaster = new DataSet(); //Master Table dstDCPResultMaster = dsDCPResultMaster.GetDCPResultMasterByArrayMasterID(pstrMasterIDToUpdate); //Detail table dstDCPResultDetailAfterSaving = dsDCPResultDetail.GetDCPResultDetailByMasterID(pstrMasterIDToUpdate); if (dstDCPResultDetailAfterSaving.Tables[0].Rows.Count > 0) { if (parrMasterIDToUpdate.Count > 0) { for (int i = 0; i < parrMasterIDToUpdate.Count; i++) { //Select Detail for each masterID DataRow[] adrowDetailByMasterID = dstDCPResultDetailAfterSaving.Tables[0].Select(PRO_DCPResultDetailTable.DCPRESULTMASTERID_FLD + " = " + parrMasterIDToUpdate[i].ToString(), PRO_DCPResultDetailTable.STARTTIME_FLD); //Select Master for each masterID DataRow[] adrowMasterByMasterID = dstDCPResultMaster.Tables[0].Select(PRO_DCPResultMasterTable.DCPRESULTMASTERID_FLD + " = " + parrMasterIDToUpdate[i].ToString()); if (adrowDetailByMasterID.Length > 0) //Update Master { if (adrowMasterByMasterID.Length > 0) { decimal decQuantityMaster = 0; for (int j = 0; j < adrowDetailByMasterID.Length; j++) { if ((adrowDetailByMasterID[j][PRO_DCPResultDetailTable.QUANTITY_FLD] != null) && (adrowDetailByMasterID[j][PRO_DCPResultDetailTable.QUANTITY_FLD] != DBNull.Value)) { decQuantityMaster += decimal.Parse(adrowDetailByMasterID[j][PRO_DCPResultDetailTable.QUANTITY_FLD].ToString()); } } adrowMasterByMasterID[0][PRO_DCPResultMasterTable.QUANTITY_FLD] = decQuantityMaster; adrowMasterByMasterID[0][PRO_DCPResultMasterTable.STARTDATETIME_FLD] = (DateTime)adrowDetailByMasterID[0][PRO_DCPResultDetailTable.STARTTIME_FLD]; adrowMasterByMasterID[0][PRO_DCPResultMasterTable.DUEDATETIME_FLD] = (DateTime)adrowDetailByMasterID[adrowDetailByMasterID.Length - 1][PRO_DCPResultDetailTable.ENDTIME_FLD]; } } else { //Save MasterID to Delete strMasterIDToDelete += "," + parrMasterIDToUpdate[i].ToString(); } } } //Update Master dsDCPResultMaster.UpdateDataSetDeleteMultiRows(dstDCPResultMaster); //Delete Master dsDCPResultMaster.DeleteMultiRows(strMasterIDToDelete); } else { //Delete Master dsDCPResultMaster.DeleteMultiRows(pstrMasterIDToUpdate); } } #endregion }