/// <summary>
        /// GetDefault R_Status_ID
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="fields"></param>
        /// <returns></returns>
        public int GetDefaultR_Status_ID(Ctx ctx, string fields)
        {
            string[] paramValue = fields.Split(',');
            int      R_RequestType_ID;

            //Assign parameter value
            R_RequestType_ID = Util.GetValueOfInt(paramValue[0].ToString());
            //End Assign parameter value

            MRequestType rt          = MRequestType.Get(ctx, R_RequestType_ID);
            int          R_Status_ID = rt.GetDefaultR_Status_ID();

            return(R_Status_ID);
        }
Beispiel #2
0
        public JsonResult GetDefaultR_Status_ID(string fields)
        {
            string retJSON = "";

            if (Session["ctx"] != null)
            {
                VAdvantage.Utility.Ctx ctx = Session["ctx"] as Ctx;
                string[] paramValue        = fields.Split(',');
                int      R_RequestType_ID;

                //Assign parameter value
                R_RequestType_ID = Util.GetValueOfInt(paramValue[0].ToString());
                MRequestType rt          = MRequestType.Get(ctx, R_RequestType_ID);
                int          R_Status_ID = rt.GetDefaultR_Status_ID();


                //List<Decimal> retlst = new List<Decimal>();
                //retlst.Add(currentBalance);

                retJSON = JsonConvert.SerializeObject(R_Status_ID);
            }
            return(Json(retJSON, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        } //	prepare

        /// <summary>
        ///	Process
        /// </summary>
        /// <returns>info</returns>
        protected override String DoIt()
        {
            int lenth = 1;

            log.Info("R_RequestType_ID=" + _R_RequestType_ID + ", R_Group_ID=" + _R_Group_ID
                     + ", R_Category_ID=" + _R_Category_ID + ", C_BPartner_ID=" + _C_BPartner_ID
                     + ", _M_Product_ID=" + _M_Product_ID);

            MRequestType type = MRequestType.Get(GetCtx(), _R_RequestType_ID);

            if (type.Get_ID() == 0)
            {
                throw new Exception("@R_RequestType_ID@ @NotFound@ " + _R_RequestType_ID);
            }

            if (!type.IsInvoiced())
            {
                throw new Exception("@R_RequestType_ID@ <> @IsInvoiced@");
            }

            String sql = "SELECT * FROM R_Request r"
                         + " INNER JOIN R_Status s ON (r.R_Status_ID=s.R_Status_ID) "
                         + "WHERE s.IsClosed='Y'"
                         + " AND r.R_RequestType_ID=@Param1";

            if (_R_Group_ID != 0 && _R_Group_ID != -1)
            {
                sql  += " AND r.R_Group_ID=@Param2";
                lenth = lenth + 1;
            }
            if (_R_Category_ID != 0 && _R_Category_ID != -1)
            {
                sql  += " AND r.R_Category_ID=@Param3";
                lenth = lenth + 1;
            }
            if (_C_BPartner_ID != 0)
            {
                sql  += " AND r.C_BPartner_ID=@Param4";
                lenth = lenth + 1;
            }
            sql += " AND r.IsInvoiced='Y' "
                   + "ORDER BY C_BPartner_ID";
            SqlParameter[] Param = new SqlParameter[lenth];
            IDataReader    idr   = null;
            DataTable      dt    = null;

            try
            {
                int index = 0;
                Param[index] = new SqlParameter("@Param1", _R_RequestType_ID);
                if (_R_Group_ID != 0 && _R_Group_ID != -1)
                {
                    index++;
                    Param[index] = new SqlParameter("@Param2", _R_Group_ID);
                }
                if (_R_Category_ID != 0 && _R_Category_ID != -1)
                {
                    index++;
                    Param[index] = new SqlParameter("@Param3", _R_Category_ID);
                }
                if (_C_BPartner_ID != 0)
                {
                    index++;
                    Param[index] = new SqlParameter("@Param4", _C_BPartner_ID);
                }
                idr = DataBase.DB.ExecuteReader(sql, Param, Get_TrxName());
                dt  = new DataTable();
                dt.Load(idr);
                idr.Close();
                int oldC_BPartner_ID = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    MRequest request = new MRequest(GetCtx(), dr, Get_TrxName());
                    if (!request.IsInvoiced())
                    {
                        continue;
                    }
                    if (oldC_BPartner_ID != request.GetC_BPartner_ID())
                    {
                        InvoiceDone();
                    }
                    if (_m_invoice == null)
                    {
                        InvoiceNew(request);
                        oldC_BPartner_ID = request.GetC_BPartner_ID();
                    }
                    InvoiceLine(request);
                }
                InvoiceDone();
                //
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                log.Log(Level.SEVERE, sql, e);
            }
            finally
            {
                dt = null;
                if (idr != null)
                {
                    idr.Close();
                }
            }
            if (string.IsNullOrEmpty(_msg))
            {
                _msg = "No Invoice Generated";
            }
            //	R_Category_ID
            return(_msg);
        } //	doIt