Beispiel #1
0
        /// <summary>
        /// get accounting schema according to C_AcctSchema_Gl
        /// </summary>
        /// <param name="ad_client_id"></param>
        /// <returns></returns>
        private List <AcctViewerDatakeysParam> OtherAcctSchemas(int ad_client_id)
        {
            List <AcctViewerDatakeysParam> obj = new List <AcctViewerDatakeysParam>();
            string sql = "SELECT c_acctschema_id,name FROM C_AcctSchema acs "
                         + "WHERE IsActive='Y'"
                         + " AND EXISTS (SELECT * FROM C_AcctSchema_GL gl WHERE acs.C_AcctSchema_ID=gl.C_AcctSchema_ID)";

            if (Env.IsModuleInstalled("FRPT_"))
            {
                sql += " AND EXISTS (SELECT * FROM FRPT_AcctSchema_Default d WHERE acs.C_AcctSchema_ID=d.C_AcctSchema_ID)";
            }
            else
            {
                sql += " AND EXISTS (SELECT * FROM C_AcctSchema_Default d WHERE acs.C_AcctSchema_ID=d.C_AcctSchema_ID)";
            }
            if (ad_client_id != 0)
            {
                sql += " AND AD_Client_ID=" + ad_client_id;
            }

            sql += " ORDER BY C_AcctSchema_ID";

            DataSet ds = DB.ExecuteDataset(sql);

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                var id = Util.GetValueOfInt(ds.Tables[0].Rows[0]["c_acctschema_id"]);

                if (!c_acctschemas_ids.Contains(id))    //	already in _elements
                {
                    sql = "SELECT c_acctschema_id,name from C_AcctSchema WHERE C_AcctSchema_ID=" + id;
                    var drSch = DB.ExecuteDataset(sql);
                    if (drSch != null)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            AcctViewerDatakeysParam kp = new AcctViewerDatakeysParam();
                            kp.Key  = Util.GetValueOfInt(ds.Tables[0].Rows[i]["c_acctschema_id"]);
                            kp.Name = Util.GetValueOfString(ds.Tables[0].Rows[i]["name"]);
                            obj.Add(kp);
                        }
                    }
                }
            }
            return(obj);
        }
        /// <summary>
        /// Get Accounting Schema
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="ad_client_id"></param>
        /// <param name="ad_org_id"></param>
        /// <returns></returns>
        private List <AcctViewerDatakeysParam> GetAcctSchemas(int ad_client_id, int ad_org_id)
        {
            List <AcctViewerDatakeysParam> obj = new List <AcctViewerDatakeysParam>();
            string sql =
                sql = "SELECT C_ACCTSCHEMA_ID,NAME FROM C_AcctSchema WHERE ISACTIVE='Y' AND C_ACCTSCHEMA_ID IN( " +
                      "SELECT C_ACCTSCHEMA_ID FROM FRPT_AssignedOrg WHERE ISACTIVE='Y' AND AD_CLIENT_ID=" + ad_client_id + " AND AD_ORG_ID=" + ad_org_id + ")" +
                      //Get default Accounting schema selected on tenant
                      " OR C_ACCTSCHEMA_ID IN (SELECT C_ACCTSCHEMA1_ID  FROM AD_ClientInfo where  AD_Client_ID=" + ad_client_id + ")";

            DataSet ds = DB.ExecuteDataset(sql);

            if (ds != null)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    AcctViewerDatakeysParam kp = new AcctViewerDatakeysParam();
                    kp.Key  = Util.GetValueOfInt(ds.Tables[0].Rows[i]["C_ACCTSCHEMA_ID"]);
                    kp.Name = Util.GetValueOfString(ds.Tables[0].Rows[i]["NAME"]);
                    obj.Add(kp);
                }
                c_acctschemas_ids = Util.GetValueOfInt(ds.Tables[0].Rows[0]["C_ACCTSCHEMA_ID"]);
            }
            return(obj);
        }