/// <summary> /// Delete the Master by ID : - Delete Detail /// - Delete Master /// </summary> /// <param name="pobjMaster"></param> public void DeleteMasterAndDetail(object pobjMaster) { try { SO_CustomerItemRefMasterDS dsMaster = new SO_CustomerItemRefMasterDS(); SO_CustomerItemRefDetailDS dsDetail = new SO_CustomerItemRefDetailDS(); if (((SO_CustomerItemRefMasterVO)pobjMaster).CustomerItemRefMasterID != 0) { //Delete detail DataSet dstData = dsDetail.List(((SO_CustomerItemRefMasterVO)pobjMaster).PartyID, ((SO_CustomerItemRefMasterVO)pobjMaster).CCNID); foreach (DataRow drowDetail in dstData.Tables[0].Rows) { if (drowDetail.RowState != DataRowState.Deleted) { drowDetail.Delete(); } } dsDetail.UpdateDataSet(dstData); } //Delete Master dsMaster.Delete(((SO_CustomerItemRefMasterVO)pobjMaster).CustomerItemRefMasterID); } catch (PCSDBException ex) { throw ex; } catch (Exception ex) { throw ex; } }
/// <summary> /// Add Master & Detail Of Customer reference /// </summary> /// <param name="pobjMaster"></param> /// <param name="pdstDetail"></param> public void UpdateMasterAndDetail(object pobjMaster, DataSet pdstDetail) { try { SO_CustomerItemRefMasterDS dsMaster = new SO_CustomerItemRefMasterDS(); SO_CustomerItemRefDetailDS dsDetail = new SO_CustomerItemRefDetailDS(); int intMasterID = ((SO_CustomerItemRefMasterVO)pobjMaster).CustomerItemRefMasterID; if (intMasterID == 0) { //Add Master intMasterID = dsMaster.AddAndReturnID(pobjMaster); } else { //Update Master dsMaster.Update(pobjMaster); } //Add Detail for (int i = 0; i < pdstDetail.Tables[0].Rows.Count; i++) { if (pdstDetail.Tables[0].Rows[i].RowState == DataRowState.Added) { pdstDetail.Tables[0].Rows[i][SO_CustomerItemRefDetailTable.CUSTOMERITEMREFMASTERID_FLD] = intMasterID; } } dsDetail.UpdateDataSet(pdstDetail); } catch (PCSDBException ex) { throw ex; } catch (Exception ex) { throw ex; } }