コード例 #1
0
        /// <summary>
        /// Process
        /// VFramwork.Process.SvrProcess#doIt()
        /// </summary>
        /// <returns>message</returns>
        protected override String DoIt()
        {
            log.Info("doIt - From_RfQ_ID=" + _From_RfQ_ID + ", To_RfQ_ID=" + p_To_RfQ_ID);
            //
            MRfQ to = new MRfQ(GetCtx(), p_To_RfQ_ID, Get_TrxName());

            if (to.Get_ID() == 0)
            {
                throw new ArgumentException("No To RfQ found");
            }
            MRfQ from = new MRfQ(GetCtx(), _From_RfQ_ID, Get_TrxName());

            if (from.Get_ID() == 0)
            {
                throw new ArgumentException("No From RfQ found");
            }

            //	Copy Lines
            int counter = 0;

            MRfQLine[] lines = from.GetLines();
            for (int i = 0; i < lines.Length; i++)
            {
                MRfQLine newLine = new MRfQLine(to);
                newLine.SetLine(lines[i].GetLine());
                newLine.SetDescription(lines[i].GetDescription());
                newLine.SetHelp(lines[i].GetHelp());
                newLine.SetM_Product_ID(lines[i].GetM_Product_ID());
                newLine.SetM_AttributeSetInstance_ID(lines[i].GetM_AttributeSetInstance_ID());
                //	newLine.setDateWorkStart();
                //	newLine.setDateWorkComplete();
                newLine.SetDeliveryDays(lines[i].GetDeliveryDays());
                newLine.Save();
                //	Copy Qtys
                MRfQLineQty[] qtys = lines[i].GetQtys();
                for (int j = 0; j < qtys.Length; j++)
                {
                    MRfQLineQty newQty = new MRfQLineQty(newLine);
                    newQty.SetC_UOM_ID(qtys[j].GetC_UOM_ID());
                    newQty.SetQty(qtys[j].GetQty());
                    newQty.SetIsOfferQty(qtys[j].IsOfferQty());
                    newQty.SetIsPurchaseQty(qtys[j].IsPurchaseQty());
                    newQty.SetMargin(qtys[j].GetMargin());
                    newQty.Save();
                }
                counter++;
            }   //	copy all lines
            return("# " + counter);
        }
コード例 #2
0
        /// <summary>
        /// </summary>
        /// <param name="_ds"></param> dataset contains all the records according to selection criteria.
        /// <returns></returns> returns the final message.
        private string CreateRfQ(DataSet _ds)
        {
            MRfQ   rfq = null;
            int    Requisition_ID = 0, LineNo = 0;
            string message = "";

            for (int i = 0; i < _ds.Tables[0].Rows.Count; i++)
            {
                // If document is not consolidated
                if (!isConsolidate)
                {
                    if (rfq == null || Requisition_ID != Util.GetValueOfInt(_ds.Tables[0].Rows[i]["M_Requisition_ID"]))
                    {
                        LineNo         = 0;
                        Requisition_ID = Util.GetValueOfInt(_ds.Tables[0].Rows[i]["M_Requisition_ID"]);
                        rfq            = new MRfQ(GetCtx(), 0, Get_TrxName());
                        rfq.SetAD_Org_ID(AD_Org_ID);
                        rfq.SetName("Name");
                        rfq.SetSalesRep_ID(GetCtx().GetAD_User_ID());
                        rfq.SetC_RfQ_Topic_ID(RfQTopic_ID);
                        rfq.SetM_Requisition_ID(Requisition_ID);
                        rfq.SetDateWorkStart(System.DateTime.Now);
                        rfq.SetDateResponse(DateResponse);      // Added by Bharat on 15 Jan 2019 as asked by Puneet
                        if (Util.GetValueOfDateTime(_ds.Tables[0].Rows[i]["DateRequired"]) >= System.DateTime.Now)
                        {
                            rfq.SetDateWorkComplete(Util.GetValueOfDateTime(_ds.Tables[0].Rows[i]["DateRequired"]));
                        }
                        if (string.IsNullOrEmpty(RfQtype))
                        {
                            rfq.SetQuoteType("S");
                        }
                        else
                        {
                            rfq.SetQuoteType(RfQtype);
                        }
                        rfq.SetIsInvitedVendorsOnly(true);
                        rfq.SetIsQuoteAllQty(true);
                        rfq.SetIsRfQResponseAccepted(true);
                        rfq.SetC_Currency_ID(C_Currency_ID);
                        if (rfq.Save())
                        {
                            DB.ExecuteQuery("UPDATE C_Rfq SET Name='" + rfq.GetDocumentNo() + "' WHERE C_RfQ_ID= " + rfq.GetC_RfQ_ID(), null, Get_TrxName());
                            if (message == "")
                            {
                                message = Msg.GetMsg(GetCtx(), "RfQGeneratedSuccess") + " =" + rfq.GetDocumentNo();
                            }
                            else
                            {
                                message = message + "," + rfq.GetDocumentNo();
                            }
                        }
                        else
                        {
                            ValueNamePair vp = VLogger.RetrieveError();
                            if (vp != null)
                            {
                                Get_TrxName().Rollback();
                                return(Msg.GetMsg(GetCtx(), "RfQHeadNotSaved") + "- " + vp.Name);
                            }
                            else
                            {
                                Get_TrxName().Rollback();
                                return(Msg.GetMsg(GetCtx(), "RfQHeadNotSaved"));
                            }
                        }
                    }
                }
                // If document is consolidated
                else
                {
                    if (rfq == null)
                    {
                        rfq = new MRfQ(GetCtx(), 0, Get_TrxName());
                        rfq.SetAD_Org_ID(AD_Org_ID);
                        rfq.SetName("Name");
                        rfq.SetSalesRep_ID(GetCtx().GetAD_User_ID());
                        rfq.SetC_RfQ_Topic_ID(RfQTopic_ID);
                        rfq.SetDateWorkStart(System.DateTime.Now);
                        rfq.SetDateResponse(DateResponse);      // Added by Bharat on 15 Jan 2019 as asked by Puneet
                        if (Util.GetValueOfDateTime(_ds.Tables[0].Rows[i]["DateRequired"]) >= System.DateTime.Now)
                        {
                            rfq.SetDateWorkComplete(Util.GetValueOfDateTime(_ds.Tables[0].Rows[i]["DateRequired"]));
                        }
                        if (string.IsNullOrEmpty(RfQtype))
                        {
                            rfq.SetQuoteType("S");
                        }
                        else
                        {
                            rfq.SetQuoteType(RfQtype);
                        }
                        rfq.SetIsInvitedVendorsOnly(true);
                        rfq.SetIsQuoteAllQty(true);
                        rfq.SetIsRfQResponseAccepted(true);
                        rfq.SetC_Currency_ID(C_Currency_ID);
                        if (!rfq.Save())
                        {
                            ValueNamePair vp = VLogger.RetrieveError();
                            if (vp != null)
                            {
                                Get_TrxName().Rollback();
                                return("RFQ Not Saved - " + vp.Name);
                            }
                            else
                            {
                                Get_TrxName().Rollback();
                                return("RFQ Not Saved");
                            }
                        }
                        else
                        {
                            DB.ExecuteQuery("UPDATE C_Rfq SET Name='" + rfq.GetDocumentNo() + "' WHERE C_RfQ_ID= " + rfq.GetC_RfQ_ID(), null, Get_TrxName());
                        }
                        message = "RfQ Generated =" + rfq.GetDocumentNo();
                    }
                }
                LineNo = LineNo + 10;
                // Create RfQ line
                MRfQLine RfqLine = new MRfQLine(rfq);
                RfqLine.SetLine(LineNo);
                RfqLine.SetM_RequisitionLine_ID(Util.GetValueOfInt(_ds.Tables[0].Rows[i]["M_RequisitionLine_ID"]));
                RfqLine.SetM_Product_ID(Util.GetValueOfInt(_ds.Tables[0].Rows[i]["M_Product_ID"]));
                if (Util.GetValueOfInt(_ds.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]) > 0)
                {
                    RfqLine.SetM_AttributeSetInstance_ID(Util.GetValueOfInt(_ds.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]));
                }
                RfqLine.SetDescription(Util.GetValueOfString(_ds.Tables[0].Rows[i]["Description"]));
                if (RfqLine.Save())
                {
                    // Create RfQ Qty
                    MRfQLineQty RfQLineQty = new MRfQLineQty(RfqLine);
                    RfQLineQty.SetC_UOM_ID(Util.GetValueOfInt(_ds.Tables[0].Rows[i]["C_UOM_ID"]));
                    RfQLineQty.SetQty(Util.GetValueOfDecimal(_ds.Tables[0].Rows[i]["Qty"]));
                    RfQLineQty.SetIsPurchaseQty(true);
                    RfQLineQty.SetIsRfQQty(true);
                    if (!RfQLineQty.Save())
                    {
                        ValueNamePair vp = VLogger.RetrieveError();
                        if (vp != null)
                        {
                            Get_TrxName().Rollback();
                            return(Msg.GetMsg(GetCtx(), "RfQLineQtyNotSaved") + "- " + vp.Name);
                        }
                        else
                        {
                            Get_TrxName().Rollback();
                            return(Msg.GetMsg(GetCtx(), "RfQLineQtyNotSaved"));
                        }
                    }
                }
                else
                {
                    ValueNamePair vp = VLogger.RetrieveError();
                    if (vp != null)
                    {
                        Get_TrxName().Rollback();
                        return(Msg.GetMsg(GetCtx(), "RfQLineNotSaved") + "- " + vp.Name);
                    }
                    else
                    {
                        Get_TrxName().Rollback();
                        return(Msg.GetMsg(GetCtx(), "RfQLineNotSaved"));
                    }
                }
            }

            return(message);
        }