コード例 #1
0
        public static List <XrefRecord> GetXrefList(User user, FilterInfo filter)
        {
            List <XrefRecord> ret = new List <XrefRecord>();

            try
            {
                var connection = ConnectionsMgr.GetOCConnection(user, Home);
                {
                    var recCount = _GetRecordCount(user, connection, filter);
                    if (recCount > 0)
                    {
                        filter.ResultCount = recCount;
                        filter.MaxPage     = (int)(Math.Ceiling(recCount / (double)resultPageSize));
                    }

                    using (var queryCurrent = connection.Select("*", CatXref, $"WHERE {filter.ToFetchQueryString(user, searchCols, resultPageSize)}"))
                    {
                        while (queryCurrent.Read())
                        {
                            XrefRecord xr = new XrefRecord(queryCurrent);
                            ret.Add(xr);
                        }
                    }
                }
                connection.Close();
            }
            catch (Exception e)
            {
                ProgramLog.LogError(user, nameof(CatalogXrefManager), nameof(GetXrefList), e.Message);
            }
            return(ret);
        }
コード例 #2
0
        public static bool CreateXref(User user, XrefRecord rec)
        {
            string sVendName  = rec.CompanyName.Truncate(60).SQLEscape();
            string sVendId    = rec.GXSAccount.Truncate(15).SQLEscape();
            string sVendSeq   = rec.SelectionCode.Truncate(3).SQLEscape();
            string sBrandName = rec.BrandName.Truncate(80).SQLEscape();
            string sCustomer  = user.Customer.SQLEscape();
            string sPartner   = user.ActivePartner.SQLEscape();
            string skey       = DBConnect.GenerateUniqueKey();
            Dictionary <string, string> insertDict = new Dictionary <string, string>()
            {
                { UniqueKey, skey },
                { VendorName, sVendName },
                { VendorId, sVendId },
                { VendorSeq, sVendSeq },
                { BrandName, sBrandName },
                { Customer, sCustomer },
                { Partner, sPartner }
            };

            try
            {
                DBConnect connection = ConnectionsMgr.GetOCConnection(user, Home);
                {
                    connection.Insert(CatXref, insertDict);
                }
                connection.Close();
            }
            catch (Exception e)
            {
                ProgramLog.LogError(user, nameof(CatalogXrefManager), nameof(CreateXref), e.Message);

                return(false);
            }
            return(true);
        }