public bool CheckLevelApproval(int pintApproverID, int pintMasterID, int pintCCNID) { PO_PurchaseOrderDetailDS dsPurchaseOrderDetail = new PO_PurchaseOrderDetailDS(); DataSet dstApprovalLevel = new DataSet(); dstApprovalLevel = dsPurchaseOrderDetail.GetApprovalLevel(pintApproverID); PO_PurchaseOrderMasterDS dsPurchaseOrderMaster = new PO_PurchaseOrderMasterDS(); dstApprovalLevel.Tables.Add(dsPurchaseOrderMaster.ListPODetailByPOMasterID(pintMasterID, pintCCNID, false).Tables[0].Copy()); for (int i = 0; i < dstApprovalLevel.Tables[0].Rows.Count; i++) { decimal amount = 0, total = 0; if (dstApprovalLevel.Tables[0].Rows[i][MST_ApprovalLevelTable.AMOUNT_FLD].ToString().Trim() != String.Empty) { amount = decimal.Parse(dstApprovalLevel.Tables[0].Rows[i][MST_ApprovalLevelTable.AMOUNT_FLD].ToString()); } if (dstApprovalLevel.Tables[1].Rows[i][PO_PurchaseOrderDetailTable.TOTALAMOUNT_FLD].ToString().Trim() != String.Empty) { total = decimal.Parse(dstApprovalLevel.Tables[1].Rows[i][PO_PurchaseOrderDetailTable.TOTALAMOUNT_FLD].ToString()); } if (amount < total) { return(false); } else { return(true); } } return(true); }
/// <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); }
public DataSet ListPODetailByPOMasterID(int pintPOMasterID, int pintCCNID, bool pblnApproved) { try { DataSet dstApprover = new DataSet(); PO_PurchaseOrderMasterDS dsPurchaseOrderMaster = new PO_PurchaseOrderMasterDS(); //Table[0] has got 2 fields PurchaseOrderDetailID, ReceiveAmount dstApprover.Tables.Add(dsPurchaseOrderMaster.ListPODetailByMasterIDOfPOReceiptDetail(pintPOMasterID, pblnApproved).Tables[0].Copy()); //Table[1] has got 12 fields PONo, PurchaseOrderDetailID, Line, Code, Description, Revision, BuyingUM, OrderQuantity, AvailableQty, Currency, TotalAmount and openAmount dstApprover.Tables.Add(dsPurchaseOrderMaster.ListPODetailByPOMasterID(pintPOMasterID, pintCCNID, pblnApproved).Tables[0].Copy()); dstApprover.Tables[1].Columns.Add(OPEN_AMOUNT, typeof(decimal)); //find rows to compare and insert value to openAmount field if (dstApprover.Tables[0].Rows.Count == 0) { foreach (DataRow drowTable1 in dstApprover.Tables[1].Rows) { drowTable1[OPEN_AMOUNT] = decimal.Parse(drowTable1[PO_PurchaseOrderDetailTable.TOTALAMOUNT_FLD].ToString()); } } else { foreach (DataRow drowTable1 in dstApprover.Tables[1].Rows) { foreach (DataRow drowTable0 in dstApprover.Tables[0].Rows) { if (drowTable0[PO_PurchaseOrderDetailTable.PURCHASEORDERDETAILID_FLD].ToString() == drowTable1[PO_PurchaseOrderDetailTable.PURCHASEORDERDETAILID_FLD].ToString()) { if (drowTable0[RECEIVE_AMOUNT].ToString() != string.Empty) { drowTable1[OPEN_AMOUNT] = decimal.Parse(drowTable1[PO_PurchaseOrderDetailTable.TOTALAMOUNT_FLD].ToString()) - decimal.Parse(drowTable0[RECEIVE_AMOUNT].ToString()); } else { drowTable1[OPEN_AMOUNT] = decimal.Parse(drowTable1[PO_PurchaseOrderDetailTable.TOTALAMOUNT_FLD].ToString()); } } } } } return(dstApprover); } catch (PCSDBException ex) { throw ex; } catch (Exception ex) { throw ex; } }
public void DeletePurchaseOrder(int pintMasterID) { PO_PurchaseOrderDetailDS dsDetail = new PO_PurchaseOrderDetailDS(); DataSet dstDetail = dsDetail.List(pintMasterID); foreach (DataRow drow in dstDetail.Tables[0].Rows) { dsDetail.Delete(int.Parse(drow[PO_PurchaseOrderDetailTable.PURCHASEORDERDETAILID_FLD].ToString())); } PO_PurchaseOrderMasterDS dsMaster = new PO_PurchaseOrderMasterDS(); dsMaster.Delete(pintMasterID); }
/// <summary> /// Update PO and Delivery Schedule in case : CPO to Exist PO /// </summary> /// <param name="pdstCPODetail"></param> /// <param name="pobjMasterVO"></param> /// <param name="pdstDetail"></param> /// <author>TuanDM</author> public void UpdatePOAndDelSchedule(System.Data.DataSet pdstCPODetail, object pobjMasterVO, System.Data.DataSet pdstDetail) { //Update PO Master PO_PurchaseOrderMasterDS dsMaster = new PO_PurchaseOrderMasterDS(); dsMaster.Update(pobjMasterVO); //Update PO Detail ArrayList arlIndexs = new ArrayList(); ArrayList arlDueDate = new ArrayList(); int intinD = -1; if (pdstDetail != null) { foreach (DataRow objRow in pdstDetail.Tables[0].Rows) { intinD++; if (objRow.RowState == DataRowState.Deleted) { continue; } objRow[PO_PurchaseOrderDetailTable.PURCHASEORDERMASTERID_FLD] = ((PO_PurchaseOrderMasterVO)pobjMasterVO).PurchaseOrderMasterID; if (objRow[PO_DeliveryScheduleTable.SCHEDULEDATE_FLD].ToString() != string.Empty) { arlDueDate.Add(objRow[PO_DeliveryScheduleTable.SCHEDULEDATE_FLD]); arlIndexs.Add(intinD); } } } PO_PurchaseOrderDetailDS dsDetail = new PO_PurchaseOrderDetailDS(); dsDetail.UpdateDataSet(pdstDetail); //Update DeliverySchedule pdstDetail = dsDetail.List(((PO_PurchaseOrderMasterVO)pobjMasterVO).PurchaseOrderMasterID); //Create DeliverySchedule -- and add DeliverySchedule for (int i = 0; i < arlIndexs.Count; i++) { PO_DeliveryScheduleVO voSchedule = new PO_DeliveryScheduleVO(); voSchedule.DeliveryLine = 1; voSchedule.PurchaseOrderDetailID = int.Parse(pdstDetail.Tables[0].Rows[int.Parse(arlIndexs[i].ToString())][PO_DeliveryScheduleTable.PURCHASEORDERDETAILID_FLD].ToString()); voSchedule.ScheduleDate = DateTime.Parse(arlDueDate[i].ToString()); voSchedule.DeliveryQuantity = decimal.Parse(pdstDetail.Tables[0].Rows[int.Parse(arlIndexs[i].ToString())][PO_PurchaseOrderDetailTable.ORDERQUANTITY_FLD].ToString()); new PO_DeliveryScheduleDS().Add(voSchedule); } //Update CPODetail new MTR_CPODS().SetPOMasterID(null, ((PO_PurchaseOrderMasterVO)pobjMasterVO).PurchaseOrderMasterID); }
public DateTime GetOrderDateByPOMasterID(int pintPOMasterID) { try { PO_PurchaseOrderMasterDS dsPO_PurchaseOrderMaster = new PO_PurchaseOrderMasterDS(); return(dsPO_PurchaseOrderMaster.GetOrderDateByPOMasterID(pintPOMasterID)); } catch (PCSDBException ex) { throw ex; } catch (Exception ex) { throw ex; } }
//************************************************************************** /// <Description> /// This method uses to get PO_PurchaseOrderMasterVO object from ID /// </Description> /// <Inputs> /// int /// </Inputs> /// <Outputs> /// PO_PurchaseOrderMasterVO /// </Outputs> /// <Returns> /// PO_PurchaseOrderMasterVO /// </Returns> /// <Authors> /// DungLa /// </Authors> /// <History> /// 07-Mar-2005 /// </History> /// <Notes> /// </Notes> //************************************************************************** public object GetPOMasterVO(int pintPOMasterID) { try { PO_PurchaseOrderMasterDS dsPOMaster = new PO_PurchaseOrderMasterDS(); return(dsPOMaster.GetObjectVO(pintPOMasterID)); } catch (PCSException ex) { throw ex; } catch (Exception ex) { throw ex; } }
/// <summary> /// Delete purchase order of estimate month /// </summary> /// <param name="pdtmFromDate">From Date</param> /// <param name="pdtmToDate">To Date</param> /// <param name="pintPOType">Purchase Type</param> /// <param name="pstrVendorID">Vendor List</param> /// <param name="pstrItemID">Item list</param> public void DeleteEstimatePO(DateTime pdtmFromDate, DateTime pdtmToDate, int pintPOType, string pstrVendorID, string pstrItemID) { PO_PurchaseOrderMasterDS dsMaster = new PO_PurchaseOrderMasterDS(); // get list of purchase order master ID to be delete DataTable dtbMaster = dsMaster.ListMasterToDelete(pdtmFromDate, pdtmToDate, pintPOType, pstrItemID, pstrItemID).Tables[0]; string strMasterId = dtbMaster.Rows.Cast <DataRow>().Aggregate("0", (current, drowMaster) => current + ("," + drowMaster[PO_PurchaseOrderMasterTable.PURCHASEORDERMASTERID_FLD])); // delete delivery schedule first PO_DeliveryScheduleDS dsSchedule = new PO_DeliveryScheduleDS(); dsSchedule.DeleteByPOMaster(strMasterId); // delete purchase order detail PO_PurchaseOrderDetailDS dsDetail = new PO_PurchaseOrderDetailDS(); dsDetail.DeleteByMaster(strMasterId); // delete purchase order master dsMaster.Delete(strMasterId); }
/// <summary> /// CheckReferenceAndRevisionNo /// </summary> /// <param name="pstrReferenceNo"></param> /// <param name="pstrRevision"></param> /// <returns></returns> /// <author>Trada</author> /// <date>Friday, September 22 2006</date> public bool CheckReferenceAndRevisionNo(string pstrReferenceNo, string pstrRevision, int pintPOMasterID) { PO_PurchaseOrderMasterDS dsPurchaseOrderMaster = new PO_PurchaseOrderMasterDS(); DataSet dstCount = new DataSet(); dstCount = dsPurchaseOrderMaster.CheckReferenceAndRevisionNo(pstrReferenceNo, pstrRevision, pintPOMasterID); if (dstCount.Tables[0].Rows.Count > 0) { if (int.Parse(dstCount.Tables[0].Rows[0][0].ToString()) > 0) { return(false); } } return(true); }
public int GetPurchaseOrderMasterID(string pstrCode) { try { PO_PurchaseOrderMasterDS dsMasterBlank = new PO_PurchaseOrderMasterDS(); PO_PurchaseOrderMasterVO voMasterBlank = new PO_PurchaseOrderMasterVO(); voMasterBlank = (PO_PurchaseOrderMasterVO)dsMasterBlank.GetObjectVO(pstrCode); return(voMasterBlank.PurchaseOrderMasterID); } catch (PCSDBException ex) { throw ex; } catch (Exception ex) { throw ex; } }
public int AddNewPurchaseOrder(object pvoPOMaster, DataSet pdstPODetail) { PO_PurchaseOrderMasterDS dsMaster = new PO_PurchaseOrderMasterDS(); int intPOMasterID = dsMaster.AddAndReturnID(pvoPOMaster); foreach (DataRow objRow in pdstPODetail.Tables[0].Rows) { if (objRow.RowState == DataRowState.Deleted) { continue; } objRow[PO_PurchaseOrderDetailTable.PURCHASEORDERMASTERID_FLD] = intPOMasterID; } PO_PurchaseOrderDetailDS dsDetail = new PO_PurchaseOrderDetailDS(); dsDetail.UpdateDataSet(pdstPODetail); return(intPOMasterID); }
public void UpdatePurchaseOrder(object pvoPOMaster, DataSet pdstDetail) { PO_PurchaseOrderMasterDS dsMaster = new PO_PurchaseOrderMasterDS(); dsMaster.Update(pvoPOMaster); if (pdstDetail != null) { foreach (DataRow objRow in pdstDetail.Tables[0].Rows) { if (objRow.RowState == DataRowState.Deleted) { continue; } objRow[PO_PurchaseOrderDetailTable.PURCHASEORDERMASTERID_FLD] = ((PO_PurchaseOrderMasterVO)pvoPOMaster).PurchaseOrderMasterID; } } PO_PurchaseOrderDetailDS dsDetail = new PO_PurchaseOrderDetailDS(); dsDetail.UpdateDataSet(pdstDetail); }
/// <summary> /// Add new for case : Convert CPO to new PO /// </summary> /// <param name="pdstCPODetail"></param> /// <param name="pobjMasterVO"></param> /// <param name="pdstDetail"></param> ///<author>TuanDM</author> public int AddPOAndDelSchedule(System.Data.DataSet pdstCPODetail, object pobjMasterVO, System.Data.DataSet pdstDetail) { //Add Master and Get returning ID PO_PurchaseOrderMasterDS dsPOMaster = new PO_PurchaseOrderMasterDS(); int intMasterID = dsPOMaster.AddAndReturnID(pobjMasterVO); //Add detail ArrayList arlDueDate = new ArrayList(); foreach (DataRow drowDetail in pdstDetail.Tables[0].Rows) { drowDetail[PO_PurchaseOrderDetailTable.PURCHASEORDERMASTERID_FLD] = intMasterID; arlDueDate.Add(drowDetail[PO_DeliveryScheduleTable.SCHEDULEDATE_FLD].ToString()); } PO_PurchaseOrderDetailDS dsPODetail = new PO_PurchaseOrderDetailDS(); dsPODetail.UpdateDataSet(pdstDetail); //Get PODetail DataSet which includes PURCHASEORDERDETAILID_FLD pdstDetail = dsPODetail.List(intMasterID); //Create DeliverySchedule -- and add DeliverySchedule PO_DeliveryScheduleVO voSchedule; for (int i = 0; i < pdstDetail.Tables[0].Rows.Count; i++) { voSchedule = new PO_DeliveryScheduleVO(); voSchedule.DeliveryLine = 1; voSchedule.PurchaseOrderDetailID = int.Parse(pdstDetail.Tables[0].Rows[i][PO_PurchaseOrderDetailTable.PURCHASEORDERDETAILID_FLD].ToString()); voSchedule.ScheduleDate = DateTime.Parse(arlDueDate[i].ToString()); voSchedule.DeliveryQuantity = decimal.Parse(pdstDetail.Tables[0].Rows[i][PO_PurchaseOrderDetailTable.ORDERQUANTITY_FLD].ToString()); new PO_DeliveryScheduleDS().Add(voSchedule); } //Update CPODetail new MTR_CPODS().SetPOMasterID(null, intMasterID); //return ID return(intMasterID); }
public DataRow GetDataRow(string pstrKeyField, string pstrValue, string pstrTable, string pstrField, string pstrCodition) { PO_PurchaseOrderMasterDS dsMaster = new PO_PurchaseOrderMasterDS(); return(dsMaster.GetDataRow(pstrKeyField, pstrValue, pstrTable, pstrField, pstrCodition)); }
public object GetPurchaseOrderByCode(string pstrCode) { PO_PurchaseOrderMasterDS dsMaster = new PO_PurchaseOrderMasterDS(); return(dsMaster.GetObjectVO(pstrCode)); }
public int IsValidateData(string pstrValue, string pstrTable, string pstrField, string pstrCodition) { PO_PurchaseOrderMasterDS dsMaster = new PO_PurchaseOrderMasterDS(); return(dsMaster.IsValidateData(pstrValue, pstrTable, pstrField, pstrCodition)); }
public DataRow LoadObjectVO(int pintID) { PO_PurchaseOrderMasterDS dsMaster = new PO_PurchaseOrderMasterDS(); return(dsMaster.LoadObjectVO(pintID)); }
/// <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); }
public object GetMasterVO(int pintPOMasterID) { PO_PurchaseOrderMasterDS dsMaster = new PO_PurchaseOrderMasterDS(); return(dsMaster.GetObjectVO(pintPOMasterID)); }