/// <summary> /// 根据所选的PO物资带出对应值 /// </summary> /// <param name="dtReceiveMaterial"></param> public void GetPOMaterialInfo(DataTable dtReceiveMaterial, string sWHID) { string sSelectSql = string.Empty; DataTable dtPOMaterial; CEntityUitlity cEntity = new CEntityUitlity(); string sItemCode = string.Empty; string BINID = GetBINIDFromWHID(sWHID); //dtReceiveMaterial.DefaultView.Sort = "POLine,ItemCode"; // 需要计算可收数量 foreach (DataRow dr in dtReceiveMaterial.Rows) { //-------------add by wudi---------2007-8-8------------- if (dr.RowState != DataRowState.Deleted) { // 查询基本 sSelectSql = @" SELECT POMaterial.MaterialUomID ,POMaterial.ItemCode,POMaterial.ReceiveBaseQuantity,MaterialUom.UOMID, POMaterial.PartNo , POMaterial.UnitPrice , POMaterial.POQuantity ,Material.MaterialName,POMaterial.MRNO,POMaterial.POLine,POMaterial.Remark FROM POMaterial INNER JOIN MaterialUOM ON POMaterial.MaterialUomID = MaterialUOM.MaterialUomID INNER JOIN Material ON Material.ItemCode = POMaterial.ItemCode WHERE POMaterialID = '" + dr["POMaterialID"].ToString() + "' ORDER BY POMaterial.POLine,POMaterial.ItemCode"; dtPOMaterial = this.BaseDataAccess.GetDataTable(sSelectSql); if (dtPOMaterial.Rows.Count > 0) { dr["MaterialUomID"] = dtPOMaterial.Rows[0]["MaterialUomID"]; dr["WH_ReceiveMaterial__MaterialUomID"] = dtPOMaterial.Rows[0]["UOMID"]; dr["PartNO"] = dtPOMaterial.Rows[0]["PartNo"]; dr["UnitPrice"] = dtPOMaterial.Rows[0]["UnitPrice"]; dr["POQuantity"] = dtPOMaterial.Rows[0]["POQuantity"]; dr["ItemCode"] = dtPOMaterial.Rows[0]["ItemCode"].ToString(); dr["MaterialName"] = dtPOMaterial.Rows[0]["MaterialName"].ToString(); //dr["WH_ReceiveMaterial__BINID"] = BINID; //dr["BINID"] = BINID; dr["Comment"] = dtPOMaterial.Rows[0]["Remark"].ToString(); dr["POLine"] = dtPOMaterial.Rows[0]["POLine"].ToString(); if (dtPOMaterial.Rows[0]["ReceiveBaseQuantity"] == DBNull.Value || Convert.ToDecimal(dtPOMaterial.Rows[0]["ReceiveBaseQuantity"]) == 0) { dr["ReceivedQuantity"] = 0; dr["CanReceivedQuantity"] = dr["POQuantity"]; } else { // 将已收数量转换为当前的单位 decimal fReceivedQuattity = cEntity.ChangeFromBaseUON(dtPOMaterial.Rows[0]["ItemCode"].ToString(), dtPOMaterial.Rows[0]["MaterialUomID"].ToString(), Convert.ToDecimal(dtPOMaterial.Rows[0]["ReceiveBaseQuantity"])); dr["ReceivedQuantity"] = fReceivedQuattity; dr["CanReceivedQuantity"] = Convert.ToDecimal(dr["POQuantity"]) - fReceivedQuattity; } } } } }
/// <summary> /// 根据所选的PO物资带出对应值 /// </summary> /// <param name="dtReceiveMaterial"></param> public void GetPOMaterialInfo(DataTable dtReceiveMaterial, string sPOID) { string sSelectSql = string.Empty; DataTable dtPOMaterial; CEntityUitlity cEntity = new CEntityUitlity(); string sItemCode = string.Empty; // 需要计算可收数量 foreach (DataRow dr in dtReceiveMaterial.Rows) { if (dr.RowState != DataRowState.Deleted) { // 查询基本 sSelectSql = @" SELECT POMaterial.MaterialUomID ,POMaterial.ItemCode,POMaterial.ReceiveBaseQuantity,MaterialUom.UOMID,MaterialUom.UomID, POMaterial.PartNo , POMaterial.UnitPrice , POMaterial.TotalCost, POMaterial.POQuantity ,Material.MaterialName FROM POMaterial INNER JOIN MaterialUOM ON POMaterial.MaterialUomID = MaterialUOM.MaterialUomID INNER JOIN Material ON Material.ItemCode = POMaterial.ItemCode WHERE POID = '" + sPOID + "' AND POMaterialID = '" + dr["POMaterialID"].ToString() + "'"; dtPOMaterial = this.BaseDataAccess.GetDataTable(sSelectSql); dr["MaterialUomID"] = dtPOMaterial.Rows[0]["MaterialUomID"]; dr["WH_ReceiveMaterial__MaterialUomID"] = dtPOMaterial.Rows[0]["UomID"]; dr["PartNO"] = dtPOMaterial.Rows[0]["PartNo"]; dr["UnitPrice"] = dtPOMaterial.Rows[0]["UnitPrice"]; dr["POQuantity"] = dtPOMaterial.Rows[0]["POQuantity"]; dr["ItemCode"] = dtPOMaterial.Rows[0]["ItemCode"].ToString(); dr["MaterialName"] = dtPOMaterial.Rows[0]["MaterialName"].ToString(); if (dtPOMaterial.Rows[0]["ReceiveBaseQuantity"] == DBNull.Value || Convert.ToDecimal(dtPOMaterial.Rows[0]["ReceiveBaseQuantity"]) == 0) { dr["ReceivedQuantity"] = 0; dr["CanReceivedQuantity"] = dr["POQuantity"]; } else { // 将已收数量转换为当前的单位 decimal fReceivedQuattity = cEntity.ChangeFromBaseUON(dtPOMaterial.Rows[0]["ItemCode"].ToString(), dtPOMaterial.Rows[0]["MaterialUomID"].ToString(), Convert.ToDecimal(dtPOMaterial.Rows[0]["ReceiveBaseQuantity"])); dr["ReceivedQuantity"] = fReceivedQuattity; dr["CanReceivedQuantity"] = Convert.ToDecimal(dr["POQuantity"]) - fReceivedQuattity; } } } }